Repository navigation
Release automatically when the version changes - #14
Merged
Merged
Conversation
Add a release job to the CI workflow that runs on pushes to the default branch once the test jobs have passed. It reads the first "## x.y.z" heading of CHANGELOG.md and, when no tag of that name exists, creates the tag and the GitHub release with generated notes in one step; Packagist picks the tag up through its webhook. A push whose version is already tagged releases nothing. Document the flow in a README "Releasing" section and in the changelog. 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
masterthat puts a new## x.y.zheading at the top ofCHANGELOG.mdis now enough to tag the release and create the GitHub release; Packagist picks the tag up through its webhook, so no manual tagging is needed. The README gets a maintainer-facing "Releasing" section and the changelog an entry under 0.1.3.How it works
releasejob inci.ymlruns onpushto the default branch only (guarded bygithub.event_name == 'push'andgithub.ref == refs/heads/<default branch>), afterbuild-lowest-versionandbuildhave succeeded, withpermissions: contents: writeand areleaseconcurrency group that does not cancel runs in progress. On pull requests it is skipped.## x.y.zheading ofCHANGELOG.md(composer.jsonhas noversionfield; Packagist reads the versions from the tags) and uses it as the tag name without avprefix, matching the existing tags0.1.0to0.1.2.git ls-remote --exit-code --tags origin refs/tags/<tag>decides what happens: exit 0 means the tag exists, so the job says so and ends withcreated=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 with the workflow'sGITHUB_TOKENand the job ends withcreated=true; any other exit code fails the job.tagandcreatedoutputs so a publish job could be attached later; nothing publishes from CI here because Packagist is fed by its webhook.Verification
python3 -c 'import yaml,sys; [yaml.safe_load(open(f)) for f in sys.argv[1:]]' .github/workflows/*.ymlpasses.actionlint .github/workflows/*.yml(v1.7.12) reports nothing.sed -nE 's/^## ([0-9][^[:space:]]*).*/\1/p' CHANGELOG.md | head -1prints0.1.3on this branch.gh: for0.1.2(tagged) the job reports that the tag exists and setscreated=false; for0.1.3(untagged) it callsgh release create 0.1.3 --target <sha> --title 0.1.3 --generate-notesand setscreated=true. Against this repositorygit ls-remote --exit-codereturns 0 for0.1.2and 2 for0.1.3.releasejob itself can only run after the merge.CHANGELOG.mdalready carries## 0.1.3at the top and no0.1.3tag exists, so the first push tomasterafter merging this PR tags0.1.3at that merge commit and creates its release.🤖 Generated with Claude Code