#!/usr/bin/env bash set -euo pipefail VERSION_FILE="VERSION" if [ ! -f "$VERSION_FILE" ]; then echo "Error: $VERSION_FILE not found" >&2 exit 1 fi current=$(cat "$VERSION_FILE") echo "Current version: $current" IFS='.' read -r major minor patch <<< "$current" if [ "${1:-}" = "--increment" ]; then patch=$((patch + 1)) new_version="${major}.${minor}.${patch}" echo "Auto-incrementing to: $new_version" else echo "Increment version? [y/N]" read -r answer if [[ "$answer" =~ ^[Yy] ]]; then echo " 1) patch (${major}.${minor}.$((patch + 1)))" echo " 2) minor (${major}.$((minor + 1)).0)" echo " 3) major ($((major + 1)).0.0)" echo -n "Choice [1]: " read -r choice case "${choice:-1}" in 1) patch=$((patch + 1)); new_version="${major}.${minor}.${patch}" ;; 2) minor=$((minor + 1)); patch=0; new_version="${major}.${minor}.${patch}" ;; 3) major=$((major + 1)); minor=0; patch=0; new_version="${major}.${minor}.${patch}" ;; *) echo "Invalid choice" >&2; exit 1 ;; esac echo "New version: $new_version" else new_version="$current" echo "Keeping version: $new_version" fi fi echo "$new_version" > "$VERSION_FILE" echo "Building arrman v${new_version}..." go build -ldflags "-X main.Version=${new_version}" -o arrman . echo "Done: ./arrman v${new_version}"