Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Source: https://crates.io/docs/trusted-publishing
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) + ']' }}]"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assumption: we can evaluate JavaScript here. GH docs seem to imply this.

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"