Repository navigation
Release automatically when the version changes - #6
Merged
Merged
Conversation
Add a release job to ci.yml that runs on pushes to the default branch after both test matrices succeed. It reads the version from the `from:` argument of the README install snippet and, when the tag vX.Y.Z does not exist yet, creates the tag and the GitHub release at the pushed commit with generated notes. Swift Package Manager and the Swift Package Index resolve releases from the tags, so no further publishing step is needed. Document the flow in a Releasing section of the README. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Merging a pull request that bumps the version in the README install snippet is now enough to tag and publish a GitHub release; no manual tagging is needed. A
releasejob is added toci.ymlafter the two test matrices, and a maintainer-facing "Releasing" section is added to the README. Nothing else is published from CI: Swift Package Manager and the Swift Package Index resolve releases from the Git tags.How it works
releasejob runs only onpushto the default branch (github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)), aftertest-linuxandtest-macossucceed, withpermissions: contents: writeandconcurrency: { group: release, cancel-in-progress: false }so two merges never race.from:argument of the README install snippet (sed -nE 's/.*from: *"([^"]+)".*/\1/p' README.md | head -1) and derives the tagv<version>.git ls-remote --exit-code --tags origin "refs/tags/$TAG"decides what happens: exit 0 means the tag exists, so the job logs that and stops; exit 2 means it is missing, sogh release create "$TAG" --target "$GITHUB_SHA" --title "$TAG" --generate-notes(withGH_TOKEN: ${{ github.token }}) creates the tag and the release at the merge commit; any other exit status fails the job without releasing anything.tagandcreatedoutputs. Onpull_requestruns it is skipped.1.0.2and nov1.0.2tag exists, so the first push tomainafter this merges will createv1.0.2and its release.Verification
python3 -c 'import yaml,sys; [yaml.safe_load(open(f)) for f in sys.argv[1:]]' .github/workflows/*.ymlparses the workflow, andactionlint1.7.12 reports nothing.1.0.2against the checked-out README. The new README text deliberately does not containfrom: ", so it can never be picked up instead of the install snippet.run:scripts were executed locally withbash -eo pipefailagainst the real remote and a stubgh: a missing tag (v1.0.2) callsgh release create v1.0.2 --target <sha> --title v1.0.2 --generate-notesand setscreated=true; an existing tag (v1.0.1) setscreated=falseand does not callgh; a failinggit ls-remotefails the job without callinggh; a README without a version fails the job.releasejob itself cannot run before this is merged. Thepull_requestCI run on this branch shows it as skipped, with the test matrices unchanged.🤖 Generated with Claude Code