Skip to content

Merge pull request #18 from jcwang587/dev #1

Merge pull request #18 from jcwang587/dev

Merge pull request #18 from jcwang587/dev #1

Workflow file for this run

name: publish rust
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
publishToCrates:
description: "Publish to crates.io?"
required: true
default: "no"
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
if: github.event_name == 'push' || inputs.publishToCrates == 'yes'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Validate tag matches Cargo.toml version
if: github.event_name == 'push'
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
CARGO_VERSION="$(grep -m1 '^version = ' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')"
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
- name: Publish crate to crates.io
run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}