Repository navigation
ci: prepare release drafts before tagging #11569
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
Merged
Roasbeef
merged 2 commits into
lightningnetwork:master
from
yyforyongyu:task-release-preflight
Nov 13, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Exercise the release workflow's actual preparation step with local Git and | ||
| # fixture CLI output, so checks cannot create public tags or release assets. | ||
| set -euo pipefail | ||
|
|
||
| DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| WORK="$(mktemp -d)" | ||
| trap 'rm -rf "$WORK"' EXIT | ||
|
|
||
| # Arrange the workflow contract check by loading YAML with Ruby's standard | ||
| # library, which also lets the execution cases reuse the actual shell block. | ||
| ruby -ryaml - "$DIR/../.github/workflows/release.yaml" "$WORK/prepare.sh" <<'RUBY' | ||
| workflow = YAML.load_file(ARGV.fetch(0)) | ||
| # YAML 1.1 treats the Actions key "on" as true; accept either parser spelling. | ||
| events = workflow['on'] || workflow[true] | ||
| steps = workflow.fetch('jobs').fetch('main').fetch('steps') | ||
|
|
||
| # Act by reading the public trigger and draft settings rather than matching | ||
| # implementation text inside the workflow's shell commands. | ||
| push = events.fetch('push') | ||
| release = steps.find { |step| step['name'] == 'Create Release' }.fetch('with') | ||
| version = steps.find { |step| step['id'] == 'version' } | ||
|
|
||
| # Assert that version-file pushes prepare drafts at an exact commit and that | ||
| # pushing the human-signed tag cannot rerun this release build. | ||
| raise 'release branch filter' unless push['branches'] == ['v0.*-branch'] | ||
| raise 'version path filter' unless push['paths'] == ['build/version.go'] | ||
| raise 'unexpected tag trigger' if push.key?('tags') | ||
| raise 'manual retry unavailable' unless events.key?('workflow_dispatch') | ||
| raise 'release must stay draft' unless release['draft'] == true | ||
| unless release['tag_name'] == '${{ env.RELEASE_VERSION }}' | ||
| raise 'prospective tag missing' | ||
| end | ||
| unless release['target_commitish'] == '${{ github.sha }}' | ||
| raise 'tested commit missing' | ||
| end | ||
| File.write(ARGV.fetch(1), version.fetch('run')) | ||
| RUBY | ||
|
|
||
| # Supply only the established lnd version output; Git operations remain real. | ||
| mkdir "$WORK/bin" | ||
| cat > "$WORK/bin/go" <<'SH' | ||
| #!/bin/bash | ||
| # Reject other calls so the fixture cannot hide a different build operation. | ||
| [[ "$*" == 'run ./cmd/lnd --version' ]] || exit 1 | ||
| printf 'lnd version %s commit=fixture\n' "$TEST_VERSION" | ||
| SH | ||
| chmod +x "$WORK/bin/go" | ||
|
|
||
| # new_repo isolates each case with a committed HEAD and a local bare origin. | ||
| # Disable commit signing only in the fixture so tests never use a human key. | ||
| new_repo() { | ||
| REPO="$WORK/$1" | ||
| git init --quiet "$REPO" | ||
| git -C "$REPO" -c user.name=Fixture -c user.email=fixture@example.com \ | ||
| -c commit.gpgSign=false commit --quiet --allow-empty -m fixture | ||
| git init --quiet --bare "$REPO.git" | ||
| git -C "$REPO" remote add origin "$REPO.git" | ||
| : > "$REPO/env" | ||
| } | ||
|
|
||
| # Arrange a new release and a signing preference that CI must override without | ||
| # accessing a private key. Its origin initially has no published tag. | ||
| new_repo release | ||
| git -C "$REPO" config tag.gpgSign true | ||
|
|
||
| # Act by executing the workflow's preparation block in the fixture checkout, | ||
| # supplying the same environment-file interface used by the Actions runner. | ||
| ( | ||
| cd "$REPO" | ||
| PATH="$WORK/bin:$PATH" TEST_VERSION=0.21.9-beta GITHUB_ENV="$REPO/env" \ | ||
| bash -eo pipefail "$WORK/prepare.sh" | ||
| ) | ||
|
|
||
| # Assert that CI exports the derived version and creates only an unsigned | ||
| # local tag at the tested commit; nothing reaches even the local bare origin. | ||
| grep -qx 'RELEASE_VERSION=v0.21.9-beta' "$REPO/env" | ||
| test "$(git -C "$REPO" rev-parse refs/tags/v0.21.9-beta)" = \ | ||
| "$(git -C "$REPO" rev-parse HEAD)" | ||
| test "$(git -C "$REPO" cat-file -t refs/tags/v0.21.9-beta)" = commit | ||
| if git --git-dir="$REPO.git" show-ref --verify --quiet \ | ||
| refs/tags/v0.21.9-beta; then | ||
| echo 'FAIL: preparation published a tag' >&2 | ||
| exit 1 | ||
| fi | ||
| echo 'ok: new release prepares only a local unsigned tag' | ||
|
|
||
| # Arrange the documented development version in a fresh repository, so no | ||
| # release from another case can accidentally make the skip assertions pass. | ||
| new_repo development | ||
|
|
||
| # Act through the same workflow block with the development CLI version. | ||
| ( | ||
| cd "$REPO" | ||
| PATH="$WORK/bin:$PATH" TEST_VERSION=0.21.99-beta GITHUB_ENV="$REPO/env" \ | ||
| bash -eo pipefail "$WORK/prepare.sh" | ||
| ) | ||
|
|
||
| # Assert that no release version is exported and no local tag is created, | ||
| # leaving the later notes, build, and upload steps without a release to run. | ||
| test ! -s "$REPO/env" | ||
| test -z "$(git -C "$REPO" tag --list)" | ||
| echo 'ok: development version skips release preparation' | ||
|
|
||
| # Arrange an already present release tag and remember its object so a retry | ||
| # must preserve it rather than replacing it with the current checkout. | ||
| new_repo tagged | ||
| git -C "$REPO" -c tag.gpgSign=false tag v0.21.9-beta | ||
| TAG_OBJECT="$(git -C "$REPO" rev-parse refs/tags/v0.21.9-beta)" | ||
|
|
||
| # Act by requesting preparation of that same version through the workflow. | ||
| ( | ||
| cd "$REPO" | ||
| PATH="$WORK/bin:$PATH" TEST_VERSION=0.21.9-beta GITHUB_ENV="$REPO/env" \ | ||
| bash -eo pipefail "$WORK/prepare.sh" | ||
| ) | ||
|
|
||
| # Assert that already tagged releases export no preparation version and keep | ||
| # the original object, preventing a retry from replacing release assets. | ||
| test ! -s "$REPO/env" | ||
| test "$(git -C "$REPO" rev-parse refs/tags/v0.21.9-beta)" = "$TAG_OBJECT" | ||
| echo 'ok: already tagged release skips preparation' | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Non-blocking: this guards the workflow contract (triggers, draft settings, prepare-step semantics), but nothing in CI runs it, so a future edit to
release.yamlcould silently break the contract it pins. Worth wiring into an existing shell/static-check job (it only needs bash, git, ruby — no Docker) in a follow-up.