name: release
on:
push:
tags:
- 'v*.*.*'
permissions:
id-token: write
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: clone am-fs-core sibling
shell: bash
run: git clone --depth 1 https://github.com/antimatter-studios/rust-fs-core.git ../rust-fs-core
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.94.1
components: clippy
- uses: Swatinem/rust-cache@v2
- name: verify tag matches Cargo.toml version
run: |
tag="${GITHUB_REF_NAME#v}"
crate_ver=$(grep -m1 '^version' Cargo.toml | sed -E 's/version *= *"(.*)"/\1/')
if [ "$tag" != "$crate_ver" ]; then
echo "tag $tag does not match Cargo.toml version $crate_ver" >&2
exit 1
fi
- run: cargo test --all-targets
- run: cargo clippy --all-targets -- -D warnings
publish:
name: publish to crates.io
needs: test
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.94.1
- uses: rust-lang/crates-io-auth-action@v1.0.4
id: auth
- name: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish