WEB-INF/VERSION only ever held a git short-hash, which claimed more than
it could prove: two builds of the same commit can still differ (local
library jars, anything outside git), so a git version alone doesn't
guarantee what's actually in the WAR on the server.
Replaced with WEB-INF/TAG (<build-timestamp>-<git-short-hash>[-dirty] -
build time, not commit time, so a rebuilt/redeployed same commit still
gets a unique value, and "-dirty" flags an uncommitted working tree at
build time) plus a sha256 of the sportrum.war actually sitting on the
server, computed here rather than trusted from the build since a file
can't hash itself and this also catches corruption/tampering in transit.
resolve-migration-tag now reads both and the migration tag becomes
<build-tag>-<war-hash>[-<label>] instead of <git-version>[-<label>].
README and build.xml's inline docs/target descriptions updated to match.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb