Skip to content

Commit 284e7a7

Browse files
committed
Migrate GitHub Actions publishing flow to Trusted Publishing
https://crates.io/docs/trusted-publishing
1 parent 6e64476 commit 284e7a7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

.github/workflows/publish.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ jobs:
99
Publish:
1010
if: github.repository_owner == 'Traverse-Research'
1111
runs-on: ubuntu-latest
12+
# https://crates.io/docs/trusted-publishing
13+
environment: release # Optional: for enhanced security
14+
permissions:
15+
id-token: write # Required for OIDC token exchange
1216
steps:
1317
- uses: actions/checkout@v4
18+
- uses: rust-lang/crates-io-auth-action@v1
19+
id: auth
1420
- name: Publish
15-
run: cargo publish --token ${{ secrets.cratesio_token }}
21+
env:
22+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
23+
run: cargo publish

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,15 @@ rust-template = "0.0.0"
2424
```rust
2525
// A code example
2626
```
27+
28+
## Template usage
29+
30+
> [!WARNING]
31+
> Delete this section after inheriting from the template. It only explains how to utilize and configure this template effectively.
32+
33+
### Publishing strategy
34+
35+
The [publish workflow] relies on crates.io's [Trusted Publishing] to publish releases from GitHub Actions as soon as a tag is pushed. To set this up, ensure your repository has a `release` environment. After publishing an initial crate version to crates.io, add the repository as a Trusted Publisher using the `publish.yaml` filename and `release` environment for your GitHub repository.
36+
37+
[publish workflow]: ./.github/workflows/publish.yaml
38+
[Trusted Publishing]: https://crates.io/docs/trusted-publishing

0 commit comments

Comments
 (0)