A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory
at test-validate 72 lines 1.5 kB view raw
1#!/bin/bash 2 3set -e 4 5# Colors 6RED='\033[0;31m' 7GREEN='\033[0;32m' 8YELLOW='\033[1;33m' 9NC='\033[0m' # No Color 10 11# Check if git is clean 12if [[ -n $(git status -s) ]]; then 13 echo -e "${RED}Error: Git working directory is not clean${NC}" 14 echo "Please commit or stash your changes first" 15 exit 1 16fi 17 18# Get current version from git tags 19CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") 20 21# Remove 'v' prefix if present 22CURRENT_VERSION=${CURRENT_VERSION#v} 23 24# Parse version 25IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" 26MAJOR="${VERSION_PARTS[0]}" 27MINOR="${VERSION_PARTS[1]}" 28PATCH="${VERSION_PARTS[2]}" 29 30# Bump version based on argument 31case "$1" in 32 major) 33 MAJOR=$((MAJOR + 1)) 34 MINOR=0 35 PATCH=0 36 ;; 37 minor) 38 MINOR=$((MINOR + 1)) 39 PATCH=0 40 ;; 41 patch) 42 PATCH=$((PATCH + 1)) 43 ;; 44 *) 45 echo "Usage: $0 {major|minor|patch}" 46 exit 1 47 ;; 48esac 49 50NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" 51 52echo -e "${YELLOW}Current version: ${CURRENT_VERSION}${NC}" 53echo -e "${GREEN}New version: ${NEW_VERSION}${NC}" 54echo "" 55 56# Confirm 57read -p "Create tag ${NEW_VERSION}? (y/N) " -n 1 -r 58echo 59if [[ ! $REPLY =~ ^[Yy]$ ]]; then 60 echo "Cancelled" 61 exit 0 62fi 63 64# Create git tag 65git tag -a "${NEW_VERSION}" -m "Release ${NEW_VERSION}" 66 67echo -e "${GREEN}✓ Created tag ${NEW_VERSION}${NC}" 68echo "" 69echo "To push the tag, run:" 70echo " git push origin ${NEW_VERSION}" 71echo "" 72echo "Or use 'make release' to push automatically"