From 6f863a19547ad63c047dd1428641d9c488576020 Mon Sep 17 00:00:00 2001 From: Stuart Meeks Date: Wed, 27 May 2026 04:55:56 +0000 Subject: [PATCH] Auto-create a GitHub release on version tags Add a tag-gated `release` job (needs: publish, contents: write) that extracts the matching section from CHANGELOG.md for the pushed v* tag and creates a GitHub release with it via the gh CLI. Falls back to a minimal note if the section isn't found. Future releases: push a v* tag and the pipeline publishes to NuGet and creates the GitHub release automatically. (v0.1.0's release was created manually, before this existed.) Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 314340b..e9ea74c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,3 +67,35 @@ jobs: - name: Publish to NuGet run: dotnet nuget push "./artifacts/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + + release: + needs: publish + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v6 + + # Pull the section for this tag's version out of CHANGELOG.md + # (e.g. tag v0.1.0 -> the "## [0.1.0] — …" block) for the release body. + # Falls back to a minimal note if the section isn't found. + - name: Build release notes + run: | + version="${GITHUB_REF_NAME#v}" + awk -v ver="$version" ' + $0 ~ "^## \\[" ver "\\]" { capture = 1; next } + capture && /^## \[/ { exit } + capture && /^\[.*\]: / { exit } + capture { print } + ' CHANGELOG.md > release-notes.md + if [ ! -s release-notes.md ]; then + echo "Release $GITHUB_REF_NAME" > release-notes.md + fi + + - name: Create GitHub release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file release-notes.md --verify-tag