Skip to content

Add hack to grab release notes from CHANGELOG #2

Add hack to grab release notes from CHANGELOG

Add hack to grab release notes from CHANGELOG #2

Workflow file for this run

# Source: https://crates.io/docs/trusted-publishing

Check failure on line 1 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

(Line: 24, Col: 12): Unexpected symbol: '+'. Located at position 5 within expression: '[' + github.ref_name.slice(1) + ']', (Line: 34, Col: 7): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory, (Line: 37, Col: 5): Unexpected value 'run'
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"