From a3843bb6ae87715760dca730ca5bb1efa323fb99 Mon Sep 17 00:00:00 2001 From: test-user Date: Wed, 1 Apr 2026 11:48:49 -0700 Subject: [PATCH] chore: add release.sh and update maintain.sh Co-Authored-By: Claude Opus 4.6 (1M context) --- maintain.sh | 5 +--- release.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100755 release.sh diff --git a/maintain.sh b/maintain.sh index 03d888d..36b5506 100755 --- a/maintain.sh +++ b/maintain.sh @@ -2,13 +2,10 @@ set -euo pipefail -# Ensure git hooks are active -git config core.hooksPath .githooks - uv sync --all-extras uv run uv-outdated uv run uv-secure --ignore-unfixed uv run ruff check --fix uv run ruff format -uv run pytest uv run pyright +uv run pytest -n auto diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..4b43595 --- /dev/null +++ b/release.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +set -euo pipefail + +VERSION="${1:-}" + +if [[ -z "$VERSION" ]]; then + echo "Usage: ./release.sh " + echo "Example: ./release.sh 0.4.0" + exit 1 +fi + +if ! [[ "$VERSION" =~ ^[1-9][0-9]*\.[0-9]+\.[0-9]+$|^0\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: version must be in X.Y.Z format (e.g. 0.4.0)" + exit 1 +fi + +TAG="v$VERSION" + +BRANCH="$(git rev-parse --abbrev-ref HEAD)" +if [[ "$BRANCH" != "main" ]]; then + echo "Error: releases must be made from the main branch (currently on $BRANCH)" + exit 1 +fi + +if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "Error: tag $TAG already exists" + exit 1 +fi + +if [[ -n "$(git status --porcelain)" ]]; then + echo "Error: working tree is not clean. Commit or stash changes first." + exit 1 +fi + +echo "=== Releasing $TAG ===" + +echo "→ Running checks..." +uv run ruff check +uv run ruff format --check +uv run pytest +uv run pyright + +echo "→ Updating version to $VERSION..." +# Portable sed -i: works on both macOS (BSD) and Linux (GNU) +if sed --version >/dev/null 2>&1; then + # GNU sed + sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml + sed -i "s/^__version__ = \".*\"/__version__ = \"$VERSION\"/" src/remove_ai_watermarks/__init__.py +else + # BSD sed (macOS) + sed -i '' "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml + sed -i '' "s/^__version__ = \".*\"/__version__ = \"$VERSION\"/" src/remove_ai_watermarks/__init__.py +fi + +echo "→ Committing..." +git add pyproject.toml src/remove_ai_watermarks/__init__.py +git commit -m "chore: bump version to $VERSION" + +echo "→ Tagging $TAG..." +git tag "$TAG" + +echo "→ Pushing..." +git push origin main +git push origin "$TAG" + +echo "=== Released $TAG ==="