Publish to crates.io #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # See https://crates.io/docs/trusted-publishing | |
| name: Publish to crates.io | |
| on: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: {} | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| id-token: write # Required for OIDC token exchange | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: rust-lang/crates-io-auth-action@v1 | |
| id: auth | |
| - run: | | |
| # Publish crates if their current version is not already on crates.io. | |
| # Order matters: dependencies must be published first. | |
| CRATES="bootc-internal-utils bootc-internal-mount bootc-internal-blockdev" | |
| for crate in $CRATES; do | |
| VERSION=$(cargo read-manifest -p "$crate" | jq -r '.version') | |
| if cargo info "$crate@$VERSION" > /dev/null 2>&1; then | |
| echo "$crate@$VERSION is already published, skipping" | |
| else | |
| echo "Publishing $crate@$VERSION..." | |
| cargo publish -p "$crate" | |
| echo "Successfully published $crate@$VERSION" | |
| fi | |
| done | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |