Add Trusted Publishing Config (#102)

This commit is contained in:
Tony Arcieri 2026-02-12 19:20:35 -07:00 committed by GitHub
parent 0d9bf82ee5
commit 239ff349af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

41
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: Publish to crates.io
on:
push:
tags: [
'ascon-v*',
'bash-f-v*',
'keccak-v*',
]
jobs:
publish:
runs-on: ubuntu-latest
environment: publish
permissions:
id-token: write
steps:
- uses: actions/checkout@v6
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Extract Crate Name and Version
run: |
TAG_NAME="${{ github.ref_name }}"
CRATE_NAME=${TAG_NAME%-v*}
CRATE_VERSION=${TAG_NAME##*-v}
echo $CRATE_NAME $CRATE_VERSION
echo "CRATE_NAME=${CRATE_NAME}" >> $GITHUB_ENV
echo "CRATE_VERSION=${CRATE_VERSION}" >> $GITHUB_ENV
- name: Check crate version
working-directory: ${{ env.CRATE_NAME }}
run: |
CRATE_TOML_VERSION=$(grep "^version =" Cargo.toml | cut -d'"' -f2)
echo $CRATE_TOML_VERSION
[[ $CRATE_TOML_VERSION == $CRATE_VERSION ]]
- name: Publish
working-directory: ${{ env.CRATE_NAME }}
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish