Skip to content

Commit af892a8

Browse files
authored
Add initial Trusted Publishing config (#301)
1 parent 2d58e61 commit af892a8

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/publish.yml

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

0 commit comments

Comments
 (0)