name: Release
"on":
push:
tags:
- 'v*.*.*'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
verify:
name: Verify Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: dtolnay/rust-toolchain@stable
- name: Install protoc (for sdforge dev-dependency)
run: sudo apt-get install -y protobuf-compiler
- name: Verify build (all features)
run: cargo build --release --all-features
- name: Verify tests pass
run: cargo test --all-features --no-fail-fast
github-release:
name: Create GitHub Release
needs: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Get version from tag
id: version
run: |
TAG_NAME="${GITHUB_REF#refs/tags/}"
VERSION="${TAG_NAME#v}"
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b with:
tag_name: ${{ steps.version.outputs.tag_name }}
name: Release ${{ steps.version.outputs.tag_name }}
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crates:
name: Publish to crates.io (conditional)
needs: github-release
runs-on: ubuntu-latest
env:
HAS_CARGO_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN != '' }}
HAS_CRATES_TOKEN: ${{ secrets.CRATES_IO_TOKEN != '' }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 if: env.HAS_CARGO_TOKEN == 'true' || env.HAS_CRATES_TOKEN == 'true'
- uses: dtolnay/rust-toolchain@stable
if: env.HAS_CARGO_TOKEN == 'true' || env.HAS_CRATES_TOKEN == 'true'
- name: Determine token
id: token
if: env.HAS_CARGO_TOKEN == 'true' || env.HAS_CRATES_TOKEN == 'true'
run: |
if [ "${{ env.HAS_CARGO_TOKEN }}" = "true" ]; then
echo "token=${{ secrets.CARGO_REGISTRY_TOKEN }}" >> $GITHUB_OUTPUT
else
echo "token=${{ secrets.CRATES_IO_TOKEN }}" >> $GITHUB_OUTPUT
fi
- name: Publish trait-kit
if: env.HAS_CARGO_TOKEN == 'true' || env.HAS_CRATES_TOKEN == 'true'
run: cargo publish --token ${{ steps.token.outputs.token }} --all-features