From c044333a35cef4811b70cdf1c1dc75adca2c6e6f Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Fri, 15 Aug 2025 14:59:54 +0100 Subject: [PATCH] add sample github action for crates.io publishing Add a github action sample workflow file for auto-publishing crates on creation of 'v*' tags. The sample workflow assumes a non-workspace setup, so that cargo publish can be run from the repository root (= crate root). For multi-crate repositories, repository_setup.sh will generate derivatives of this file. There is a useless `cd .` in the `run` step which only exists so that sed can easily replace it with the path for crates in a workspace when auto-generating workflows. Signed-off-by: Patrick Roy --- publish.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 publish.yml diff --git a/publish.yml b/publish.yml new file mode 100644 index 0000000..14d1e1b --- /dev/null +++ b/publish.yml @@ -0,0 +1,21 @@ +name: Publish to crates.io + +on: + push: + tags: ['v*'] # Triggers when pushing version tags + +jobs: + publish: + runs-on: ubuntu-latest + # environment: release # Optional: for enhanced security + permissions: + id-token: write # Required for OIDC token exchange + steps: + - uses: actions/checkout@v4 + - uses: rust-lang/crates-io-auth-action@v1 + id: auth + - run: | + cd . + cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}