Repository navigation
fix: publish GitHub releases without pushing to main #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,10 @@ jobs: | |
| aws_assume_role: ${{ vars.AWS_ROLE_ARN }} | ||
| ssm_parameter_pairs: '/global/services/docker/public/username = DOCKER_USERNAME, /global/services/docker/public/token = DOCKER_TOKEN' | ||
| - name: set release token | ||
| run: echo "GITHUB_TOKEN=$GITHUB_RELEASE_TOKEN" >> $GITHUB_ENV | ||
| run: | | ||
| if [[ -n "${GITHUB_RELEASE_TOKEN:-}" ]]; then | ||
| echo "GITHUB_TOKEN=$GITHUB_RELEASE_TOKEN" >> "$GITHUB_ENV" | ||
| fi | ||
| - name: setup access for find-code-references | ||
| uses: launchdarkly/gh-actions/actions/ssh-key-by-repo@main | ||
| with: | ||
|
|
@@ -55,7 +58,9 @@ jobs: | |
|
|
||
| make build | ||
| - name: prepare release | ||
| run: ./scripts/release/prepare-release.sh | ||
| run: | | ||
| ./scripts/release/prepare-release.sh | ||
| echo "RELEASE_COMMIT=$(git rev-parse HEAD)" >> "$GITHUB_ENV" | ||
| - name: publish | ||
| run: | | ||
| if [[ "$DRY_RUN" = true ]]; then | ||
|
|
@@ -67,12 +72,24 @@ jobs: | |
| run: | | ||
| git show -p | ||
| ls -1a "$ARTIFACT_DIRECTORY" | ||
| - name: push to origin | ||
| - name: push tag to origin | ||
| continue-on-error: true | ||
| run: ./scripts/release/push-to-origin.sh | ||
| - name: create Github release | ||
| uses: ncipollo/release-action@v1.14.0 | ||
| if: ${{ !inputs.dryRun }} | ||
| with: | ||
| token: ${{ github.token }} | ||
| tag: v${{ inputs.releaseVersion }} | ||
| commit: ${{ env.RELEASE_COMMIT }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Failed tag push cannot create releaseMedium Severity If the tag push fails, the bump commit never reaches GitHub. Additional Locations (1)Reviewed by Cursor Bugbot for commit eb2eda7. Configure here. |
||
| body: ${{ inputs.changeLog }} | ||
| artifacts: ${{ env.ARTIFACT_DIRECTORY }}/* | ||
| draft: true | ||
| allowUpdates: true | ||
| updateOnlyUnreleased: true | ||
| artifactErrorsFailBuild: true | ||
| - name: publish Github release | ||
| if: ${{ !inputs.dryRun }} | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: gh release edit "v${LD_RELEASE_VERSION}" --draft=false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT="$(cd "$(dirname "$0")" && pwd)/push-to-origin.sh" | ||
| root="$(cd "$(dirname "$0")/../.." && pwd)" | ||
| workdir=$(mktemp -d "$root/.push-to-origin-test.XXXXXX") | ||
| trap 'rm -rf "$workdir"' EXIT | ||
|
|
||
| git init --bare --initial-branch=main "$workdir/remote.git" >/dev/null | ||
| git clone "$workdir/remote.git" "$workdir/local" >/dev/null 2>&1 | ||
| cd "$workdir/local" | ||
|
|
||
| git config user.email "test@example.com" | ||
| git config user.name "test" | ||
|
|
||
| echo init > file | ||
| git add file | ||
| git commit --no-verify -m init >/dev/null | ||
| git push -u origin main >/dev/null | ||
| main_sha=$(git rev-parse origin/main) | ||
|
|
||
| echo bump > file | ||
| git add file | ||
| git commit --no-verify -m bump >/dev/null | ||
| git tag v2.99.0 | ||
| bump_sha=$(git rev-parse HEAD) | ||
|
|
||
| export LD_RELEASE_VERSION=2.99.0 | ||
| export DRY_RUN=false | ||
| "$SCRIPT" | ||
|
|
||
| remote_tag=$(git ls-remote --tags origin "refs/tags/v2.99.0" | awk '{print $1}') | ||
| if [[ "$remote_tag" != "$bump_sha" ]]; then | ||
| echo "expected origin tag v2.99.0 -> $bump_sha, got ${remote_tag:-empty}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| remote_main=$(git rev-parse origin/main) | ||
| if [[ "$remote_main" != "$main_sha" ]]; then | ||
| echo "origin/main moved; expected $main_sha, got $remote_main" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| "$SCRIPT" | ||
|
|
||
| echo "push-to-origin_test.sh ok" |


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Publish aborts on unset GITHUB_TOKEN
High Severity
When
GITHUB_RELEASE_TOKENis empty,GITHUB_TOKENis no longer exported toGITHUB_ENV.stage-artifacts.shlater expands$GITHUB_TOKENunderset -u, so the publish step dies before Docker Hub, Homebrew, or the GitHub release run.Reviewed by Cursor Bugbot for commit eb2eda7. Configure here.