4 Commits
Author SHA1 Message Date
Overlord 322092729f Merge tag 'v0.1.0-dev' into develop
Tagging version v0.1.0-dev v0.1.0-dev
2026-10-03 20:38:49 +02:00
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 8484d6c20c Merge tag 'v0.1.0' into develop
Tagging version v0.1.0 v0.1.0
2026-10-03 18:36:43 +02:00
8 changed files with 122 additions and 18 deletions

No files matched your search

+3 -2
View File
@@ -1,6 +1,7 @@
# Builds the mod for every v* tag and publishes it as a release with lua_mod_automator.zip # 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. # attached, so .../releases/download/latest/lua_mod_automator.zip always serves the newest one.
# Pre-release tags (containing "-") are built and tested but not released (see ci/release.sh). # 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 # Uses the repository secret RELEASE_TOKEN (a token with "repository: Read and Write") when it
# exists, else the job's automatic token. # exists, else the job's automatic token.
name: release name: release
@@ -16,7 +17,7 @@ jobs:
steps: steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with: with:
# release.sh reads the v* tag on HEAD # release.sh reads the v* tag on HEAD and checks that HEAD is on origin/master
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 - uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1
+5 -1
View File
@@ -155,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
@@ -164,7 +167,8 @@ directory (or set `zomboidForge.deployDirectory` and run `./gradlew deployMod`)
Pushing a tag `v<version>` that matches `version` in `build.gradle.kts` builds the mod and 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 publishes it as a release (`.gitea/workflows/release.yml`, `ci/release.sh`). Tags containing
`-` (e.g. `v0.2.0-rc.1`) are built and tested but not released. `-` (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
+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"))
}
+14 -2
View File
@@ -4,8 +4,9 @@
# attached twice: as lua_mod_automator-<version>.zip, and as lua_mod_automator.zip, the stable # 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. # name behind <server>/<owner>/<repo>/releases/download/latest/lua_mod_automator.zip.
# #
# A pre-release tag (containing "-", e.g. v0.2.0-rc.1) is built and tested but not released. # A pre-release tag (containing "-", e.g. v0.2.0-rc.1), or a tag on a commit that is not on
# The tag must match the version in build.gradle.kts. # master, is built and tested but not released. The tag must match the version in
# build.gradle.kts.
# #
# Usage: # Usage:
# ci/release.sh build downloads the game jar and builds the mod (tests and checkMod included) # ci/release.sh build downloads the game jar and builds the mod (tests and checkMod included)
@@ -27,6 +28,7 @@ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
readonly REPO_ROOT readonly REPO_ROOT
readonly MOD_ID="lua_mod_automator" readonly MOD_ID="lua_mod_automator"
readonly RELEASE_BRANCH="master"
readonly WORK_DIR="${REPO_ROOT}/build/ci" readonly WORK_DIR="${REPO_ROOT}/build/ci"
# DepotDownloader downloads single files of a depot; steamcmd only whole apps. Same release # DepotDownloader downloads single files of a depot; steamcmd only whole apps. Same release
@@ -47,6 +49,11 @@ fail() {
exit 1 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. # Prints the v* tag on HEAD, or nothing.
release_tag() { release_tag() {
git -C "${REPO_ROOT}" describe --tags --exact-match --match 'v*' 2> /dev/null || true git -C "${REPO_ROOT}" describe --tags --exact-match --match 'v*' 2> /dev/null || true
@@ -174,6 +181,11 @@ publish() {
return return
fi 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}" : "${GITEA_TOKEN:?GITEA_TOKEN is not set}"
: "${GITHUB_API_URL:?GITHUB_API_URL is not set}" : "${GITHUB_API_URL:?GITHUB_API_URL is not set}"
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is not set}" : "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is not set}"
@@ -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)
{ {