Skip to content

Release automatically when the version changes - #10

Merged
jonathan-kosgei merged 1 commit into
mainfrom
auto-release
Nov 3, 2026
Merged

jonathan-kosgei merged 1 commit into
mainfrom
auto-release

Conversation

@jonathan-kosgei

@jonathan-kosgei jonathan-kosgei commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Merging a pull request that bumps VERSION in lib/ipdata/version.rb is now enough to tag the merge commit, create the GitHub release and publish the gem to RubyGems. No manual tagging is needed. The manual Publish to RubyGems run (bump input) and a pushed v* tag keep working as before.

How it works

  • ci.yml gains a release job that runs only on a push to the default branch, after the whole test matrix succeeds (permissions: contents: write, concurrency group release). It reads the version from lib/ipdata/version.rb, checks git ls-remote --exit-code --tags origin refs/tags/v<version> and, when the tag is missing (exit status 2), runs gh release create v<version> --target $GITHUB_SHA --title v<version> --generate-notes with the workflow token. When the tag exists it does nothing and says so, so the current 0.2.0, which is already tagged, is not released again. The job exposes the outputs tag and created.
  • A tag or release created with GITHUB_TOKEN does not trigger other workflows, so a publish job in the same run (needs: release, if: needs.release.outputs.created == 'true', contents: write and id-token: write) calls release.yml as a reusable workflow with that tag.
  • release.yml gains an on: workflow_call trigger with a required tag input. Its release job also runs when that input is set and then checks out refs/tags/<tag>; a manual bump run still checks out main and a tag push still checks out the pushed tag. The publish steps (tests, rubygems/release-gem@v1 with trusted publishing) are unchanged and exist once, in release.yml, so the RubyGems trusted publisher configured for that file keeps matching.
  • README: new "Releasing" section after "Development".

Verification

  • Both workflows parse as YAML and actionlint (with shellcheck) reports no errors.
  • The version command prints 0.2.0 for the checked-out lib/ipdata/version.rb.
  • The release step's script was run locally against origin with a stub gh: for 0.2.0 it reports that v0.2.0 exists and sets created=false; for an untagged version it invokes gh release create v9.9.9 --target <sha> --title v9.9.9 --generate-notes and sets created=true; an unreadable version fails the step.
  • The test suite and the gem build pass as before; nothing outside .github/ and the README changed.
  • The push-triggered release job cannot run before this is merged. Its first run after the merge should report that v0.2.0 already exists and publish nothing.

🤖 Generated with Claude Code

Add a release job to the CI workflow: after the tests pass on a push to
the default branch it reads lib/ipdata/version.rb and, when tag
v<version> does not exist, creates the tag and the GitHub release. A tag
created with the workflow token starts no other workflow, so a publish
job in the same run calls the release workflow, which gains a
workflow_call trigger with a tag input and checks that tag out. The
manual bump run and a pushed tag publish as before. Document the
process in the README.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jonathan-kosgei
jonathan-kosgei merged commit 9bbf98a into main Nov 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants