Skip to content

Commit

Permalink
Add support for Github Rust Release
Browse files Browse the repository at this point in the history
  • Loading branch information
electronjoe committed Nov 3, 2024
1 parent 50644b8 commit 5430e22
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

on:
push:
tags:
- v[0-9]+.* # Matches v1.0.0, v0.1.0, etc

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 pkgid | cut -d# -f2)
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 }}

0 comments on commit 5430e22

Please sign in to comment.