From db5c828b5f384eed2294570281bfa6709df03b77 Mon Sep 17 00:00:00 2001 From: Phillip Tarrant Date: Thu, 20 Nov 2025 12:34:15 -0600 Subject: [PATCH] adding release script --- scripts/release.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 scripts/release.sh diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..f5e359d --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# SneakyScan Release Script +# Handles version bumping, branch merging, tagging, and pushing + +set -e + +CONFIG_FILE="app/web/config.py" +DEVELOP_BRANCH="develop" +STAGING_BRANCH="staging" +MAIN_BRANCH="master" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +echo -e "${GREEN}=== SneakyScan Release Script ===${NC}\n" + +# Ensure we're in the repo root +if [ ! -f "$CONFIG_FILE" ]; then + echo -e "${RED}Error: Must run from repository root${NC}" + exit 1 +fi + +# Check for uncommitted changes +if [ -n "$(git status --porcelain)" ]; then + echo -e "${RED}Error: You have uncommitted changes. Please commit or stash them first.${NC}" + exit 1 +fi + +# Prompt for version +read -p "Enter version (e.g., 1.0.0): " VERSION + +# Validate version format (semver) +if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then + echo -e "${RED}Error: Invalid version format. Use semver (e.g., 1.0.0 or 1.0.0-beta)${NC}" + exit 1 +fi + +TAG_NAME="v$VERSION" + +# Check if tag already exists +if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then + echo -e "${RED}Error: Tag $TAG_NAME already exists${NC}" + exit 1 +fi + +echo -e "\n${YELLOW}Release version: $VERSION${NC}" +echo -e "${YELLOW}Tag name: $TAG_NAME${NC}\n" + +read -p "Proceed with release? (y/n): " CONFIRM +if [ "$CONFIRM" != "y" ]; then + echo "Release cancelled." + exit 0 +fi + +# Fetch latest from remote +echo -e "\n${GREEN}Fetching latest from remote...${NC}" +git fetch origin + +# Update version in config.py +echo -e "\n${GREEN}Updating version in $CONFIG_FILE...${NC}" +sed -i "s/APP_VERSION = .*/APP_VERSION = '$VERSION'/" "$CONFIG_FILE" + +# Checkout develop and commit version change +echo -e "\n${GREEN}Committing version change on $DEVELOP_BRANCH...${NC}" +git checkout "$DEVELOP_BRANCH" +git add "$CONFIG_FILE" +git commit -m "Bump version to $VERSION" + +# Merge develop into staging +echo -e "\n${GREEN}Merging $DEVELOP_BRANCH into $STAGING_BRANCH...${NC}" +git checkout "$STAGING_BRANCH" +git merge "$DEVELOP_BRANCH" -m "Merge $DEVELOP_BRANCH into $STAGING_BRANCH for release $VERSION" + +# Merge staging into main +echo -e "\n${GREEN}Merging $STAGING_BRANCH into $MAIN_BRANCH...${NC}" +git checkout "$MAIN_BRANCH" +git merge "$STAGING_BRANCH" -m "Merge $STAGING_BRANCH into $MAIN_BRANCH for release $VERSION" + +# Create tag +echo -e "\n${GREEN}Creating tag $TAG_NAME...${NC}" +git tag -a "$TAG_NAME" -m "Release $VERSION" + +# Push everything +echo -e "\n${GREEN}Pushing branches and tag to remote...${NC}" +git push origin "$DEVELOP_BRANCH" +git push origin "$STAGING_BRANCH" +git push origin "$MAIN_BRANCH" +git push origin "$TAG_NAME" + +# Return to develop branch +git checkout "$DEVELOP_BRANCH" + +echo -e "\n${GREEN}=== Release $VERSION complete! ===${NC}" +echo -e "Tag: $TAG_NAME" +echo -e "All branches and tags have been pushed to origin."