Skip to content

Commit 985408c

Browse files
committed
ci: publish rust crates using OIDC
1 parent 03de883 commit 985408c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

.github/workflows/rust.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Rust - Build and test
1+
name: Rust - Build, test and publish
22
on:
33
push:
44
branches: [ "master" ]
5+
tags: ['v*'] # Triggers when pushing tags starting with 'v'
56
pull_request:
67
branches: [ "master" ]
78

@@ -53,3 +54,17 @@ jobs:
5354
name: ${{ matrix.asset_name }}
5455
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
5556
if-no-files-found: error
57+
publish:
58+
runs-on: ubuntu-latest
59+
if: startsWith(github.ref, 'refs/tags/v')
60+
needs: build
61+
environment: release # Optional: for enhanced security
62+
permissions:
63+
id-token: write # Required for OIDC token exchange
64+
steps:
65+
- uses: actions/checkout@v5
66+
- uses: rust-lang/crates-io-auth-action@v1
67+
id: auth
68+
- run: cargo publish
69+
env:
70+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

0 commit comments

Comments
 (0)