Skip to content

Commit 001e740

Browse files
authored
Adopt Trusted Publishing (#552)
1 parent d908618 commit 001e740

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish to crates.io
2+
on:
3+
push:
4+
tags: [
5+
'aes-v*',
6+
'aria-v*',
7+
'belt-block-v*',
8+
'blowfish-v*',
9+
'camellia-v*',
10+
'cast5-v*',
11+
'cast6-v*',
12+
'des-v*',
13+
'gift-v*',
14+
'idea-v*',
15+
'kuznyechik-v*',
16+
'magma-v*',
17+
'rc2-v*',
18+
'rc5-v*',
19+
'rc6-v*',
20+
'serpent-v*',
21+
'sm4-v*',
22+
'speck-v*',
23+
'threefish-v*',
24+
'twofish-v*',
25+
'xtea-v*',
26+
]
27+
28+
jobs:
29+
publish:
30+
runs-on: ubuntu-latest
31+
environment: publish
32+
permissions:
33+
id-token: write
34+
steps:
35+
- uses: actions/checkout@v6
36+
- uses: rust-lang/crates-io-auth-action@v1
37+
id: auth
38+
39+
- name: Extract Crate Name and Version
40+
run: |
41+
TAG_NAME="${{ github.ref_name }}"
42+
CRATE_NAME=${TAG_NAME%-v*}
43+
CRATE_VERSION=${TAG_NAME##*-v}
44+
echo $CRATE_NAME $CRATE_VERSION
45+
echo "CRATE_NAME=${CRATE_NAME}" >> $GITHUB_ENV
46+
echo "CRATE_VERSION=${CRATE_VERSION}" >> $GITHUB_ENV
47+
48+
- name: Check crate version
49+
working-directory: ${{ env.CRATE_NAME }}
50+
run: |
51+
CRATE_TOML_VERSION=$(grep "^version =" Cargo.toml | cut -d'"' -f2)
52+
echo $CRATE_TOML_VERSION
53+
[[ $CRATE_TOML_VERSION == $CRATE_VERSION ]]
54+
55+
- name: Publish
56+
working-directory: ${{ env.CRATE_NAME }}
57+
env:
58+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
59+
run: cargo publish

0 commit comments

Comments
 (0)