Skip to content

fix: ensure automated release (#27) #2

fix: ensure automated release (#27)

fix: ensure automated release (#27) #2

Workflow file for this run

name: Release and Publish
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (without v prefix)'
required: true
type: string
env:
CARGO_TERM_COLOR: always
jobs:
test:
uses: ./.github/workflows/ci.yml

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

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

error parsing called workflow ".github/workflows/release.yml" -> "./.github/workflows/ci.yml" (source tag with sha:23afe6760943fde92074d9d2ae9d29f31aa8b37a) : workflow is not reusable as it is missing a `on.workflow_call` trigger
validate:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Extract version
id: version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=${GITHUB_REF#refs/tags/v}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Verify version matches Cargo.toml
run: |
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
if [[ "$CARGO_VERSION" != "${{ steps.version.outputs.version }}" ]]; then
echo "Version mismatch: Cargo.toml has $CARGO_VERSION, but release is ${{ steps.version.outputs.version }}"
exit 1
fi
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: [test, validate]
environment: release
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-publish-${{ hashFiles('**/Cargo.lock') }}
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
run: cargo publish