Fix release workflow #2
Workflow file for this run
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: Release | |
on: | |
push: | |
tags: | |
- v[0-9]+.* | |
jobs: | |
create-release: | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get version from tag | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
body: | | |
See [CHANGELOG.md](CHANGELOG.md) for details. | |
publish-crate: | |
name: Publish to crates.io | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Check package version matches tag | |
run: | | |
CARGO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version') | |
TAG_VERSION="${GITHUB_REF#refs/tags/v}" | |
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then | |
echo "Package version ($CARGO_VERSION) does not match tag version ($TAG_VERSION)" | |
exit 1 | |
fi | |
- name: Publish to crates.io | |
run: cargo publish --token ${CRATES_TOKEN} | |
env: | |
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} |