diff --git a/Makefile b/Makefile index 6d73acb..f84761a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all build lint fmt check audit test coverage bench clean deploy blog +.PHONY: all build lint fmt check audit test coverage bench clean deploy blog release all: lint build test @@ -33,6 +33,12 @@ blog: echo " $$f → site/blog/posts/$$name.html"; \ done +release: +ifndef VERSION + $(error Usage: make release VERSION=0.8.0) +endif + ./scripts/release.sh $(VERSION) + clean: cargo clean diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..d4ee882 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ $# -ne 1 ]; then + echo "Usage: $0 (e.g. 0.7.0)" >&2 + exit 1 +fi + +VERSION="$1" +TAG="v$VERSION" + +# Sanity checks +if ! git diff --quiet || ! git diff --cached --quiet; then + echo "ERROR: working tree is dirty — commit or stash first" >&2 + exit 1 +fi + +if [ "$(git branch --show-current)" != "main" ]; then + echo "ERROR: must be on main branch" >&2 + exit 1 +fi + +if git tag -l "$TAG" | grep -q .; then + echo "ERROR: tag $TAG already exists" >&2 + exit 1 +fi + +CURRENT=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') +echo "Bumping $CURRENT -> $VERSION" + +# Bump version +sed -i.bak "s/^version = \"$CURRENT\"/version = \"$VERSION\"/" Cargo.toml +rm -f Cargo.toml.bak +cargo update --workspace + +# Commit, tag, push +git add Cargo.toml Cargo.lock +git commit -m "chore: bump version to $VERSION" +git tag "$TAG" +git push origin main --tags + +echo +echo "Released $TAG — GitHub Actions will build, publish to crates.io, and create the release."