diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 76616c7..1f5090f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,27 +16,24 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - name: Parse version from tag + - name: Check version matches tag run: | TAG="${{ github.event.release.tag_name }}" VERSION="${TAG#v}" - echo "TAG_VERSION=$VERSION" >> $GITHUB_ENV - - - name: Check version matches Cargo.toml - run: | CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') - if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then - echo "Tag v$TAG_VERSION does not match Cargo.toml version $CARGO_VERSION" + if [ "$VERSION" != "$CARGO_VERSION" ]; then + echo "Tag v$VERSION does not match Cargo.toml version $CARGO_VERSION" exit 1 fi - name: Run tests run: cargo test - - name: Dry run publish - run: cargo publish --dry-run + - name: Authenticate with crates.io + id: auth + uses: rust-lang/crates-io-auth-action@v1 - name: Publish to crates.io run: cargo publish env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}