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
ci / image (42, public) (push) Successful in 3m17s
This commit is contained in:
1 parent
c529b04ff0
commit
26ca1b90a2
9 files changed
+137
-34
No files matched your search
+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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user