Skip to content

Commit 085a94f

Browse files
authored
Adopt Trusted Publishin (#506)
1 parent 555ad15 commit 085a94f

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.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+
"ssh-cipher/v**",
6+
"ssh-derive/v**",
7+
"ssh-encoding/v**",
8+
"ssh-key/v**",
9+
"ssh-protocol/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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
- uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
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 -m 1 "^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)