diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b65243..4e3dd00 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,3 +56,41 @@ jobs: # workflow's OIDC identity instead. PyPI must have the # corresponding "trusted publisher" configured pointing at # this repo + workflow file + environment. + + github-release: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write # required to create the GitHub Release + steps: + - uses: actions/checkout@v4 + + - name: Extract this version's CHANGELOG section + run: | + version="${GITHUB_REF_NAME#v}" + # Pull the body between this version's "## [x.y.z]" header and + # the next "## [" header. Empty file is fine — gh falls back to + # an autogenerated body via --generate-notes. + awk -v v="$version" ' + $0 ~ "^## \\[" v "\\]" { grab=1; next } + grab && /^## \[/ { exit } + grab { print } + ' CHANGELOG.md > release-notes.md + echo "---- release-notes.md ----" + cat release-notes.md + + - name: Create GitHub Release + env: + GH_TOKEN: ${{ github.token }} + run: | + if [ -s release-notes.md ]; then + gh release create "$GITHUB_REF_NAME" \ + --title "$GITHUB_REF_NAME" \ + --notes-file release-notes.md \ + --verify-tag + else + gh release create "$GITHUB_REF_NAME" \ + --title "$GITHUB_REF_NAME" \ + --generate-notes \ + --verify-tag + fi