ci: also create GitHub Release on tag push (#33) #72
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
| name: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| ci: | |
| uses: runcycles/.github/.github/workflows/ci-rust.yml@main | |
| with: | |
| rust-versions: '["stable", "1.88"]' | |
| cargo-args: '--all-features' | |
| publish: | |
| name: Publish to crates.io | |
| needs: ci | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: crates-publish | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write # required to create the GitHub Release | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable @ 2026-05-02 | |
| - name: Publish to crates.io | |
| run: cargo publish | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
| - name: Extract changelog notes | |
| id: changelog | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| # Extract the section between "## [VERSION]" and the next "## [". | |
| # Strip leading blank line and trailing whitespace. | |
| awk -v ver="$VERSION" ' | |
| $0 ~ "^## \\[" ver "\\]" { found=1; next } | |
| found && /^## \[/ { exit } | |
| found { print } | |
| ' CHANGELOG.md | awk 'NF || found { found=1; print }' > /tmp/release-notes.md | |
| if [ ! -s /tmp/release-notes.md ]; then | |
| echo "::warning::No CHANGELOG entry found for $VERSION; release will use a placeholder body." | |
| echo "Release of v$VERSION. See CHANGELOG.md for details." > /tmp/release-notes.md | |
| fi | |
| echo "----- Release notes for v$VERSION -----" | |
| cat /tmp/release-notes.md | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| gh release create "v$VERSION" \ | |
| --title "v$VERSION" \ | |
| --notes-file /tmp/release-notes.md |