diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.1 diff --git a/deploy.sh b/deploy.sh index 09cec67..fa68c9a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -16,8 +16,26 @@ DEST_DIR="/var/lib/caddy/www/metronome" [[ -f "$SRC_DIR/index.html" ]] || { echo "error: $SRC_DIR/index.html not found" >&2; exit 1; } [[ -d "$DEST_DIR" ]] || { echo "error: web root $DEST_DIR is missing — is Caddy set up?" >&2; exit 1; } -cp "$SRC_DIR/index.html" "$DEST_DIR/index.html" -echo "deployed index.html ($(stat -c '%s' "$DEST_DIR/index.html") bytes) -> $DEST_DIR" +# --- compute build version --------------------------------------------------- +# Formal build: clean tree on a commit tagged v -> "X.Y.Z" +# Dev build: anything else -> "X.Y.Z-dev..[.dirty]" +VER="$(cat "$SRC_DIR/VERSION" 2>/dev/null || echo 0.0.0)" +cd "$SRC_DIR" +if git rev-parse --git-dir >/dev/null 2>&1; then + tag="$(git describe --exact-match --tags HEAD 2>/dev/null || true)" + dirty=""; [[ -n "$(git status --porcelain 2>/dev/null)" ]] && dirty=".dirty" + if [[ "$tag" == "v$VER" && -z "$dirty" ]]; then + BUILD="$VER" # formal release + else + BUILD="$VER-dev.$(date -u +%Y%m%dT%H%M%SZ).g$(git rev-parse --short HEAD 2>/dev/null || echo nogit)$dirty" + fi +else + BUILD="$VER-dev.$(date -u +%Y%m%dT%H%M%SZ)" # not a git checkout +fi + +# stamp the version into the deployed copy only (source stays clean) +sed "s|const APP_VERSION = \"[^\"]*\";|const APP_VERSION = \"$BUILD\";|" "$SRC_DIR/index.html" > "$DEST_DIR/index.html" +echo "deployed v$BUILD ($(stat -c '%s' "$DEST_DIR/index.html") bytes) -> $DEST_DIR" # If real audio samples are added later (see the plan's GM-sample note), # sync that directory too. diff --git a/index.html b/index.html index 354a24f..2b3e846 100644 --- a/index.html +++ b/index.html @@ -143,7 +143,7 @@
-

Stackable Metronome mockup

+

Stackable Metronome v0.0.1-dev

Space play · T tap · ↑↓ tempo (⇧×10) · A add · R set lists · N next · ? help @@ -263,6 +263,11 @@ diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..3a5d5fa --- /dev/null +++ b/release.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Cut a formal release: set VERSION (optional arg) and tag the current commit +# as v. A clean checkout on that tag makes deploy.sh stamp the formal +# "X.Y.Z" instead of a dev build. +# +# ./release.sh # tag v +# ./release.sh 0.1.0 # bump VERSION to 0.1.0, then tag v0.1.0 +# +# Pushing the tag is left to you: git push origin "v" +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" + +if [[ $# -ge 1 ]]; then + [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "error: version must be X.Y.Z (got '$1')" >&2; exit 1; } + echo "$1" > VERSION + git add VERSION + git commit -m "Bump version to $1" >/dev/null + echo "VERSION -> $1 (committed)" +fi + +VER="$(cat VERSION)" +[[ -z "$(git status --porcelain)" ]] || { echo "error: working tree dirty — commit before releasing" >&2; exit 1; } + +if git rev-parse -q --verify "refs/tags/v$VER" >/dev/null; then + echo "error: tag v$VER already exists" >&2; exit 1 +fi + +git tag -a "v$VER" -m "Release v$VER" +echo "tagged v$VER" +echo "next: git push origin v$VER && ./deploy.sh (will now stamp the formal v$VER)"