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