diff --git a/README.md b/README.md index fa66b13..fa9e76f 100644 --- a/README.md +++ b/README.md @@ -10,25 +10,30 @@ This project deliberately does NOT build or upload `sportrum.war`/ project needs to make so `ant "migrate(@host)"` here can tag a deploy by the exact commit it shipped. -## Required: embedding WEB-INF/VERSION in the webapp build +## Required: embedding WEB-INF/TAG in the webapp build -`ant "migrate(@host)"` (see `build.xml`) tags every migration with the git -version of whatever `sportrum.war` is already sitting on the server — -read back off the WAR itself, not derived from this repo's git history -(there isn't a relationship between the two repos to derive it from). -That means the sportrum webapp project's own `build.xml` needs to embed a -`WEB-INF/VERSION` file into the WAR, containing a single line: +`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: ``` -- +-[-dirty] ``` -e.g. `20260930-184512-a3f9c21`. Timestamp first so tagged migration -folders on the server sort chronologically; build time (not commit time), -so the value stays unique even if the same commit is ever rebuilt and -redeployed again; `WEB-INF/`, not the WAR root, since anything outside -`WEB-INF/` is directly servable over HTTP by Tomcat and a commit hash -shouldn't be publicly fetchable. +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. Add this near the top of the webapp project's `war` target, before the `` task itself runs: @@ -42,19 +47,34 @@ Add this near the top of the webapp project's `war` target, before the - - - - + + + + + + + + + + + + + + + + + + ``` Then add a `` fileset to the existing `` task call, alongside whatever filesets are already there: ```xml - - + + + ``` diff --git a/build.xml b/build.xml index b81377e..7e912f4 100644 --- a/build.xml +++ b/build.xml @@ -268,19 +268,27 @@ Preferences -> Ant -> Runtime -> Classpath -> Ant Home Entries — same fix. - @@ -291,27 +299,37 @@ Preferences -> Ant -> Runtime -> Classpath -> Ant Home Entries — same fix. keyfile="${deploy.keyfile}" passphrase="${deploy.key.passphrase}" knownhosts="${deploy.knownhosts}" - command="unzip -p /home/sportrum/webapp/sportrum.war WEB-INF/VERSION | tr -d '\n'" - outputproperty="deploy.gitversion" + command="unzip -p /home/sportrum/webapp/sportrum.war WEB-INF/TAG | tr -d '\n'" + outputproperty="deploy.buildtag" failonerror="true"/> + file-write may have left in WEB-INF/TAG - whether or not it + did isn't this project's business to assume either way, + and a stray newline landing in a directory name would be a + much stranger failure to debug than this one-liner is to + write. --> - - + + - + -Couldn't read WEB-INF/VERSION out of the sportrum.war on @{host}. Either +Couldn't read WEB-INF/TAG out of the sportrum.war on @{host}. Either "ant release-all" hasn't been run against this server yet, or the webapp -project's build.xml doesn't embed WEB-INF/VERSION yet - see this project's +project's build.xml doesn't embed WEB-INF/TAG yet - see this project's README for the snippet it needs. + + @@ -335,10 +353,10 @@ on the server. Run again without spaces or other punctuation. override a value the condition above already set. Confirmed both branches empirically before relying on this. --> - + - + @@ -386,10 +404,11 @@ rationale: state. Then: WAR+logs backup only (no SQL dump - nothing to protect against), install the new sportrum.war, restart Tomcat (still needed; class files may have changed). No manager-exec.sh runs at all. - - migrate(@server): for a change that DOES touch the DB. Prompts for a - tag - the git version already embedded in sportrum.war's - WEB-INF/VERSION (see this project's README for the webapp project's - own build.xml needs), plus an optional short label - then runs the + - migrate(@server): for a change that DOES touch the DB. Resolves a tag + from the build-provenance string already embedded in sportrum.war's + WEB-INF/TAG (see this project's README for the webapp project's own + build.xml needs) plus a hash of the sportrum.war itself, plus an + optional short label - then runs the same schema check as above but only logs the result rather than blocking (a diff here is expected, not a sign anything's wrong). Then: full SQL+WAR+logs backup (the regular short-lived tier AND an @@ -445,7 +464,7 @@ else to configure here. + description="For a change that DOES migrate the DB. Resolves a tag (build-provenance string from sportrum.war's WEB-INF/TAG + a hash of sportrum.war itself + optional label), logs the pending schema diff, then runs upgrade.sh migrate on local.sportrum.se (tagged before/after backup kept indefinitely, DB migration with saved transcript), then confirms https://local.sportrum.se/ responds.">