Skip to content

ci: switch release flow to tag-triggered and add PR title checks (#95) #1

ci: switch release flow to tag-triggered and add PR title checks (#95)

ci: switch release flow to tag-triggered and add PR title checks (#95) #1

Workflow file for this run

name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v0.1.0) — must already exist"
required: true
permissions:
contents: write
jobs:
build-and-release:
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
- name: Resolve tag and version
id: version
run: |
tag="${{ inputs.tag || github.ref_name }}"
version="${tag#v}"
cargo_version=$(awk -F'"' '/^version *=/ {print $2; exit}' Cargo.toml)
if [ "$version" != "$cargo_version" ]; then
echo "Tag $tag does not match Cargo.toml version $cargo_version" >&2
exit 1
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Verify tag points at a commit on main
run: |
git fetch origin main
if ! git merge-base --is-ancestor HEAD origin/main; then
echo "Tagged commit $(git rev-parse HEAD) is not on main" >&2
exit 1
fi
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build release binaries
run: cargo build --release --workspace
- name: Run tests
run: cargo test --release --workspace
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.version.outputs.tag }}
run: |
gh release create "$TAG" \
--title "$TAG" \
--target "${{ github.sha }}" \
--generate-notes