Skip to content

Commit 8519db2

Browse files
authored
Add Trusted Publishing config (#532)
1 parent 9a628ac commit 8519db2

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/publish.yml

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

0 commit comments

Comments
 (0)