Compare commits
2
Commits
v0.3.0
...
26ca1b90a2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26ca1b90a2 | ||
|
|
c529b04ff0 |
No files matched your search
@@ -15,7 +15,7 @@ jobs:
|
||||
include:
|
||||
# One entry per supported version; add older Steam version branches
|
||||
# (e.g. pz_version 42.19, steam_branch 42.19) to keep them building.
|
||||
- pz_version: "42.21"
|
||||
- pz_version: "42"
|
||||
steam_branch: public
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
# Publishes an image for every new Steam build of each supported Project Zomboid
|
||||
# version. Immutable tags are never overwritten (see ci/release.sh).
|
||||
# Publishes an image for every new Project Zomboid version (hotfixes included) of each
|
||||
# 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
|
||||
# package write access) and a runner with a Docker (or Podman) CLI.
|
||||
name: release
|
||||
|
||||
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:
|
||||
- cron: "0 */6 * * *"
|
||||
- cron: "0 0,5,10,15,20 * * *"
|
||||
- cron: "30 2,7,12,17,22 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@@ -16,7 +20,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- pz_version: "42.21"
|
||||
- pz_version: "42"
|
||||
steam_branch: public
|
||||
latest: "true"
|
||||
steps:
|
||||
|
||||
+38
-4
@@ -6,6 +6,10 @@
|
||||
# podman build --platform linux/amd64 -t zomboidforge .
|
||||
# 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:
|
||||
# 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
|
||||
@@ -14,7 +18,8 @@
|
||||
# files with steamcmd's newer copies
|
||||
# FORGE_VERSION ZomboidForge version (jar manifest, image label); set by ci/release.sh.
|
||||
# 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
|
||||
# (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
|
||||
RUN install-server /server "${PZ_BRANCH}" "${STEAMCLIENT}"
|
||||
|
||||
# --- Stage 2: ZomboidForge build and server jar patching -----------------------
|
||||
FROM docker.io/library/eclipse-temurin:25-jdk AS build
|
||||
# --- Stage 2: ZomboidForge sources and Gradle -----------------------------------
|
||||
FROM docker.io/library/eclipse-temurin:25-jdk AS sources
|
||||
WORKDIR /src
|
||||
|
||||
# Gradle distribution download, cached independently of the sources.
|
||||
@@ -53,6 +58,35 @@ COPY agent agent
|
||||
COPY patcher patcher
|
||||
COPY mod-tools mod-tools
|
||||
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
|
||||
|
||||
# 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}} \
|
||||
build -x :gradle-plugin:test :patcher:patchServerJar
|
||||
|
||||
# --- Stage 3: runtime ------------------------------------------------------------
|
||||
# --- Stage 4: runtime ------------------------------------------------------------
|
||||
FROM docker.io/library/debian:trixie-slim
|
||||
|
||||
# ca-certificates: required by steamclient.so to connect to Steam.
|
||||
|
||||
+5
-1
@@ -40,7 +40,7 @@ version = "1.2.0"
|
||||
zomboidForge {
|
||||
id = "shop"
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
Mods that declare `game` versions compile against `projectzomboid.jar`, which cannot be
|
||||
|
||||
@@ -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 |
|
||||
| `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),
|
||||
`<forge>-pz<pz>`, and `latest`.
|
||||
Published images are tagged `<forge>-pz<major.minor.build>` (never overwritten),
|
||||
`<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
|
||||
|
||||
|
||||
+51
-20
@@ -1,22 +1,28 @@
|
||||
#!/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:
|
||||
#
|
||||
# <forge>-pz<pz>-build<steam_buildid> immutable; never overwritten
|
||||
# <forge>-pz<pz> moves to the newest Steam build of that version
|
||||
# latest only with LATEST=true
|
||||
# <forge>-pz<major.minor.build> written once per ZomboidForge and Project Zomboid version
|
||||
# <forge>-pz<major.minor> moves to the newest hotfix of that minor version
|
||||
# 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).
|
||||
# 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".
|
||||
#
|
||||
# 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:
|
||||
# IMAGE Image name without tag, e.g. git.security-command.org/overlord/zomboidforge
|
||||
# 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)
|
||||
# LATEST true: also push "latest". Default: false
|
||||
# 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
|
||||
}
|
||||
|
||||
# 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() {
|
||||
local reference="$1"
|
||||
local forge_version="$2"
|
||||
@@ -119,8 +141,9 @@ push_as() {
|
||||
main() {
|
||||
local forge_version
|
||||
local publish="${REQUESTED_PUBLISH}"
|
||||
local pz_version
|
||||
local pz_prefix
|
||||
local build_id
|
||||
local game_version
|
||||
|
||||
forge_version="$(release_tag_version)"
|
||||
if [[ -z "${forge_version}" ]]; then
|
||||
@@ -132,31 +155,39 @@ main() {
|
||||
log "${forge_version} is a pre-release version; nothing will be published."
|
||||
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}")"
|
||||
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}"
|
||||
local version_tag="${IMAGE}:${forge_version}-pz${pz_version}"
|
||||
log "ZomboidForge ${forge_version}, Project Zomboid ${pz_version}, Steam branch ${PZ_BRANCH} build ${build_id}"
|
||||
# Checked here as well as by the patcher, to fail before the full download.
|
||||
if [[ "${game_version}" != "${pz_prefix}" && "${game_version}" != "${pz_prefix}."* ]]; then
|
||||
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
|
||||
log "${immutable_tag} is already published; nothing to do."
|
||||
local version_tag="${IMAGE}:${forge_version}-pz${game_version}"
|
||||
# 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
|
||||
fi
|
||||
|
||||
build_image "${immutable_tag}" "${forge_version}" "${pz_version}" "${build_id}"
|
||||
verify_build_id "${immutable_tag}" "${build_id}"
|
||||
build_image "${version_tag}" "${forge_version}" "${game_version}" "${build_id}"
|
||||
verify_build_id "${version_tag}" "${build_id}"
|
||||
|
||||
if [[ "${publish}" != true ]]; then
|
||||
log "Built ${immutable_tag} (not published)"
|
||||
log "Built ${version_tag} (not published)"
|
||||
return
|
||||
fi
|
||||
|
||||
"$(container_engine)" push "${immutable_tag}"
|
||||
log "Pushed ${immutable_tag}"
|
||||
push_as "${immutable_tag}" "${version_tag}"
|
||||
"$(container_engine)" push "${version_tag}"
|
||||
log "Pushed ${version_tag}"
|
||||
push_as "${version_tag}" "${minor_tag}"
|
||||
if [[ "${LATEST}" == true ]]; then
|
||||
push_as "${immutable_tag}" "${IMAGE}:latest"
|
||||
push_as "${version_tag}" "${IMAGE}:latest"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ group=dev.overlord.zomboidforge
|
||||
|
||||
# Project Zomboid version the build targets. Selects compat/b<major>/, and
|
||||
# :patcher:patchServerJar fails when the server jar reports another version.
|
||||
# "42.21" matches every 42.21.x build; "42.21.0" matches exactly.
|
||||
pz.version=42.21
|
||||
# "42" matches every Build 42 version, "42.21" every 42.21.x build, "42.21.0" exactly.
|
||||
pz.version=42
|
||||
|
||||
# Vanilla dedicated server jar used for compilation and patching.
|
||||
# Default: lib/server/java/projectzomboid.jar (relative to the root project).
|
||||
|
||||
@@ -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.MethodNode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,6 +34,18 @@ public final class 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)
|
||||
{
|
||||
ClassNode core = new ClassNode();
|
||||
|
||||
Reference in new issue
Block a user