Skip to content

Bump version to 0.1.1 and add crates.io install instructions #2

Bump version to 0.1.1 and add crates.io install instructions

Bump version to 0.1.1 and add crates.io install instructions #2

Workflow file for this run

name: Publish to crates.io
on:
push:
branches: [main]
paths:
- 'Cargo.toml'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Detect version bump
id: version
run: |
current=$(grep -m1 '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
previous=$(git show HEAD~1:Cargo.toml 2>/dev/null | grep -m1 '^version = ' | sed -E 's/version = "(.*)"/\1/' || echo "")
echo "current=$current"
echo "previous=$previous"
echo "current=$current" >> "$GITHUB_OUTPUT"
if [ -n "$current" ] && [ "$current" != "$previous" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Install Rust toolchain
if: steps.version.outputs.changed == 'true'
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
if: steps.version.outputs.changed == 'true'
uses: Swatinem/rust-cache@v2
- name: Publish to crates.io
if: steps.version.outputs.changed == 'true'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked
- name: Tag release
if: steps.version.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="v${{ steps.version.outputs.current }}"
git tag "$tag"
git push origin "$tag"