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