at 22e2605
#!/usr/bin/env bash # # Bump, tag, build, and push a new release. # # Usage: ./scripts/release.sh <version> # # Prerequisites: # - On `main` branch, working tree clean # - Tools: rust/cargo, git-cliff, cargo-readme, prek # # What it does: # 1. Pre-flight: branch check, clean tree, user confirmation # 2. Regenerate README.md + abbaye.schema.json # 3. Bump version in Cargo.toml, commit # 4. Tag (so git-cliff can find it) # 5. Generate changelog, amend release commit # 6. Pre-commit hooks (may amend again if hooks modify files) # 7. Release build # 8. Force-push branch + tags # 9. Build abbaye website with itself # 10. Deploy docs to server set -euo pipefail VERSION="${1:-}" if [[ -z "$VERSION" ]]; then echo "Usage: $0 <version>" exit 1 fi # ── Pre-flight ───────────────────────────────────────────────────────────── BRANCH=$(git rev-parse --abbrev-ref HEAD) if [[ "$BRANCH" != "main" ]]; then echo "Error: must be on main branch (currently on $BRANCH)" exit 1 fi if ! git diff --quiet; then echo "Error: working tree has uncommitted changes" exit 1 fi read -rp "Release v${VERSION}? [y/N] " CONFIRM if [[ "$CONFIRM" != "y" && "$CONFIRM" != "Y" ]]; then echo "Aborted." exit 1 fi # ── Pre-flight regeneration ──────────────────────────────────────────────── echo "=== Regenerating README ===" cargo readme --no-indent-headings --no-title > README.md git add README.md echo "=== Regenerating schema ===" cargo run --bin abbaye dump-schema > abbaye.schema.json git add abbaye.schema.json # ── Bump version ─────────────────────────────────────────────────────────── echo "=== Bumping version to $VERSION ===" cargo set-version "$VERSION" git add Cargo.toml Cargo.lock git commit -m "chore: release v${VERSION}" # ── Tag (before changelog so git-cliff can find this version) ────────────── echo "=== Tagging v${VERSION} ===" git tag "v${VERSION}" # ── Changelog (amend into release commit) ────────────────────────────────── echo "=== Generating changelog ===" git cliff -o CHANGELOG.md git add CHANGELOG.md # Skip hooks: the changelog-check hook would fail because it runs against the # staged changelog while the tag now points at HEAD~1, making git-cliff think # this version is already released. We run hooks explicitly next. git commit --amend --no-edit -n # ── Pre-commit hooks ─────────────────────────────────────────────────────── echo "=== Running pre-commit hooks ===" prek run --all-files # If hooks modified anything (trailing whitespace, EOF fixes, fmt), fold them # into the release commit. if ! git diff --quiet; then git add -A git commit --amend --no-edit -n fi # ── Build ────────────────────────────────────────────────────────────────── echo "=== Building release binary ===" cargo build --release # ── Push (move tag to the final amended commit) ──────────────────────────── echo "=== Pushing ===" git tag --force "v${VERSION}" git push --force # ── Post-release ─────────────────────────────────────────────────────────── echo "=== Building abbaye website ===" cargo run --release --bin abbaye -- build echo "=== Deploying docs ===" rsync --progress -avz --links --perms --update public/ ololduck@vit.am:public_html/abbaye/