Adjust release
Foundry VTT System Release / build-and-release (push) Failing after 3m57s

This commit is contained in:
Byroks committed 2026-10-26 19:20:02 +01:00
1 parent 49b8eddf15
commit 930e188202
4 files changed
+57 -25

No files matched your search

+53 -21
View File
@@ -2,30 +2,48 @@ import fs from "fs";
import path from "path";
import archiver from "archiver";
// Pfade definieren (Passe an, falls dein Gitea-Benutzer/Repo-Name anders heißt)
// Pfade definieren
const GITEA_URL = process.env.GITEA_URL;
const REPO = process.env.GITEA_REPOSITORY;
const RELEASE_TAG = process.env.GITEA_REF_NAME || "v1.0.0";
const systemJsonPath = path.resolve("./system.json");
const packageJsonPath = path.resolve("./package.json");
// 1. system.json einlesen und Update-Pfade für Foundry patchen
const systemJson = JSON.parse(fs.readFileSync(systemJsonPath, "utf8"));
// Version aus dem Tag extrahieren (z.B. "v1.2.3" -> "1.2.3")
const cleanVersion = RELEASE_TAG.replace(/^v/, "");
// Wenn das Script über ein Tag läuft, nehmen wir das Tag ohne das "v" als Versionsnummer
if (process.env.GITEA_REF_TYPE === "tag") {
systemJson.version = RELEASE_TAG.replace("v", "");
// 1. system.json aktualisieren
if (fs.existsSync(systemJsonPath)) {
const systemJson = JSON.parse(fs.readFileSync(systemJsonPath, "utf8"));
systemJson.version = cleanVersion;
systemJson.manifest = `${GITEA_URL}/api/v1/repos/${REPO}/raw/system.json`;
systemJson.download = `${GITEA_URL}/api/v1/repos/${REPO}/releases/download/${RELEASE_TAG}/system.zip`;
fs.writeFileSync(systemJsonPath, JSON.stringify(systemJson, null, 2));
console.log(
`\x1b[32m✅ system.json erfolgreich auf Version ${cleanVersion} aktualisiert.\x1b[0m`
);
} else {
console.error(`\x1b[31m❌ system.json nicht gefunden unter: ${systemJsonPath}\x1b[0m`);
}
// Update-URLs dynamisch generieren
systemJson.manifest = `${GITEA_URL}/api/v1/repos/${REPO}/raw/system.json`;
systemJson.download = `${GITEA_URL}/api/v1/repos/${REPO}/releases/download/${RELEASE_TAG}/system.zip`;
// 2. package.json aktualisieren
if (fs.existsSync(packageJsonPath)) {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
// Modifizierte system.json zurückschreiben
fs.writeFileSync(systemJsonPath, JSON.stringify(systemJson, null, 2));
console.log(`✅ system.json erfolgreich für Version ${systemJson.version} aktualisiert.`);
packageJson.version = cleanVersion;
// 2. zip-Archiv für Foundry erstellen
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log(
`\x1b[32m✅ package.json erfolgreich auf Version ${cleanVersion} aktualisiert.\x1b[0m`
);
} else {
console.log(`\x1b[33m⚠️ package.json nicht gefunden – Schritt übersprungen.\x1b[0m`);
}
// 3. zip-Archiv für Foundry erstellen
async function zipDirectory(sourceDir, outPath) {
const archive = archiver("zip", { zlib: { level: 9 } });
const stream = fs.createWriteStream(outPath);
@@ -41,16 +59,26 @@ async function zipDirectory(sourceDir, outPath) {
});
}
// Kopiert wichtige Dateien in einen temporären Build-Ordner (dist) und zippt ihn
// Passe die Liste an, je nachdem was in deiner system.zip landen muss!
const filesToInclude = ["src/system.json", "templates", "dist", "lang", "assets"];
// Name auf "build-zip" geändert, um Konflikte mit Vites "dist"-Ordner zu vermeiden!
const zipTmpDir = path.resolve("./build-zip");
const distDir = path.resolve("./dist");
if (!fs.existsSync(distDir)) fs.mkdirSync(distDir);
if (fs.existsSync(zipTmpDir)) {
fs.rmSync(zipTmpDir, { recursive: true, force: true });
}
fs.mkdirSync(zipTmpDir);
// Passe diese Liste an! Da Vite in "dist" baut, müssen die Pfade eventuell dorthin zeigen
// Beispiel: Wenn dein CSS in dist/styles/M6.css liegt, schreibe 'dist/styles/M6.css' in die Liste.
const filesToInclude = [
"src/system.json",
"template",
"dist", // Kopiert den gesamten Inhalt deines echten Vite-Build-Ordners mit in die Zip!
"lang"
];
for (const file of filesToInclude) {
if (fs.existsSync(file)) {
const dest = path.join(distDir, file);
const dest = path.join(zipTmpDir, file);
fs.mkdirSync(path.dirname(dest), { recursive: true });
if (fs.lstatSync(file).isDirectory()) {
fs.cpSync(file, dest, { recursive: true });
@@ -60,5 +88,9 @@ for (const file of filesToInclude) {
}
}
await zipDirectory(distDir, "./system.zip");
console.log("✅ system.zip wurde erfolgreich generiert.");
// Wir zippen jetzt den sicheren "build-zip" Ordner
await zipDirectory(zipTmpDir, "./system.zip");
console.log("\x1b[32m✅ system.zip wurde erfolgreich generiert.\x1b[0m");
// Optional: Den temporären Ordner nach dem Zippen wieder aufräumen
fs.rmSync(zipTmpDir, { recursive: true, force: true });