diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..1ac4433f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Publish to crates.io +on: + push: + tags: [ 'v*' ] + +jobs: + publish: + runs-on: ubuntu-latest + environment: publish + permissions: + id-token: write + steps: + - uses: actions/checkout@v6 + - uses: rust-lang/crates-io-auth-action@v1 + id: auth + + - name: Check crate version + run: | + CRATE_VERSION=v$(grep -m 1 "^version =" Cargo.toml | cut -d'"' -f2) + echo $CRATE_VERSION ${{ github.ref_name }} + [[ $CRATE_VERSION == ${{ github.ref_name }} ]] + + - name: Publish + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + run: cargo publish