name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
DEEPINFRA_API_KEY: ${{ secrets.DEEPINFRA_API_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup build environment
uses: ./.github/actions/setup-env
env:
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: "Bearer ${{ secrets.CARGO_REGISTRY_TOKEN }}"
DEEPINFRA_API_KEY: ${{ secrets.DEEPINFRA_API_KEY }}
- name: Verify tag matches Cargo.toml version
run: |
python3 - <<'PY'
import os
import tomllib
tag = os.environ["GITHUB_REF_NAME"]
with open("Cargo.toml", "rb") as f:
data = tomllib.load(f)
version = data["package"]["version"]
expected = f"v{version}"
if tag != expected:
raise SystemExit(f"tag {tag} does not match Cargo.toml version {expected}")
PY
- name: Publish to crates.io
run: cargo publish --locked --features local