From 18ff32b5ce12925f6e1ae64d0e4df9ccd2142758 Mon Sep 17 00:00:00 2001 From: Overlord Date: Sat, 3 Oct 2026 01:11:44 +0200 Subject: [PATCH] Refine tag handling in CI/release workflows and publish script to use the v* tag on HEAD, improve error messaging, and update documentation for server configuration adjustments. --- .gitea/workflows/ci.yml | 2 +- .gitea/workflows/publish.yml | 3 +-- .gitea/workflows/release.yml | 2 +- MOD_DEVELOPMENT.md | 13 ++++++++++--- ci/publish.sh | 10 +++++----- ci/release.sh | 16 ++++++++++------ 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index ab518aa..556e056 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - # release.sh derives the version from the newest v* tag + # release.sh derives the version from the v* tags fetch-depth: 0 - name: Build and verify diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index 0b964ba..b03d780 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -9,7 +9,6 @@ on: push: tags: - "v*" - workflow_dispatch: jobs: maven: @@ -17,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - # publish.sh derives the version from the newest v* tag + # publish.sh derives the version from the v* tag on HEAD fetch-depth: 0 - uses: actions/setup-java@v4 diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 1010132..4751894 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - # release.sh derives the version from the newest v* tag + # release.sh derives the version from the v* tags fetch-depth: 0 - name: Log in to the registry diff --git a/MOD_DEVELOPMENT.md b/MOD_DEVELOPMENT.md index 4668f8b..4d5b964 100644 --- a/MOD_DEVELOPMENT.md +++ b/MOD_DEVELOPMENT.md @@ -69,7 +69,8 @@ game jar for mods that declare `game` versions. Default settings go into | `gameJar` | see below | the `projectzomboid.jar` to compile and check against | | `steamBranch` | `public` | Steam branch for the download: `public`, `unstable`, or a version such as `42.19` | | `serverImage` | the ZomboidForge image, `latest` | image for `runServer` | -| `adminPassword` | `admin` | admin password of the `runServer` server | +| `adminPassword` | random, generated once per volume | admin password of the `runServer` server (see below) | +| `serverAddress` | `127.0.0.1` | host address `runServer` publishes the game ports on; `0.0.0.0` for the network | | `dataVolume` | `zomboidforge-` | volume for the `runServer` world and server config | | `containerEngine` | podman or docker, whichever is installed | for `runServer` and the download | | `deployDirectory` | none | a server's mods directory for `deployMod` | @@ -104,9 +105,15 @@ The game jar has to be one of the declared `game` versions; the check below fail | `modFolder` | `build/mod//` with `.jar` and `lib/`, as a server expects it in `/mods` | | `modZip` | the same as `build/distributions/-.zip` | | `runServer` | a ZomboidForge server in a container with the mod; Ctrl+C stops it after it saved the world | -| `deployMod` | copies the mod folder into `deployDirectory` | +| `deployMod` | copies the mod folder into `deployDirectory`; keeps the server's `config.toml` of the mod | | `downloadGame` | installs the dedicated server for its game jar; runs only when needed | +`runServer` is reachable from this machine only, unless `serverAddress` says otherwise. Without +`adminPassword`, the first run generates a random admin password for the volume, prints it, and +keeps it in `/zomboidforge/admin-passwords/`. The server uses the +password only when it creates the admin account, on the volume's first start; a later change +needs a new volume (`dataVolume`, or remove the old one). + ### Working on ZomboidForge itself To build a mod against a local ZomboidForge checkout instead of a published version, include it @@ -220,7 +227,7 @@ balances.set("player1", new Balance(250, Instant.now())); Optional balance = balances.get("player1"); balances.update("player1", old -> new Balance(old.coins() + 10, Instant.now()), () -> new Balance(0, null)); -this.storage().transaction(() -> { // all or nothing +this.storage().transaction(() -> { // all or nothing, also when nested balances.update("player1", old -> new Balance(old.coins() - 5, old.lastPaid()), () -> new Balance(0, null)); balances.update("player2", old -> new Balance(old.coins() + 5, old.lastPaid()), () -> new Balance(0, null)); }); diff --git a/ci/publish.sh b/ci/publish.sh index ea9bc6d..bd5f4df 100755 --- a/ci/publish.sh +++ b/ci/publish.sh @@ -2,10 +2,10 @@ # # Publishes the mod API (dev.overlord.zomboidforge:api), the mod tools (mod-tools), and the # Gradle plugin (dev.overlord.zomboidforge.mod) to the Maven registry of the ZomboidForge Gitea, -# in the version of the newest v* git tag reachable from HEAD, without the "v". +# in the version of the v* git tag on HEAD, without the "v". # # A pre-release version (containing "-", e.g. 0.3.0-rc.1) is built and tested but never -# published. Without any v* tag nothing is published. +# published. Without a v* tag on HEAD nothing is published. # # Environment: # ORG_GRADLE_PROJECT_giteaUsername Gitea user with package write access @@ -31,11 +31,11 @@ log() { echo "[publish] $*" >&2 } -# Prints the newest v* tag reachable from HEAD without its "v", or nothing. +# Prints the v* tag on HEAD without its "v", or nothing. release_tag_version() { local tag - if tag="$(git -C "${REPO_ROOT}" describe --tags --abbrev=0 --match 'v*' 2> /dev/null)"; then + if tag="$(git -C "${REPO_ROOT}" describe --tags --exact-match --match 'v*' 2> /dev/null)"; then echo "${tag#v}" fi } @@ -69,7 +69,7 @@ main() { version="$(release_tag_version)" if [[ -z "${version}" ]]; then - log "No v* git tag found (shallow clone without tags?); nothing to publish." + log "HEAD has no v* git tag (not a release commit, or a shallow clone without tags?); nothing to publish." exit 1 fi if [[ "${version}" == *-* ]]; then diff --git a/ci/release.sh b/ci/release.sh index e3aa620..59b926c 100755 --- a/ci/release.sh +++ b/ci/release.sh @@ -10,9 +10,10 @@ # is the version the branch's server jar reports, read before the full # build (Dockerfile stage game-version, which downloads only the jar). # -# is the newest v* git tag reachable from HEAD, without the "v" (v0.2.0 -> 0.2.0). -# A pre-release version (containing "-", e.g. 0.2.0-rc.1) is built and verified but never -# published. Without any v* tag the version is "0.0.0-prerelease". +# is the v* git tag on HEAD, without the "v" (v0.2.0 -> 0.2.0). When HEAD has no such +# tag, it is the git describe version of HEAD (0.2.0-3-g1a2b3c4: 3 commits after v0.2.0). +# A pre-release version (containing "-", e.g. 0.2.0-rc.1 or 0.2.0-3-g1a2b3c4) is built and +# verified but never published. Without any v* tag the version is "0.0.0-prerelease". # # Nothing is built when -pz already exists in the registry. The # server only admits clients with the same major.minor.build, so every hotfix (42.21.1 -> @@ -69,12 +70,15 @@ gradle_property() { exit 1 } -# Prints the forge version: the newest v* tag reachable from HEAD without its "v", -# or nothing when the repository has no such tag. +# Prints the forge version without the "v": the v* tag on HEAD, else the git describe version +# of HEAD relative to the newest reachable v* tag (v0.2.0-3-g1a2b3c4), or nothing when the +# repository has no such tag. release_tag_version() { local tag - if tag="$(git -C "${REPO_ROOT}" describe --tags --abbrev=0 --match 'v*' 2> /dev/null)"; then + if tag="$(git -C "${REPO_ROOT}" describe --tags --exact-match --match 'v*' 2> /dev/null)"; then + echo "${tag#v}" + elif tag="$(git -C "${REPO_ROOT}" describe --tags --match 'v*' 2> /dev/null)"; then echo "${tag#v}" fi }