name: Release
on:
push:
tags:
- "v*"
permissions: {}
jobs:
publish:
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 with:
toolchain: stable
- name: Verify tag matches workspace version
run: |
set -euo pipefail
version="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "bitflagset") | .version')"
if [[ "${GITHUB_REF_NAME}" != "v${version}" ]]; then
echo "::error::tag ${GITHUB_REF_NAME} does not match bitflagset ${version}"
exit 1
fi
- name: Dry-run publish
run: cargo publish --workspace --dry-run
- name: Authenticate to crates.io
id: auth
uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18
- name: Publish workspace
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish --workspace