Skip to content

Commit fdc1188

Browse files
authored
Adopt Trusted Publishing (#2277)
See RustCrypto/meta#27
1 parent 6851f68 commit fdc1188

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish to crates.io
2+
on:
3+
push:
4+
tags: [
5+
'aead-v*',
6+
'async-signature-v*',
7+
'cipher-v*',
8+
'crypto-common-v*',
9+
'crypto-v*',
10+
'digest-v*',
11+
'elliptic-curve-v*',
12+
'kdf-v*',
13+
'kem-v*',
14+
'password-hash-v*',
15+
'signature-v*',
16+
'universal-hash-v*',
17+
]
18+
19+
jobs:
20+
publish:
21+
runs-on: ubuntu-latest
22+
environment: publish
23+
permissions:
24+
id-token: write
25+
steps:
26+
- uses: actions/checkout@v6
27+
- uses: rust-lang/crates-io-auth-action@v1
28+
id: auth
29+
30+
- name: Extract Crate Name and Version
31+
run: |
32+
TAG_NAME="${{ github.ref_name }}"
33+
CRATE_NAME=${TAG_NAME%-v*}
34+
CRATE_VERSION=${TAG_NAME##*-v}
35+
echo $CRATE_NAME $CRATE_VERSION
36+
echo "CRATE_NAME=${CRATE_NAME}" >> $GITHUB_ENV
37+
echo "CRATE_VERSION=${CRATE_VERSION}" >> $GITHUB_ENV
38+
39+
- name: Check crate version
40+
working-directory: ${{ env.CRATE_NAME }}
41+
run: |
42+
CRATE_TOML_VERSION=$(grep "^version =" Cargo.toml | cut -d'"' -f2)
43+
echo $CRATE_TOML_VERSION
44+
[[ $CRATE_TOML_VERSION == $CRATE_VERSION ]]
45+
46+
- name: Publish
47+
working-directory: ${{ env.CRATE_NAME }}
48+
env:
49+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
50+
run: cargo publish

0 commit comments

Comments
 (0)