Repository navigation
Release automatically when the version changes - #4
Merged
Merged
Conversation
After the test matrix, a release job on pushes to the default branch reads $VERSION from lib/Net/IPData.pm and, when the tag vX.Y.Z does not exist yet, creates the tag and the GitHub release with generated notes. A tag created with the workflow's own token starts no other workflow run, so the CPAN upload runs in the same run: release.yml is now also callable (workflow_call with a tag input; the release trigger stays) and ci.yml calls it with inherited secrets. A merge whose version is already tagged publishes nothing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a Releasing section to the README and a Changes entry: bump $VERSION and date the Changes entry in a pull request, merge, and CI tags, releases and uploads to CPAN. 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
A merge to
mainthat bumps$VERSIONinlib/Net/IPData.pmis now enough to tagvX.Y.Z, create the GitHub release and upload the distribution to CPAN. Nothing is tagged by hand any more, and a merge whose version is already tagged publishes nothing.ci.yml: areleasejob after the test matrix (pushes to the default branch only) and apublishjob that calls the CPAN upload workflow when a tag was created.release.yml: now also callable (workflow_callwith ataginput). Therelease: publishedtrigger is kept, so a release published by hand still uploads its tag. The build and upload steps and the secrets they use are unchanged.Changes: anUnreleasedentry, since this file logs CI changes too.How it works
releaseruns after every matrix leg has passed, only forpushevents on the repository's default branch, withcontents: writeand thereleaseconcurrency group (no cancellation), so two merges in a row are handled one after the other.sed -nE "s/.*VERSION *= *['\"]([^'\"]+)['\"].*/\1/p" lib/Net/IPData.pm | head -1and derives the tagv<version>.git ls-remote --exit-code --tags origin "refs/tags/$TAG"decides: exit 0 means the tag exists (nothing to do, outputcreated=false); exit 2 means it is missing, sogh release create "$TAG" --target "$GITHUB_SHA" --title "$TAG" --generate-notescreates the tag and the release in one step (created=true); any other exit status fails the job.GITHUB_TOKENdoes not start other workflow runs, so the upload has to happen in the same run:publish(needs: release,if: needs.release.outputs.created == 'true') callsrelease.ymlwith the tag andsecrets: inherit. The called workflow checks out the tag it was given (falling back togithub.event.release.tag_nameon the release trigger), then builds, tests, builds the distribution and runscpan-uploadexactly as before.releaseandpublishare skipped there.Verification
actionlint1.7.12 (with shellcheck 0.9.0) reports nothing.1.1.0for the checked-outlib/Net/IPData.pm;git ls-remote --exit-code --tags origin refs/tags/v9.9.9exits with 2 for a missing tag and with 0 for the existingv1.1.0.releasejob were run locally withbash -e, a stubghand a temporaryGITHUB_OUTPUT: existing tag ->created=false; missing tag ->gh release create v9.9.9 --target <sha> --title v9.9.9 --generate-notesandcreated=true; a failingls-remote-> the job fails with its status; a module file without$VERSION-> the job fails.perl Makefile.PL && make && make test(180 tests) andmake distsucceed on this branch; the tarball carries the updatedChangesand README.releasejob itself and its call intorelease.yml. The first run onmainwill findv1.1.0already tagged and publish nothing; the next version bump exercises the full path.🤖 Generated with Claude Code