#!/bin/bash # TomTomGames Build & Deploy Script # Usage: ./build.sh "Commit message describing changes" # # Prerequisites (one-time setup): # git init # git remote add origin https://github.com/tomtomgames/tomtomgames-app.git # git config user.email "myronblair@outlook.com" # git config user.name "TomTomGames" # # For GitHub auth, create a PAT at: # https://github.com/settings/tokens → New classic token → repo scope # Then: git remote set-url origin https://YOUR_TOKEN@github.com/tomtomgames/tomtomgames-app.git set -e MSG="${1:-Auto build $(date '+%Y-%m-%d %H:%M')}" # ── Determine next version ──────────────────────────────── CURRENT=$(cat VERSION 2>/dev/null || echo "1.0.1") IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" PATCH=$((PATCH + 1)) NEW_VERSION="$MAJOR.$MINOR.$PATCH" echo "──────────────────────────────────────" echo " Building TomTomGames v$NEW_VERSION" echo " Message: $MSG" echo "──────────────────────────────────────" # ── Write version file ──────────────────────────────────── echo "$NEW_VERSION" > VERSION echo "✓ VERSION → $NEW_VERSION" # ── Update version in PHP config ───────────────────────── # (The DB is the source of truth — bump_version.php handles it on the server) # ── Build zip ───────────────────────────────────────────── ZIP_NAME="tomgames_v${NEW_VERSION}.zip" zip -r "$ZIP_NAME" tomgames/ -x "*.DS_Store" -x "*/.git/*" -q echo "✓ Built $ZIP_NAME ($(du -sh "$ZIP_NAME" | cut -f1))" # ── Git commit & push ───────────────────────────────────── git add -A git commit -m "v${NEW_VERSION} — ${MSG}" git tag -a "v${NEW_VERSION}" -m "v${NEW_VERSION}: ${MSG}" git push origin main --tags echo "✓ Pushed to GitHub as v${NEW_VERSION}" echo "" echo "═══════════════════════════════════════" echo " After uploading to server, run:" echo " https://tomtomgames.com/bump_version.php?key=TTG_bump_2026!&version=$NEW_VERSION¬es=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$MSG'))")" echo "═══════════════════════════════════════"