5 Commits
Author SHA1 Message Date
Overlord 1d657e2b9a Merge branch 'release/v0.1.0-dev'
release / release (push) Failing after 26s
2026-10-03 20:38:49 +02:00
Overlord e07e946a87 Add resolveCollection task: resolves config.toml like server startup and prints results. 2026-10-03 20:33:58 +02:00
Overlord 226c909d19 Merge branch 'release/v0.1.0'
release / release (push) Successful in 1m58s
2026-10-03 18:36:43 +02:00
Overlord 8484d6c20c Merge tag 'v0.1.0' into develop
Tagging version v0.1.0 v0.1.0
2026-10-03 18:36:43 +02:00
OverlordandClaude Bot e1094d96a2 Add CI pipeline: automated builds and releases for versioned tags.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 18:36:33 +02:00
9 changed files with 381 additions and 15 deletions

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
# Builds the mod for every v* tag and publishes it as a release with lua_mod_automator.zip
# attached, so .../releases/download/latest/lua_mod_automator.zip always serves the newest one.
# Pre-release tags (containing "-") and tags on commits that are not on master are built and
# tested but not released (see ci/release.sh).
# Uses the repository secret RELEASE_TOKEN (a token with "repository: Read and Write") when it
# exists, else the job's automatic token.
name: release
on:
push:
tags:
- "v*"
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
# release.sh reads the v* tag on HEAD and checks that HEAD is on origin/master
fetch-depth: 0
- uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1
with:
distribution: temurin
java-version: "25"
# The build runs without the token; only the publish step gets it.
- name: Build
run: ci/release.sh build
- name: Publish
env:
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITEA_TOKEN }}
run: ci/release.sh publish
+1
View File
@@ -2,6 +2,7 @@
!README.md !README.md
/lib /lib
.*/ .*/
!.gitea/
build/ build/
out/ out/
+20 -2
View File
@@ -18,8 +18,18 @@ Players keep the official, unmodified client; the mod runs on the server only.
## Installation ## Installation
1. Unpack `lua_mod_automator-<version>.zip` into `<forge>/mods/`, which gives 1. Download the newest release and unpack it into `<forge>/mods/`, which gives
`<forge>/mods/lua_mod_automator/`. `<forge>/mods/lua_mod_automator/`:
```shell
curl --fail --location --output lua_mod_automator.zip \
https://git.security-command.org/Overlord/LuaModAutomator/releases/download/latest/lua_mod_automator.zip
unzip -o lua_mod_automator.zip -d <forge>/mods/
```
Every release also carries `lua_mod_automator-<version>.zip` for a fixed version. To update,
remove `lua_mod_automator.jar` and `lib/` from the mod's folder first and unpack the new zip;
`config.toml` is not part of the zip and stays.
2. Create `<forge>/mods/lua_mod_automator/config.toml` with at least the collection: 2. Create `<forge>/mods/lua_mod_automator/config.toml` with at least the collection:
```toml ```toml
@@ -145,6 +155,9 @@ download (see ZomboidForge's mod development guide).
```shell ```shell
./gradlew build # compiles, tests, checks the mod against the game, and packs build/distributions/ ./gradlew build # compiles, tests, checks the mod against the game, and packs build/distributions/
./gradlew runServer # a ZomboidForge server in a container with the mod (default settings: idle) ./gradlew runServer # a ZomboidForge server in a container with the mod (default settings: idle)
# What a config.toml resolves to, the way the server does it at startup, without a server:
./gradlew -q resolveCollection --args=path/to/config.toml
``` ```
`runServer` mounts the mod read-only, so it runs with the default settings, in which the mod `runServer` mounts the mod read-only, so it runs with the default settings, in which the mod
@@ -152,6 +165,11 @@ is idle. To try it with a collection, copy `build/mod/lua_mod_automator/` into a
directory (or set `zomboidForge.deployDirectory` and run `./gradlew deployMod`) and add a directory (or set `zomboidForge.deployDirectory` and run `./gradlew deployMod`) and add a
`config.toml` there. `config.toml` there.
Pushing a tag `v<version>` that matches `version` in `build.gradle.kts` builds the mod and
publishes it as a release (`.gitea/workflows/release.yml`, `ci/release.sh`). Tags containing
`-` (e.g. `v0.2.0-rc.1`) and tags on commits that are not on `master` are built and tested but
not released.
## License ## License
[GNU Affero General Public License v3.0](LICENSE) [GNU Affero General Public License v3.0](LICENSE)
+9
View File
@@ -39,3 +39,12 @@ tasks.withType<JavaCompile>().configureEach {
tasks.test { tasks.test {
useJUnitPlatform() useJUnitPlatform()
} }
// Prints what the server would set for a config.toml: ./gradlew -q resolveCollection --args=<config.toml>
tasks.register<JavaExec>("resolveCollection") {
group = "zomboidforge"
description = "Resolves the collection of a config.toml like the server does at startup and prints Mods=, WorkshopItems=, and Map=."
classpath = sourceSets.test.get().runtimeClasspath
mainClass = "dev.overlord.luamodautomator.ResolveCollection"
workingDir = File(System.getProperty("user.dir"))
}
Executable
+225
View File
@@ -0,0 +1,225 @@
#!/usr/bin/env bash
#
# Builds the mod for the v* git tag on HEAD and publishes it as a Gitea release, with the zip
# attached twice: as lua_mod_automator-<version>.zip, and as lua_mod_automator.zip, the stable
# name behind <server>/<owner>/<repo>/releases/download/latest/lua_mod_automator.zip.
#
# A pre-release tag (containing "-", e.g. v0.2.0-rc.1), or a tag on a commit that is not on
# master, is built and tested but not released. The tag must match the version in
# build.gradle.kts.
#
# Usage:
# ci/release.sh build downloads the game jar and builds the mod (tests and checkMod included)
# ci/release.sh publish creates the release (or reuses the tag's release) and uploads the zip
#
# Environment:
# GAME_JAR projectzomboid.jar to build against (build); default: downloaded from
# the Steam branch PZ_BRANCH (default: public) with DepotDownloader
# GITEA_TOKEN token with write access to the repository's releases (publish)
# GITHUB_API_URL Gitea API, e.g. https://git.security-command.org/api/v1 (publish; set by Gitea Actions)
# GITHUB_REPOSITORY owner/repo (publish; set by Gitea Actions)
set -o errexit
set -o nounset
set -o pipefail
shopt -s inherit_errexit
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
readonly REPO_ROOT
readonly MOD_ID="lua_mod_automator"
readonly RELEASE_BRANCH="master"
readonly WORK_DIR="${REPO_ROOT}/build/ci"
# DepotDownloader downloads single files of a depot; steamcmd only whole apps. Same release
# and checksum as ZomboidForge's image build.
readonly DEPOT_DOWNLOADER_URL="https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_3.4.0/DepotDownloader-linux-x64.zip"
readonly DEPOT_DOWNLOADER_SHA256="a999dec66b4850fc961bd50366696d23c2d0fad7b18790e6a5647b2f19097a53"
# Project Zomboid Dedicated Server: app and its depot with java/projectzomboid.jar.
readonly PZ_APP="380870"
readonly PZ_DEPOT="380871"
log() {
echo "[release] $*" >&2
}
fail() {
log "$*"
exit 1
}
# Whether HEAD is on the release branch, as fetched from origin.
on_release_branch() {
git -C "${REPO_ROOT}" merge-base --is-ancestor HEAD "origin/${RELEASE_BRANCH}" 2> /dev/null
}
# Prints the v* tag on HEAD, or nothing.
release_tag() {
git -C "${REPO_ROOT}" describe --tags --exact-match --match 'v*' 2> /dev/null || true
}
run_gradle() {
"${REPO_ROOT}/gradlew" --no-daemon --console=plain --project-dir "${REPO_ROOT}" "$@"
}
project_version() {
run_gradle --quiet properties --property version | sed --quiet 's/^version: //p'
}
# Downloads java/projectzomboid.jar of the dedicated server and prints its path.
download_game_jar() {
local branch="${PZ_BRANCH:-public}"
local tools="${WORK_DIR}/depotdownloader"
local game="${WORK_DIR}/game"
mkdir --parents "${tools}" "${game}"
log "Downloading DepotDownloader"
curl --fail --silent --show-error --location --output "${tools}/depotdownloader.zip" "${DEPOT_DOWNLOADER_URL}"
echo "${DEPOT_DOWNLOADER_SHA256} ${tools}/depotdownloader.zip" | sha256sum --check --quiet
unzip -q -o "${tools}/depotdownloader.zip" -d "${tools}"
chmod +x "${tools}/DepotDownloader"
log "Downloading projectzomboid.jar of the Steam branch '${branch}'"
echo "java/projectzomboid.jar" > "${tools}/files"
"${tools}/DepotDownloader" -app "${PZ_APP}" -depot "${PZ_DEPOT}" -branch "${branch}" -filelist "${tools}/files" -dir "${game}" >&2
echo "${game}/java/projectzomboid.jar"
}
build() {
local tag="$1"
local version="${tag#v}"
local project
local game_jar="${GAME_JAR:-}"
project="$(project_version)"
if [[ "${project}" != "${version}" ]]; then
fail "The tag '${tag}' does not match the version '${project}' in build.gradle.kts."
fi
if [[ -z "${game_jar}" ]]; then
game_jar="$(download_game_jar)"
fi
log "Building ${MOD_ID} ${version} against '${game_jar}'"
run_gradle "-Pzomboidforge.gameJar=${game_jar}" build
}
# Calls the Gitea API; prints the response body. Extra arguments go to curl.
api() {
local method="$1"
local path="$2"
shift 2
curl --fail --silent --show-error \
--request "${method}" \
--header "Authorization: token ${GITEA_TOKEN}" \
--header "Accept: application/json" \
"$@" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}${path}"
}
# Prints the id of the tag's release, created when it does not exist yet.
release_id() {
local tag="$1"
local status
local body
status="$(curl --silent --output /dev/null --write-out '%{http_code}' \
--header "Authorization: token ${GITEA_TOKEN}" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${tag}")"
case "${status}" in
200)
log "Release '${tag}' exists; replacing its files"
api GET "/releases/tags/${tag}" | jq --raw-output '.id'
return
;;
404)
;;
*)
fail "Cannot read the releases of '${GITHUB_REPOSITORY}' (HTTP ${status}); is GITEA_TOKEN valid for it?"
;;
esac
body="$(jq --null-input \
--arg tag "${tag}" \
--arg name "Release ${tag} - Stable, Automated" \
--arg body "$(date --utc +%Y-%m-%d)"$'\n'"$(git -C "${REPO_ROOT}" rev-parse HEAD)" \
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')"
log "Creating release '${tag}'"
api POST "/releases" --header "Content-Type: application/json" --data "${body}" | jq --raw-output '.id'
}
# Uploads ${file} as ${name}, replacing an attached file of that name.
upload() {
local id="$1"
local file="$2"
local name="$3"
local existing
existing="$(api GET "/releases/${id}/assets" | jq --raw-output --arg name "${name}" '.[] | select(.name == $name) | .id')"
if [[ -n "${existing}" ]]; then
api DELETE "/releases/${id}/assets/${existing}" > /dev/null
fi
api POST "/releases/${id}/assets?name=${name}" --form "attachment=@${file}" > /dev/null
log "Attached '${name}'"
}
publish() {
local tag="$1"
local version="${tag#v}"
local zip="${REPO_ROOT}/build/distributions/${MOD_ID}-${version}.zip"
local id
if [[ "${version}" == *-* ]]; then
log "${tag} is a pre-release tag; nothing is released."
return
fi
if ! on_release_branch; then
log "${tag} is not on ${RELEASE_BRANCH}; nothing is released."
return
fi
: "${GITEA_TOKEN:?GITEA_TOKEN is not set}"
: "${GITHUB_API_URL:?GITHUB_API_URL is not set}"
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is not set}"
[[ -f "${zip}" ]] || fail "'${zip}' does not exist; run 'ci/release.sh build' first."
id="$(release_id "${tag}")"
upload "${id}" "${zip}" "${MOD_ID}-${version}.zip"
upload "${id}" "${zip}" "${MOD_ID}.zip"
log "Released ${tag}: ${GITHUB_SERVER_URL:-}/${GITHUB_REPOSITORY}/releases/tag/${tag}"
}
main() {
local step="${1:-}"
local tag
tag="$(release_tag)"
if [[ -z "${tag}" ]]; then
fail "HEAD has no v* git tag (not a release commit, or a shallow clone without tags?); nothing to release."
fi
case "${step}" in
build)
build "${tag}"
;;
publish)
publish "${tag}"
;;
*)
log "Usage: ci/release.sh build|publish"
exit 2
;;
esac
}
main "$@"
@@ -62,18 +62,23 @@ record Resolution(List<Resolution.Item> items, List<Resolution.Item> excluded, L
modIds = Math.max(modIds, Resolution.modIds(item).length()); modIds = Math.max(modIds, Resolution.modIds(item).length());
} }
lines.add("# Mod list"); lines.add("Mod List:");
for (int i = 0; i < this.items.size(); i++) for (int i = 0; i < this.items.size(); i++)
{ {
Item item = this.items.get(i); Item item = this.items.get(i);
lines.add(("# %" + number + "d. %-" + title + "s %10s %-" + modIds + "s").formatted(i + 1, item.title(), item.id(), Resolution.modIds(item)).stripTrailing()); //noinspection StringConcatenationInFormatCall
lines.add(
("%" + number + "d. %-" + title + "s %10s %-" + modIds + "s").formatted(
i + 1, item.title(), item.id(), Resolution.modIds(item)
).stripTrailing()
);
} }
if (!this.excluded.isEmpty()) if (!this.excluded.isEmpty())
{ {
lines.add("# Excluded"); lines.add("Excluded:");
for (Item item : this.excluded) lines.add("# %s %s".formatted(item.title(), item.id())); for (Item item : this.excluded) lines.add(" %s %s".formatted(item.title(), item.id()));
} }
return lines; return lines;
@@ -190,13 +190,13 @@ class CollectionResolverTest
List<String> modList = CollectionResolver.resolve(CollectionResolverTest.COLLECTION, CollectionResolverTest.DEFAULT_ORDER, items).modList(); List<String> modList = CollectionResolver.resolve(CollectionResolverTest.COLLECTION, CollectionResolverTest.DEFAULT_ORDER, items).modList();
assertEquals(List.of( assertEquals(List.of(
"# Mod list", "Mod List:",
"# 1. A Map 300 MapMod", "1. A Map 300 MapMod",
"# 2. Framework 200 Frame", "2. Framework 200 Frame",
"# 3. Misc One 100 MiscOne", "3. Misc One 100 MiscOne",
"# 4. Misc Two 400 MiscTwo, MiscTwoExtra", "4. Misc Two 400 MiscTwo, MiscTwoExtra",
"# Excluded", "Excluded:",
"# Misc Three 500" " Misc Three 500"
), modList); ), modList);
} }
@@ -0,0 +1,70 @@
package dev.overlord.luamodautomator;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
/**
* Resolves a collection like the server does at startup, without the server: binds the shipped
* defaults with a {@code config.toml} on top, asks Steam, and prints the mod list,
* {@code Mods=}, {@code WorkshopItems=}, {@code Map=}, and every warning. Run through
* {@code ./gradlew resolveCollection --args=<config.toml>}.
*/
public final class ResolveCollection
{
private ResolveCollection() {}
public static void main(String[] args) throws IOException
{
if (args.length != 1)
{
System.err.println("Usage: ./gradlew resolveCollection --args=<config.toml>");
System.exit(2);
}
Path config = Path.of(args[0]);
if (!Files.isRegularFile(config))
{
System.err.println("'" + config.toAbsolutePath() + "' does not exist.");
System.exit(1);
}
List<String> warnings = new ArrayList<>();
Settings settings = SettingsTest.bind(Files.readString(config, StandardCharsets.UTF_8), warnings);
String id = SteamWorkshopApi.collectionId(settings.collection()).orElse("");
if (id.isEmpty())
{
System.err.println("'collection' in '" + args[0] + "' holds no collection id.");
System.exit(1);
}
try (SteamWorkshopApi api = new SteamWorkshopApi(SteamWorkshopApi.BASE, Duration.ofSeconds(settings.steam().timeoutS()), "LuaModAutomator/resolveCollection"))
{
Resolution resolution = CollectionResolver.resolve(api.collection(id, warnings), settings.order(), settings.items());
ServerValues values = resolution.values(settings.ini().baseMap());
warnings.addAll(resolution.warnings());
resolution.modList().forEach(System.out::println);
System.out.println();
System.out.println("Mods=" + values.mods());
System.out.println();
System.out.println("WorkshopItems=" + values.workshopItems());
System.out.println();
System.out.println("Map=" + values.map());
for (String warning : warnings) System.err.println("WARNING: " + warning);
}
catch (SteamException | ConfigurationException e)
{
System.err.println(e.getMessage());
System.exit(1);
}
}
}
@@ -109,9 +109,9 @@ class SteamWorkshopApiTest
Settings settings = SettingsTest.bind(""); Settings settings = SettingsTest.bind("");
Resolution resolution = CollectionResolver.resolve(this.api.collection(SteamWorkshopApiTest.recordedId(), new ArrayList<>()), settings.order(), settings.items()); Resolution resolution = CollectionResolver.resolve(this.api.collection(SteamWorkshopApiTest.recordedId(), new ArrayList<>()), settings.order(), settings.items());
ServerValues values = resolution.values(settings.ini().baseMap()); ServerValues values = resolution.values(settings.ini().baseMap());
List<String> expected = SteamWorkshopApiTest.resource("script-output.txt").lines().toList(); List<String> expected = SteamWorkshopApiTest.withoutCommentPrefix(SteamWorkshopApiTest.resource("script-output.txt").lines().toList());
List<String> actual = new ArrayList<>(resolution.modList()); List<String> actual = new ArrayList<>(resolution.modList().subList(1, resolution.modList().size()));
actual.add("Mods=" + values.mods()); actual.add("Mods=" + values.mods());
actual.add("WorkshopItems=" + values.workshopItems()); actual.add("WorkshopItems=" + values.workshopItems());
@@ -207,6 +207,9 @@ class SteamWorkshopApiTest
assertFalse(items.get(0).found()); assertFalse(items.get(0).found());
} }
/** The script's output without its mod list header, and the mod list lines without their {@code "# "}. */
private static List<String> withoutCommentPrefix(List<String> output) { return output.stream().skip(1).map(line -> line.startsWith("# ") ? line.substring(2) : line).toList(); }
/** Details for every even id of the request: title {@code Item <id>}, Mod ID {@code Mod<id>}. */ /** Details for every even id of the request: title {@code Item <id>}, Mod ID {@code Mod<id>}. */
private static Response details(Map<String, String> form) private static Response details(Map<String, String> form)
{ {