sportrum-deploy/README.md

97 lines
4 KiB
Markdown
Raw Permalink Normal View History

Replace flag-based upgrade.sh with named migrate/hotfix-code modes 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
2026-09-30 20:00:35 +00:00
# sportrum-deploy
Deploy tooling for the sportrum webapp — the actual server-side upgrade
(stop Tomcat, back up, install the new build, migrate the DB, restart),
run either by hand or via this repo's `build.xml`.
This project deliberately does NOT build or upload `sportrum.war`/
`manager.zip` itself. That's the sportrum webapp project's own `build.xml`
(its `release-all` target) — see the next section for the one change that
project needs to make so `ant "migrate(@host)"` here can tag a deploy by
the exact commit it shipped.
## Required: embedding WEB-INF/TAG in the webapp build
Replace flag-based upgrade.sh with named migrate/hotfix-code modes 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
2026-09-30 20:00:35 +00:00
`ant "migrate(@host)"` (see `build.xml`) tags every migration with a build
tag read back off whatever `sportrum.war` is already sitting on the server
(not derived from this repo's git history — there isn't a relationship
between the two repos to derive it from), plus a hash of that `sportrum.war`
computed here. That means the sportrum webapp project's own `build.xml`
needs to embed a `WEB-INF/TAG` file into the WAR, containing a single line:
Replace flag-based upgrade.sh with named migrate/hotfix-code modes 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
2026-09-30 20:00:35 +00:00
```
<build-timestamp>-<git-short-hash>[-dirty]
Replace flag-based upgrade.sh with named migrate/hotfix-code modes 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
2026-09-30 20:00:35 +00:00
```
e.g. `20260930-184512-a3f9c21` or `20260930-184512-a3f9c21-dirty`. This is
build provenance, not a guarantee of what the WAR actually contains (things
outside git — e.g. local library jars — can still differ between two builds
of the same commit), which is why `resolve-migration-tag` also hashes the
WAR itself rather than trusting this string alone. Timestamp first so
tagged migration folders on the server sort chronologically and so it's
easy to tell when a build happened; build time (not commit time), so the
value stays unique even if the same commit is ever rebuilt and redeployed
again; the `-dirty` suffix marks a build whose working tree had uncommitted
changes at build time. `WEB-INF/`, not the WAR root, since anything outside
`WEB-INF/` is directly servable over HTTP by Tomcat.
Replace flag-based upgrade.sh with named migrate/hotfix-code modes 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
2026-09-30 20:00:35 +00:00
Add this near the top of the webapp project's `war` target, before the
`<war>` task itself runs:
```xml
<tstamp>
<format property="build.timestamp" pattern="yyyyMMdd-HHmmss"/>
</tstamp>
<exec executable="git" outputproperty="build.gitrev" failonerror="true">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputproperty="git.dirty.files" failonerror="true">
<arg value="status"/>
<arg value="--porcelain"/>
</exec>
<condition property="git.dirty">
<not><equals arg1="${git.dirty.files}" arg2=""/></not>
</condition>
<condition property="dirty.suffix" value="-dirty">
<isset property="git.dirty"/>
</condition>
<property name="dirty.suffix" value=""/>
<property name="build.tag" value="${build.timestamp}-${build.gitrev}${dirty.suffix}"/>
<echo message="Building ${build.tag}"/>
<mkdir dir="${build}/tag-stage"/>
<echo file="${build}/tag-stage/TAG" message="${build.tag}"/>
<echo file="${build}/tag-stage/DIRTY-FILES" message="${git.dirty.files}" if="git.dirty"/>
Replace flag-based upgrade.sh with named migrate/hotfix-code modes 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
2026-09-30 20:00:35 +00:00
```
Then add a `<webinf>` fileset to the existing `<war destfile="${build}/sportrum.war" ...>`
task call, alongside whatever filesets are already there:
```xml
<webinf dir="${build}/tag-stage">
<include name="TAG"/>
<include name="DIRTY-FILES"/>
Replace flag-based upgrade.sh with named migrate/hotfix-code modes 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
2026-09-30 20:00:35 +00:00
</webinf>
```
Until that's in place, `ant "migrate(@host)"` here will fail its own
pre-flight check with a message pointing back here, rather than silently
tagging every migration `unknown` or similar — see `resolve-migration-tag`
in `build.xml`.
## Deploy targets
See `ant help` (or just `ant`, since `help` is the default target) for the
full, current usage text — it's kept there rather than duplicated here so
it can't drift out of sync with the actual `build.xml`. Short version:
`install-scripts(@host)` syncs this repo's scripts to the server without
running anything; `hotfix-code(@host)` is for a change with no DB
migration (hard-gated on `check-schema-diff.sh` confirming that's actually
true); `migrate(@host)` is for a change that does migrate the DB (tagged,
indefinitely-kept before/after backup and migration transcript under
`backup/migrations/<tag>/` on the server).