Add hack to grab release notes from CHANGELOG #2
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
# Source: https://crates.io/docs/trusted-publishing | ||
Check failure on line 1 in .github/workflows/release.yml
|
||
name: Publish to crates.io | ||
on: | ||
push: | ||
tags: ['v*'] | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
environment: release # Optional: for enhanced security | ||
permissions: | ||
id-token: write # Required for OIDC token exchange | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- uses: rust-lang/crates-io-auth-action@v1 | ||
id: auth | ||
- run: cargo publish | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | ||
# Source: https://medium.com/@usman_qb | ||
- name: Create release body | ||
id: create_release_body | ||
run: | | ||
RELEASEVERSION="[${{ '[' + github.ref_name.slice(1) + ']' }}]" | ||
echo "Version: $RELEASEVERSION" | ||
RELEASEBODY=$(awk -v ver="$RELEASEVERSION" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next } } p && NF' CHANGELOG.md) | ||
{ | ||
echo 'RELEASEBODY<<EOF' | ||
echo "${RELEASEBODY}" | ||
echo EOF | ||
} >> $GITHUB_OUTPUT | ||
- name: Create Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "Creating release for ${{ github.ref_name }}" | ||
echo "${{ steps.create_release_body.outputs.RELEASEBODY }}" | ||
gh release create "${{ github.ref_name }}" --title "release_${{ github.ref_name }}" --notes "${{ steps.create_release_body.outputs.RELEASEBODY }}" | ||
echo "Release created successfully" |