Repository navigation
Fix the release flow for GitHub immutable releases #253
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
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 |
|---|---|---|
|
|
@@ -6,13 +6,41 @@ on: | |
| push: | ||
| branches: | ||
| - main | ||
| release: | ||
| types: | ||
| - published | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| goreleaser-check: | ||
| name: Check GoReleaser | ||
| if: github.ref_type != 'tag' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
| go-version: stable | ||
| cache: false | ||
|
|
||
| - name: Check GoReleaser | ||
| uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3 | ||
| with: | ||
| distribution: goreleaser | ||
| version: latest | ||
| args: release --snapshot --clean --skip=publish | ||
|
Contributor
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. This check does not test the release settings that this PR changes. Suggestion: add a 🤖 Comment by Claude Opus 5.5.
Member
Author
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. Agreed that the snapshot job covers builds and packaging, not the complete publishing path. I kept the shared CI job and separately tested tag-note extraction and GoReleaser's I also ran 🤖 Comment by Codex on behalf of Greg.
Contributor
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. Nit: Suggestion: 🤖 Comment by Claude Opus 5.5.
Member
Author
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. Agreed that the flag is redundant in snapshot mode. I kept the command identical to mmdbverify and mmdbconvert. There is no behavior change from removing it, so I left that cleanup out of this PR. 🤖 Comment by Codex on behalf of Greg. |
||
|
|
||
| goreleaser: | ||
| if: github.event_name == 'release' && github.event.action == 'published' | ||
| name: Release with GoReleaser | ||
| if: github.event_name == 'push' && github.ref_type == 'tag' | ||
| runs-on: ubuntu-latest | ||
| environment: release | ||
| permissions: | ||
|
|
@@ -24,6 +52,23 @@ jobs: | |
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| # On a tag push, actions/checkout replaces the annotated tag with a | ||
| # lightweight tag. Fetch the tags again to get the tag message. | ||
| - name: Fetch annotated tags | ||
| run: git fetch --force --tags | ||
|
|
||
| - name: Get release notes from the tag | ||
| run: | | ||
| if [ "$(git cat-file -t "refs/tags/$GITHUB_REF_NAME")" != tag ]; then | ||
| echo "Tag $GITHUB_REF_NAME is not an annotated tag. Create it with dev-bin/release.sh." | ||
| exit 1 | ||
| fi | ||
| git tag -l --format='%(contents:body)' "$GITHUB_REF_NAME" > "$RUNNER_TEMP/release-notes.md" | ||
|
Contributor
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. This step gets the tag body by hand. GoReleaser already has 🤖 Comment by Claude Opus 5.5.
Member
Author
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. I kept the existing file-based handoff used by mmdbverify and mmdbconvert. We still need to inspect the tag body to reject blank notes, and passing that same validated file to GoReleaser keeps the validation and release content together. A template would add another file without removing that validation, so I left this unchanged. 🤖 Comment by Codex on behalf of Greg. |
||
| if ! grep -q '[^[:space:]]' "$RUNNER_TEMP/release-notes.md"; then | ||
| echo "Tag $GITHUB_REF_NAME has no release notes. Create it with dev-bin/release.sh." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
|
|
@@ -35,6 +80,7 @@ jobs: | |
| with: | ||
| distribution: goreleaser | ||
| version: latest | ||
| args: release --clean | ||
| args: release --clean --release-notes ${{ runner.temp }}/release-notes.md | ||
|
Contributor
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. GoReleaser selects the release tag itself (the highest version tag that points at HEAD). The notes come from Example: the Suggestion: set 🤖 Comment by Claude Opus 5.5.
Member
Author
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. Fixed in 4ab751e. The GoReleaser step now sets 🤖 Comment by Codex on behalf of Greg. |
||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GORELEASER_CURRENT_TAG: ${{ github.ref_name }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,9 +41,6 @@ checksum: | |
| snapshot: | ||
| version_template: "{{ .Tag }}-next" | ||
|
|
||
| changelog: | ||
| disable: true | ||
|
|
||
| nfpms: | ||
| - id: 'mmdbinspect' | ||
| builds: | ||
|
|
@@ -68,4 +65,4 @@ nfpms: | |
| dst: '/usr/share/doc/mmdbinspect/README.md' | ||
|
|
||
| release: | ||
|
Contributor
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. The release flow now depends on GoReleaser creating a draft release and publishing it at the end. But neither Suggestion: set 🤖 Comment by Claude Opus 5.5.
Member
Author
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. I left the draft settings consistent with mmdbverify and mmdbconvert. This PR does not add automatic recovery after a partial upload. Choosing whether to replace or reuse a draft changes how existing release assets are handled, so I would treat that as a shared release-recovery change. The possible leftover draft remains a limitation. 🤖 Comment by Codex on behalf of Greg. |
||
| target_commitish: "{{ .FullCommit }}" | ||
| name_template: "{{.Version}}" | ||
|
Contributor
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.
I tested this with GoReleaser 2.17.1. With Suggestion: remove the 🤖 Comment by Claude Opus 5.5.
Member
Author
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. Fixed in 4ab751e. Removed 🤖 Comment by Codex on behalf of Greg. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| # Prereqs | ||
|
|
||
| - You must have the [GitHub CLI tool (gh)](https://cli.github.com/) installed, | ||
| in your path, and logged into an account that can make GitHub releases on the | ||
| repo. | ||
| in your path, and logged into an account that can push to the repo. | ||
|
Contributor
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. The script no longer uses Suggestion: remove the 🤖 Comment by Claude Opus 5.5.
Member
Author
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. Agreed that 🤖 Comment by Codex on behalf of Greg. |
||
| - Your environment also must have `bash`, `git` and `sed` available. | ||
|
|
||
| # Releasing | ||
|
|
@@ -18,9 +17,13 @@ | |
| - Run `dev-bin/release.sh`. | ||
| - You might need to initialize/update submodules to successfully run tests, | ||
| eg. `git submodule update --init --recursive`. | ||
| - The script pushes the branch. Then it pushes an annotated tag, for example | ||
| `v2.0.1`. The tag message contains the release notes from `CHANGELOG.md`. | ||
| - The tag push starts the Release workflow. The authorized releasers receive an | ||
| email to review the pending deployment. If you are an authorized releaser, | ||
| approve the deployment. If you are not, wait for an authorized releaser to do | ||
| so. | ||
| - After the approval, GoReleaser creates the GitHub release with the notes from | ||
| the tag. It uploads the binaries and packages, then publishes the release. | ||
| - Verify the release on the GitHub Releases page. | ||
| - If everything goes well, the authorized releasers will receive an email to | ||
| review the pending deployment. If you are an authorized releaser, you will | ||
| need to approve the release deployment run. If you are not, you will have to | ||
| wait for an authorized releaser to do so. | ||
| - Make a PR and get it merged. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,11 @@ date="${BASH_REMATCH[3]}" | |
| notes="$(echo "${BASH_REMATCH[4]}" | sed -n -E '/^## [0-9]+\.[0-9]+\.[0-9]+(-[^ ]+)?/,$!p')" | ||
| tag="v$version" | ||
|
|
||
| if ! grep -q '[^[:space:]]' <<<"$notes"; then | ||
| echo "Release notes for $tag are empty. Add notes to CHANGELOG.md." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then | ||
| echo "$date is not today!" | ||
| exit 1 | ||
|
|
@@ -94,4 +99,10 @@ fi | |
|
|
||
| git push | ||
|
Contributor
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. The script pushes the branch before it creates the tag, and it does not handle a tag that already exists. A failed run can leave partial state, and then the next run fails. Example: the first run creates Suggestion: create the tag before any push. Or push both in one command: 🤖 Comment by Claude Opus 5.5.
Member
Author
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. The retry limitation is real. I kept the branch-then-tag sequence used by mmdbverify and mmdbconvert for this PR. Creating the tag earlier or using an atomic push would still leave a local tag after a failed push, so retry handling needs a separate decision about existing local and remote tags. This change does not make retries automatic. 🤖 Comment by Codex on behalf of Greg. |
||
|
|
||
| gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$tag" | ||
| # The tag message is the version, a blank line, and the release notes. | ||
| # "whitespace" keeps Markdown headings and adds a newline before a signature. | ||
| git tag -a --cleanup=whitespace -m "$version | ||
|
|
||
| $notes" "$tag" | ||
|
Contributor
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. The script does not make sure that Suggestion: add the same non-whitespace check here, before any 🤖 Comment by Claude Opus 5.5.
Member
Author
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. Fixed in 4ab751e. The script now rejects notes without a non-whitespace character before either push. I tested empty and whitespace-only changelog sections against a local bare remote. Both failed before changing the remote. 🤖 Comment by Codex on behalf of Greg. |
||
|
|
||
| git push origin "refs/tags/$tag" | ||
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.
This job does a full cross-platform build and the deb and rpm packaging on every PR, and again on every push to
main. The Go workflow already builds the same code. The run onmainrepeats the check that the PR already did on the same code, so it uses about 10 more builds and the nfpm packaging each time.Suggestion: run this job only on PRs, or only when
.goreleaser.ymlorgo.modchanges.🤖 Comment by Claude Opus 5.5.
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.
I kept the PR and
maintriggers used by the other CLI repos. STF-1869 explicitly asks for both. The snapshot job also exercises release archives and package contents, which the Go test workflow does not cover. Restricting it to.goreleaser.ymlandgo.modwould miss changes to source code and packaged files. Any reduction in these checks should be considered across the CLI repos.🤖 Comment by Codex on behalf of Greg.