From af84c11ff4f060bfa95cd0cdd0273a948d0ece1a Mon Sep 17 00:00:00 2001 From: Patrick Dewey
Date: Wed, 1 Apr 2026 09:49:52 -0400 Subject: [PATCH] feat: version tagging script and bump shutter version in TUI --- cmd/shutter/go.mod | 2 +- justfile | 8 +++++ scripts/version.sh | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100755 scripts/version.sh diff --git a/cmd/shutter/go.mod b/cmd/shutter/go.mod index df07480..14f84eb 100644 --- a/cmd/shutter/go.mod +++ b/cmd/shutter/go.mod @@ -6,7 +6,7 @@ require ( github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.10 github.com/charmbracelet/lipgloss v1.1.0 - github.com/ptdewey/shutter v0.1.4 + github.com/ptdewey/shutter v0.2.0 ) require ( diff --git a/justfile b/justfile index cf5a344..fbb4a71 100644 --- a/justfile +++ b/justfile @@ -19,3 +19,11 @@ cli: clean: @rm -rf ./__snapshots__ + +# Determine next version from conventional commits and tag both modules +release: + @./scripts/version.sh + +# Preview version bump without creating tags +release-dry: + @./scripts/version.sh --dry-run diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..880214a --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Determine next semver based on conventional commits since main. +# Usage: ./scripts/version.sh [--dry-run] + +DRY_RUN=false +if [[ "${1:-}" == "--dry-run" ]]; then + DRY_RUN=true +fi + +# Get the latest root module tag (ignore cmd/shutter/ prefixed tags) +LATEST_TAG=$(jj tag list | grep -E '^v[0-9]' | sort -V -t: -k1,1 | tail -1 | awk '{print $1}' | tr -d ':') + +if [[ -z "$LATEST_TAG" ]]; then + echo "error: no existing version tags found" + exit 1 +fi + +echo "Current version: $LATEST_TAG" + +# Parse current version +VERSION="${LATEST_TAG#v}" +IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" + +# Get commit messages since main +COMMITS=$(jj log -r 'main..@' --no-graph -T 'description ++ "---\n"' 2>/dev/null) + +if [[ -z "$COMMITS" || "$COMMITS" == $'---\n' ]]; then + echo "No commits since main." + exit 0 +fi + +echo "" +echo "Commits since main:" +echo "$COMMITS" | grep -v '^---$' | grep -v '^$' | sed 's/^/ /' +echo "" + +# Determine bump type from conventional commits +BUMP="patch" + +while IFS= read -r line; do + # Skip empty lines and delimiters + [[ -z "$line" || "$line" == "---" ]] && continue + + # Check for breaking changes + if echo "$line" | grep -qiE '^[a-z]+(\(.+\))?!:|BREAKING CHANGE'; then + BUMP="major" + break + fi + + # Check for feat -> minor + if echo "$line" | grep -qE '^feat(\(.+\))?:'; then + BUMP="minor" + fi +done <<< "$COMMITS" + +# Calculate new version +case "$BUMP" in + major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; + minor) MINOR=$((MINOR + 1)); PATCH=0 ;; + patch) PATCH=$((PATCH + 1)) ;; +esac + +NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" + +echo "Bump type: $BUMP" +echo "New version: $NEW_VERSION" +echo "Tags: $NEW_VERSION, cmd/shutter/$NEW_VERSION" + +if $DRY_RUN; then + echo "" + echo "(dry run — no tags created)" + exit 0 +fi + +echo "" +read -p "Create tags and push? [y/N] " -n 1 -r +echo "" + +if [[ $REPLY =~ ^[Yy]$ ]]; then + jj tag set "$NEW_VERSION" "cmd/shutter/$NEW_VERSION" + jj git push --tags + echo "Done. Tagged and pushed $NEW_VERSION" +else + echo "Aborted." +fi -- 2.51.2