Add versioning: VERSION file, dev/formal stamping, release.sh
- VERSION holds the formal version (0.0.1), single source of truth. - deploy.sh stamps the served HTML: "X.Y.Z" on a clean commit tagged v<VERSION>, else "X.Y.Z-dev.<utc-ts>.<sha>[.dirty]". - index.html shows the build version in the header badge (APP_VERSION). - release.sh cuts a formal release (sets VERSION + tags v<VERSION>). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
38d860b4dd
commit
a7770eaf47
4 changed files with 58 additions and 3 deletions
1
VERSION
Normal file
1
VERSION
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
0.0.1
|
||||||
22
deploy.sh
22
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; }
|
[[ -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; }
|
[[ -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"
|
# --- compute build version ---------------------------------------------------
|
||||||
echo "deployed index.html ($(stat -c '%s' "$DEST_DIR/index.html") bytes) -> $DEST_DIR"
|
# Formal build: clean tree on a commit tagged v<VERSION> -> "X.Y.Z"
|
||||||
|
# Dev build: anything else -> "X.Y.Z-dev.<utc-ts>.<sha>[.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),
|
# If real audio samples are added later (see the plan's GM-sample note),
|
||||||
# sync that directory too.
|
# sync that directory too.
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="device">
|
<div class="device">
|
||||||
<div class="row" style="align-items:baseline; justify-content:space-between; gap:14px; margin-bottom:12px">
|
<div class="row" style="align-items:baseline; justify-content:space-between; gap:14px; margin-bottom:12px">
|
||||||
<h1 style="margin:0">Stackable Metronome <span class="lane-meta">mockup</span></h1>
|
<h1 style="margin:0">Stackable Metronome <span class="lane-meta" id="appVersion" title="build version">v0.0.1-dev</span></h1>
|
||||||
<div style="display:flex; align-items:center; gap:10px">
|
<div style="display:flex; align-items:center; gap:10px">
|
||||||
<span class="kbd-legend">Space play · T tap · ↑↓ tempo (⇧×10) · A add · R set lists · N next · ? help</span>
|
<span class="kbd-legend">Space play · T tap · ↑↓ tempo (⇧×10) · A add · R set lists · N next · ? help</span>
|
||||||
<button id="themeBtn" title="toggle light / dark theme">☀</button>
|
<button id="themeBtn" title="toggle light / dark theme">☀</button>
|
||||||
|
|
@ -263,6 +263,11 @@
|
||||||
<script>
|
<script>
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
// Build version. deploy.sh rewrites this line: a clean commit tagged v<VERSION>
|
||||||
|
// stamps the formal "X.Y.Z"; any other build stamps "X.Y.Z-dev.<ts>.<sha>[.dirty]".
|
||||||
|
// The literal below is the fallback shown when viewing the un-deployed source.
|
||||||
|
const APP_VERSION = "0.0.1-dev";
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
STATE
|
STATE
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
@ -877,6 +882,7 @@ refreshPresetList();
|
||||||
renderSetlists();
|
renderSetlists();
|
||||||
renderLog();
|
renderLog();
|
||||||
updateCtx();
|
updateCtx();
|
||||||
|
$("appVersion").textContent = "v" + APP_VERSION;
|
||||||
requestAnimationFrame(drawLoop);
|
requestAnimationFrame(drawLoop);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
30
release.sh
Executable file
30
release.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Cut a formal release: set VERSION (optional arg) and tag the current commit
|
||||||
|
# as v<VERSION>. A clean checkout on that tag makes deploy.sh stamp the formal
|
||||||
|
# "X.Y.Z" instead of a dev build.
|
||||||
|
#
|
||||||
|
# ./release.sh # tag v<current VERSION>
|
||||||
|
# ./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<VERSION>"
|
||||||
|
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)"
|
||||||
Loading…
Reference in a new issue