Prepare for version 0.9 (#8)
Foundry VTT System Release / build-and-release (push) Failing after 3m47s
Foundry VTT System Release / build-and-release (push) Failing after 3m47s
Reviewed-on: #8 Co-authored-by: Byroks <byroks@gmail.com>
This commit was merged in pull request #8.
This commit is contained in:
1 parent
9568be0211
commit
49b8eddf15
84 files changed
+8046
-468
No files matched your search
@@ -0,0 +1,64 @@
|
||||
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)
|
||||
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");
|
||||
|
||||
// 1. system.json einlesen und Update-Pfade für Foundry patchen
|
||||
const systemJson = JSON.parse(fs.readFileSync(systemJsonPath, "utf8"));
|
||||
|
||||
// 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", "");
|
||||
}
|
||||
|
||||
// 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`;
|
||||
|
||||
// Modifizierte system.json zurückschreiben
|
||||
fs.writeFileSync(systemJsonPath, JSON.stringify(systemJson, null, 2));
|
||||
console.log(`✅ system.json erfolgreich für Version ${systemJson.version} aktualisiert.`);
|
||||
|
||||
// 2. zip-Archiv für Foundry erstellen
|
||||
async function zipDirectory(sourceDir, outPath) {
|
||||
const archive = archiver("zip", { zlib: { level: 9 } });
|
||||
const stream = fs.createWriteStream(outPath);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
archive
|
||||
.directory(sourceDir, false)
|
||||
.on("error", (err) => reject(err))
|
||||
.pipe(stream);
|
||||
|
||||
stream.on("close", () => resolve());
|
||||
archive.finalize();
|
||||
});
|
||||
}
|
||||
|
||||
// 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"];
|
||||
|
||||
const distDir = path.resolve("./dist");
|
||||
if (!fs.existsSync(distDir)) fs.mkdirSync(distDir);
|
||||
|
||||
for (const file of filesToInclude) {
|
||||
if (fs.existsSync(file)) {
|
||||
const dest = path.join(distDir, file);
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
if (fs.lstatSync(file).isDirectory()) {
|
||||
fs.cpSync(file, dest, { recursive: true });
|
||||
} else {
|
||||
fs.copyFileSync(file, dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await zipDirectory(distDir, "./system.zip");
|
||||
console.log("✅ system.zip wurde erfolgreich generiert.");
|
||||
Reference in new issue
Block a user