Repository navigation
Release automatically when the version changes - #39
Merged
Merged
Conversation
Add a release job to the CI workflow that runs on pushes to the default branch after build-and-test. It reads VersionPrefix from src/IPData/IPData.csproj and, when the tag vX.Y.Z does not exist yet, creates the tag and the GitHub release with generated notes. A release created with the workflow token does not trigger other workflows, so the NuGet publish workflow becomes callable with a tag input and runs in the same run when a release was created. Its release trigger stays, so a manually published release still publishes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Explain that merging a pull request that bumps VersionPrefix tags the merge commit, creates the GitHub release and publishes the package to NuGet, and that a version that is already tagged publishes nothing. 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
VersionPrefixinsrc/IPData/IPData.csprojis now enough to tag the release, create the GitHub release and publish the package to NuGet. No manual tagging is needed any more; a merge whose version is already tagged publishes nothing..github/workflows/ci.yml: newreleasejob (push to the default branch only, afterbuild-and-test) and apublishjob that calls the NuGet workflow when a release was created..github/workflows/publish.yml: also callable (workflow_callwith ataginput); the version comes from the input and falls back to the ref name, so the existingrelease: publishedtrigger keeps working for manually published releases..github/README.md: a maintainer-facing "Releasing" section.How it works
releaseruns only forpushevents on the repository's default branch, afterbuild-and-testsucceeds, withcontents: writeand areleaseconcurrency group so two merges cannot race.VersionPrefixfromsrc/IPData/IPData.csproj, derives the tagvX.Y.Zand checksgit ls-remote --exit-code --tags origin refs/tags/vX.Y.Z. Exit status 2 (tag missing) leads togh release create vX.Y.Z --target $GITHUB_SHA --title vX.Y.Z --generate-notes, which creates the tag and the release in one step; exit status 0 (tag exists) logs that there is nothing to release; any other status fails the job. The job exposes the outputstagandcreated.publishjob (needs: release,if: needs.release.outputs.created == 'true') callspublish.ymlwith the tag andsecrets: inherit. The build, test, pack and push steps and the secret they use are unchanged.Verification
3.1.0for the checked-out csproj;v3.1.0is not tagged yet, so the first merge of this change tags and publishes 3.1.0 (v3.0.2is the latest existing tag).gh: a missing tag produces the expectedgh release createcall andcreated=true; an existing tag (v3.0.2) producescreated=false; an unreachable remote and a csproj withoutVersionPrefixfail the step.releasejob itself cannot run before this is merged; the pull request CI run coversbuild-and-test.🤖 Generated with Claude Code