2 Commits
Author SHA1 Message Date
Overlord 26ca1b90a2 Add support for precise Project Zomboid versioning in builds and images. Include printGameVersion task, improve image tagging, and enhance CI/release workflows for hotfix handling.
ci / image (42, public) (push) Successful in 3m17s
2026-10-02 17:53:58 +02:00
Overlord c529b04ff0 Merge tag 'v0.3.0' into develop
ci / image (42.21, public) (push) Successful in 2m38s
Tagging version v0.3.0 v0.3.0
2026-10-02 15:36:33 +02:00
9 changed files with 137 additions and 34 deletions

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ jobs:
include: include:
# One entry per supported version; add older Steam version branches # One entry per supported version; add older Steam version branches
# (e.g. pz_version 42.19, steam_branch 42.19) to keep them building. # (e.g. pz_version 42.19, steam_branch 42.19) to keep them building.
- pz_version: "42.21" - pz_version: "42"
steam_branch: public steam_branch: public
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
+8 -4
View File
@@ -1,12 +1,16 @@
# Publishes an image for every new Steam build of each supported Project Zomboid # Publishes an image for every new Project Zomboid version (hotfixes included) of each
# version. Immutable tags are never overwritten (see ci/release.sh). # matrix entry and every new ZomboidForge release; full version tags are never overwritten
# (see ci/release.sh).
# Requires the repository secrets REGISTRY_USER and REGISTRY_TOKEN (a token with # Requires the repository secrets REGISTRY_USER and REGISTRY_TOKEN (a token with
# package write access) and a runner with a Docker (or Podman) CLI. # package write access) and a runner with a Docker (or Podman) CLI.
name: release name: release
on: on:
# Every 2.5 hours; cron cannot divide a day into 2.5-hour steps, so the gap
# from 22:30 to 00:00 is 1.5 hours.
schedule: schedule:
- cron: "0 */6 * * *" - cron: "0 0,5,10,15,20 * * *"
- cron: "30 2,7,12,17,22 * * *"
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@@ -16,7 +20,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- pz_version: "42.21" - pz_version: "42"
steam_branch: public steam_branch: public
latest: "true" latest: "true"
steps: steps:
+38 -4
View File
@@ -6,6 +6,10 @@
# podman build --platform linux/amd64 -t zomboidforge . # podman build --platform linux/amd64 -t zomboidforge .
# podman build --build-arg PZ_BRANCH=42.19 --build-arg PZ_VERSION=42.19 ... # podman build --build-arg PZ_BRANCH=42.19 --build-arg PZ_VERSION=42.19 ...
# #
# The stage game-version (--target game-version) downloads only the server jar of
# PZ_BRANCH and writes its game version to /game-version; ci/release.sh uses it to
# name the image before the full build.
#
# Build arguments: # Build arguments:
# PZ_BRANCH Steam branch of app 380870: public, unstable, or a version branch (42.19, ...) # PZ_BRANCH Steam branch of app 380870: public, unstable, or a version branch (42.19, ...)
# PZ_VERSION Expected Project Zomboid version; the build fails when the downloaded # PZ_VERSION Expected Project Zomboid version; the build fails when the downloaded
@@ -14,7 +18,8 @@
# files with steamcmd's newer copies # files with steamcmd's newer copies
# FORGE_VERSION ZomboidForge version (jar manifest, image label); set by ci/release.sh. # FORGE_VERSION ZomboidForge version (jar manifest, image label); set by ci/release.sh.
# Default: 0.0.0-prerelease # Default: 0.0.0-prerelease
# STEAM_BUILDID Image label only; set by ci/release.sh # STEAM_BUILDID Image label; in the stage game-version it keeps the cached result until
# Steam publishes a new build. Set by ci/release.sh
# DISABLED_PATCHES Comma-separated simple class names of build-time patches to skip # DISABLED_PATCHES Comma-separated simple class names of build-time patches to skip
# (debug builds only; ci/release.sh never sets it) # (debug builds only; ci/release.sh never sets it)
@@ -36,8 +41,8 @@ ARG STEAMCLIENT
COPY docker/install-server.sh /usr/local/bin/install-server COPY docker/install-server.sh /usr/local/bin/install-server
RUN install-server /server "${PZ_BRANCH}" "${STEAMCLIENT}" RUN install-server /server "${PZ_BRANCH}" "${STEAMCLIENT}"
# --- Stage 2: ZomboidForge build and server jar patching ----------------------- # --- Stage 2: ZomboidForge sources and Gradle -----------------------------------
FROM docker.io/library/eclipse-temurin:25-jdk AS build FROM docker.io/library/eclipse-temurin:25-jdk AS sources
WORKDIR /src WORKDIR /src
# Gradle distribution download, cached independently of the sources. # Gradle distribution download, cached independently of the sources.
@@ -53,6 +58,35 @@ COPY agent agent
COPY patcher patcher COPY patcher patcher
COPY mod-tools mod-tools COPY mod-tools mod-tools
COPY gradle-plugin gradle-plugin COPY gradle-plugin gradle-plugin
# --- Game version of a Steam branch, from its server jar alone ------------------
# Not part of the image; built on its own by ci/release.sh.
FROM sources AS game-version
# DepotDownloader downloads single files of a depot; steamcmd only whole apps.
ADD --checksum=sha256:a999dec66b4850fc961bd50366696d23c2d0fad7b18790e6a5647b2f19097a53 \
https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_3.4.0/DepotDownloader-linux-x64.zip \
/opt/depotdownloader/depotdownloader.zip
RUN cd /opt/depotdownloader \
&& jar xf depotdownloader.zip \
&& chmod +x DepotDownloader \
&& rm depotdownloader.zip
# FORGE_VERSION only keeps Gradle from asking git (not in this stage) for the version.
ARG PZ_BRANCH
ARG STEAM_BUILDID
ARG FORGE_VERSION
RUN echo java/projectzomboid.jar > /tmp/files \
&& /opt/depotdownloader/DepotDownloader \
-app 380870 -depot 380871 -branch "${PZ_BRANCH}" -filelist /tmp/files -dir /pz \
&& ./gradlew --no-daemon --quiet \
-Ppz.jar=/pz/java/projectzomboid.jar \
-Pversion=${FORGE_VERSION} \
:patcher:printGameVersion > /game-version
# --- Stage 3: ZomboidForge build and server jar patching -----------------------
FROM sources AS build
COPY --from=server /server/java/projectzomboid.jar /pz/projectzomboid.jar COPY --from=server /server/java/projectzomboid.jar /pz/projectzomboid.jar
# An empty PZ_VERSION keeps pz.version from gradle.properties. FORGE_VERSION always has a # An empty PZ_VERSION keeps pz.version from gradle.properties. FORGE_VERSION always has a
@@ -67,7 +101,7 @@ RUN ./gradlew --no-daemon \
${DISABLED_PATCHES:+-Pzf.disabledPatches=${DISABLED_PATCHES}} \ ${DISABLED_PATCHES:+-Pzf.disabledPatches=${DISABLED_PATCHES}} \
build -x :gradle-plugin:test :patcher:patchServerJar build -x :gradle-plugin:test :patcher:patchServerJar
# --- Stage 3: runtime ------------------------------------------------------------ # --- Stage 4: runtime ------------------------------------------------------------
FROM docker.io/library/debian:trixie-slim FROM docker.io/library/debian:trixie-slim
# ca-certificates: required by steamclient.so to connect to Steam. # ca-certificates: required by steamclient.so to connect to Steam.
+5 -1
View File
@@ -40,7 +40,7 @@ version = "1.2.0"
zomboidForge { zomboidForge {
id = "shop" id = "shop"
entrypoint = "com.example.shop.ShopMod" entrypoint = "com.example.shop.ShopMod"
game("42.21") // only when the mod uses game classes game("42") // only when the mod uses game classes
dependsOn("economy", "2.1") // other mods: id and minimum version dependsOn("economy", "2.1") // other mods: id and minimum version
} }
@@ -77,6 +77,10 @@ game jar for mods that declare `game` versions. Default settings go into
The plugin generates `META-INF/zomboidforge/mod.toml` from these settings; a hand-written one The plugin generates `META-INF/zomboidforge/mod.toml` from these settings; a hand-written one
fails the build. fails the build.
Declare a minor version in `game(...)` only when the mod needs it. A mod declaring `"42.21"`
stops the server after an update to 42.22, while the server checks every game member a mod uses
against the running jar anyway.
### The game jar ### The game jar
Mods that declare `game` versions compile against `projectzomboid.jar`, which cannot be Mods that declare `game` versions compile against `projectzomboid.jar`, which cannot be
+4 -2
View File
@@ -22,8 +22,10 @@ podman build --platform linux/amd64 -t zomboidforge . # or: docker build ...
| `FORGE_VERSION` | `0.0.0-prerelease` | ZomboidForge version (jar manifest, image label). The build stage has no `git`, so the version is never read from a tag there; `ci/release.sh` passes it | | `FORGE_VERSION` | `0.0.0-prerelease` | ZomboidForge version (jar manifest, image label). The build stage has no `git`, so the version is never read from a tag there; `ci/release.sh` passes it |
| `DISABLED_PATCHES` | | Comma-separated simple class names of build-time patches to skip (debug builds only), e.g. `IsoZombieVehiclePerformancePatch` | | `DISABLED_PATCHES` | | Comma-separated simple class names of build-time patches to skip (debug builds only), e.g. `IsoZombieVehiclePerformancePatch` |
Published images are tagged `<forge>-pz<pz>-build<steam buildid>` (immutable), Published images are tagged `<forge>-pz<major.minor.build>` (never overwritten),
`<forge>-pz<pz>`, and `latest`. `<forge>-pz<major.minor>` (the newest hotfix of that minor version), and `latest`. A new image
is built for every ZomboidForge release and every Project Zomboid version, hotfixes included:
the server only admits clients with the same version.
## Running ## Running
+51 -20
View File
@@ -1,22 +1,28 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Builds the ZomboidForge image for one Project Zomboid version and optionally # Builds the ZomboidForge image for the current build of a Steam branch and optionally
# publishes it. Published tags: # publishes it. Published tags:
# #
# <forge>-pz<pz>-build<steam_buildid> immutable; never overwritten # <forge>-pz<major.minor.build> written once per ZomboidForge and Project Zomboid version
# <forge>-pz<pz> moves to the newest Steam build of that version # <forge>-pz<major.minor> moves to the newest hotfix of that minor version
# latest only with LATEST=true # latest only with LATEST=true
#
# <major.minor.build> is the version the branch's server jar reports, read before the full
# build (Dockerfile stage game-version, which downloads only the jar).
# #
# <forge> is the newest v* git tag reachable from HEAD, without the "v" (v0.2.0 -> 0.2.0). # <forge> 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 # 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". # published. Without any v* tag the version is "0.0.0-prerelease".
# #
# Nothing is built when the immutable tag already exists in the registry. # Nothing is built when <forge>-pz<major.minor.build> already exists in the registry. The
# server only admits clients with the same major.minor.build, so every hotfix (42.21.1 ->
# 42.21.2) gets an image; a new Steam build with an unchanged version does not.
# #
# Environment: # Environment:
# IMAGE Image name without tag, e.g. git.security-command.org/overlord/zomboidforge # IMAGE Image name without tag, e.g. git.security-command.org/overlord/zomboidforge
# PZ_BRANCH Steam branch. Default: public # PZ_BRANCH Steam branch. Default: public
# PZ_VERSION Expected Project Zomboid version. Default: pz.version in gradle.properties # PZ_VERSION Accepted Project Zomboid versions ("42": every Build 42 version).
# Default: pz.version in gradle.properties
# PUBLISH true: push the tags (not for pre-release versions). Default: false (build and verify only) # PUBLISH true: push the tags (not for pre-release versions). Default: false (build and verify only)
# LATEST true: also push "latest". Default: false # LATEST true: also push "latest". Default: false
# CONTAINER_ENGINE docker or podman. Default: docker if installed, else podman # CONTAINER_ENGINE docker or podman. Default: docker if installed, else podman
@@ -78,6 +84,22 @@ image_exists() {
"$(container_engine)" manifest inspect "${reference}" > /dev/null 2>&1 "$(container_engine)" manifest inspect "${reference}" > /dev/null 2>&1
} }
# Prints the game version of the branch's current server jar, e.g. 42.21.0. Downloads only
# the jar; the result stays cached until the build ID changes.
read_game_version() {
local build_id="$1"
local image
image="$("$(container_engine)" build --quiet \
--platform linux/amd64 \
--target game-version \
--build-arg "PZ_BRANCH=${PZ_BRANCH}" \
--build-arg "STEAM_BUILDID=${build_id}" \
"${REPO_ROOT}")"
"$(container_engine)" run --rm --entrypoint cat "${image}" /game-version
}
build_image() { build_image() {
local reference="$1" local reference="$1"
local forge_version="$2" local forge_version="$2"
@@ -119,8 +141,9 @@ push_as() {
main() { main() {
local forge_version local forge_version
local publish="${REQUESTED_PUBLISH}" local publish="${REQUESTED_PUBLISH}"
local pz_version local pz_prefix
local build_id local build_id
local game_version
forge_version="$(release_tag_version)" forge_version="$(release_tag_version)"
if [[ -z "${forge_version}" ]]; then if [[ -z "${forge_version}" ]]; then
@@ -132,31 +155,39 @@ main() {
log "${forge_version} is a pre-release version; nothing will be published." log "${forge_version} is a pre-release version; nothing will be published."
fi fi
pz_version="${PZ_VERSION:-$(gradle_property pz.version)}" pz_prefix="${PZ_VERSION:-$(gradle_property pz.version)}"
build_id="$("${REPO_ROOT}/ci/steam-buildid.sh" "${PZ_BRANCH}")" build_id="$("${REPO_ROOT}/ci/steam-buildid.sh" "${PZ_BRANCH}")"
game_version="$(read_game_version "${build_id}")"
log "ZomboidForge ${forge_version}, Project Zomboid ${game_version}, Steam branch ${PZ_BRANCH} build ${build_id}"
local immutable_tag="${IMAGE}:${forge_version}-pz${pz_version}-build${build_id}" # Checked here as well as by the patcher, to fail before the full download.
local version_tag="${IMAGE}:${forge_version}-pz${pz_version}" if [[ "${game_version}" != "${pz_prefix}" && "${game_version}" != "${pz_prefix}."* ]]; then
log "ZomboidForge ${forge_version}, Project Zomboid ${pz_version}, Steam branch ${PZ_BRANCH} build ${build_id}" log "Steam branch ${PZ_BRANCH} has Project Zomboid ${game_version}; the build accepts ${pz_prefix}."
exit 1
fi
if [[ "${publish}" == true ]] && image_exists "${immutable_tag}"; then local version_tag="${IMAGE}:${forge_version}-pz${game_version}"
log "${immutable_tag} is already published; nothing to do." # 42.21.2 -> 42.21
local minor_tag="${IMAGE}:${forge_version}-pz${game_version%.*}"
if [[ "${publish}" == true ]] && image_exists "${version_tag}"; then
log "${version_tag} is already published; nothing to do."
return return
fi fi
build_image "${immutable_tag}" "${forge_version}" "${pz_version}" "${build_id}" build_image "${version_tag}" "${forge_version}" "${game_version}" "${build_id}"
verify_build_id "${immutable_tag}" "${build_id}" verify_build_id "${version_tag}" "${build_id}"
if [[ "${publish}" != true ]]; then if [[ "${publish}" != true ]]; then
log "Built ${immutable_tag} (not published)" log "Built ${version_tag} (not published)"
return return
fi fi
"$(container_engine)" push "${immutable_tag}" "$(container_engine)" push "${version_tag}"
log "Pushed ${immutable_tag}" log "Pushed ${version_tag}"
push_as "${immutable_tag}" "${version_tag}" push_as "${version_tag}" "${minor_tag}"
if [[ "${LATEST}" == true ]]; then if [[ "${LATEST}" == true ]]; then
push_as "${immutable_tag}" "${IMAGE}:latest" push_as "${version_tag}" "${IMAGE}:latest"
fi fi
} }
+2 -2
View File
@@ -2,8 +2,8 @@ group=dev.overlord.zomboidforge
# Project Zomboid version the build targets. Selects compat/b<major>/, and # Project Zomboid version the build targets. Selects compat/b<major>/, and
# :patcher:patchServerJar fails when the server jar reports another version. # :patcher:patchServerJar fails when the server jar reports another version.
# "42.21" matches every 42.21.x build; "42.21.0" matches exactly. # "42" matches every Build 42 version, "42.21" every 42.21.x build, "42.21.0" exactly.
pz.version=42.21 pz.version=42
# Vanilla dedicated server jar used for compilation and patching. # Vanilla dedicated server jar used for compilation and patching.
# Default: lib/server/java/projectzomboid.jar (relative to the root project). # Default: lib/server/java/projectzomboid.jar (relative to the root project).
+14
View File
@@ -60,3 +60,17 @@ tasks.register<JavaExec>("patchServerJar") {
) )
}) })
} }
// Used by ci/release.sh (Dockerfile stage game-version) to name the image before the full build.
tasks.register<JavaExec>("printGameVersion") {
description = "Prints the game version of the server jar (pz.jar)."
group = "help"
val serverJar = projectZomboid.serverJar
classpath = sourceSets.main.get().runtimeClasspath
mainClass = "dev.overlord.zomboidforge.patcher.GameVersionReader"
argumentProviders.add(CommandLineArgumentProvider {
listOf(serverJar.get().asFile.absolutePath)
})
}
@@ -13,6 +13,8 @@ import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -32,6 +34,18 @@ public final class GameVersionReader
private GameVersionReader() {} private GameVersionReader() {}
/** Usage: {@code GameVersionReader <server.jar>}. Prints the jar's game version, e.g. {@code 42.21.0}. */
static void main(String[] args) throws IOException
{
if (args.length != 1)
{
System.err.println("Usage: GameVersionReader <server.jar>");
System.exit(2);
}
System.out.println(JarPatcher.readGameVersion(Path.of(args[0])));
}
public static GameVersion read(byte[] coreClass) public static GameVersion read(byte[] coreClass)
{ {
ClassNode core = new ClassNode(); ClassNode core = new ClassNode();