Skip to content

Release automatically when the version changes - #39

Merged
jonathan-kosgei merged 2 commits into
masterfrom
auto-release
Nov 3, 2026
Merged

jonathan-kosgei merged 2 commits into
masterfrom
auto-release

Conversation

@jonathan-kosgei

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

Copy link
Copy Markdown
Collaborator

Summary

Merging a pull request that bumps VersionPrefix in src/IPData/IPData.csproj is 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: new release job (push to the default branch only, after build-and-test) and a publish job that calls the NuGet workflow when a release was created.
  • .github/workflows/publish.yml: also callable (workflow_call with a tag input); the version comes from the input and falls back to the ref name, so the existing release: published trigger keeps working for manually published releases.
  • .github/README.md: a maintainer-facing "Releasing" section.

How it works

  1. release runs only for push events on the repository's default branch, after build-and-test succeeds, with contents: write and a release concurrency group so two merges cannot race.
  2. It reads VersionPrefix from src/IPData/IPData.csproj, derives the tag vX.Y.Z and checks git ls-remote --exit-code --tags origin refs/tags/vX.Y.Z. Exit status 2 (tag missing) leads to gh 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 outputs tag and created.
  3. A tag or release created with the workflow's own token does not trigger other workflows, so publishing happens in the same run: the publish job (needs: release, if: needs.release.outputs.created == 'true') calls publish.yml with the tag and secrets: inherit. The build, test, pack and push steps and the secret they use are unchanged.
  4. Pull request CI and a manually published release behave exactly as before.

Verification

  • Both workflows parse as YAML and pass actionlint 1.7.12 with no findings.
  • The version command prints 3.1.0 for the checked-out csproj; v3.1.0 is not tagged yet, so the first merge of this change tags and publishes 3.1.0 (v3.0.2 is the latest existing tag).
  • The release step's shell logic was run locally against the real remote with a stubbed gh: a missing tag produces the expected gh release create call and created=true; an existing tag (v3.0.2) produces created=false; an unreachable remote and a csproj without VersionPrefix fail the step.
  • The push-triggered release job itself cannot run before this is merged; the pull request CI run covers build-and-test.

🤖 Generated with Claude Code

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>
@jonathan-kosgei
jonathan-kosgei merged commit 069fe22 into master Nov 3, 2026
3 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