Allow Skipping Changelog Generation, Fix Lang Zips (#1020)

[EXPAND]
messageTitle = "Fix Lang Zips & Cleanup `pack.mcmeta`"
messageBody = "[INTERNAL]"
[EXPAND]
This commit is contained in:
Integer Limit 2024-10-03 14:49:53 +10:00 committed by GitHub
parent da5ebbb304
commit 8388e12cc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 130 additions and 61 deletions

View File

@ -34,9 +34,14 @@ on:
required: false required: false
type: string type: string
separate_upload: separate_upload:
description: Whether to uploaed each zip (Client, Server, Lang) and the changelogs seperately. If not set, will just upload all six files into one artifact (Built Pack). description: Whether to upload each zip (Client, Server, Lang) and the changelogs seperately. If not set, will just upload all six files into one artifact (Built Pack).
required: true required: true
type: boolean type: boolean
skip_changelog:
description: Whether to skip changelog generation.
type: boolean
default: false
required: true
workflow_call: workflow_call:
inputs: inputs:
@ -66,7 +71,7 @@ on:
required: false required: false
type: string type: string
separate_upload: separate_upload:
description: Whether to uploaed each zip (Client, Server & Lang) and the changelogs seperately. If not set, will just upload all five files into one artifact (Built Pack). description: Whether to upload each zip (Client, Server & Lang) and the changelogs seperately. If not set, will just upload all five files into one artifact (Built Pack).
required: false required: false
default: false default: false
type: boolean type: boolean
@ -76,12 +81,18 @@ on:
true_sha: true_sha:
type: string type: string
required: false required: false
skip_changelog:
description: Whether to skip changelog generation.
type: boolean
default: false
required: false
env: env:
GITHUB_TAG: ${{ inputs.tag }} GITHUB_TAG: ${{ inputs.tag }}
RELEASE_TYPE: ${{ inputs.release_type }} RELEASE_TYPE: ${{ inputs.release_type }}
HEAD_REF: ${{ inputs.head_ref }} HEAD_REF: ${{ inputs.head_ref }}
TRUE_SHA: ${{ inputs.true_sha }} TRUE_SHA: ${{ inputs.true_sha }}
SKIP_CHANGELOG: ${{ inputs.skip_changelog }}
jobs: jobs:
buildSingle: buildSingle:
@ -396,6 +407,7 @@ jobs:
compression-level: 9 compression-level: 9
- name: Upload Changelogs - name: Upload Changelogs
if: ${{ !inputs.skip_changelog }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: Changelogs name: Changelogs

View File

@ -29,6 +29,7 @@ env:
HEAD_REF: ${{ github.head_ref }} HEAD_REF: ${{ github.head_ref }}
HEAD_REPO: ${{ github.event.pull_request.head.repo.owner.login }} HEAD_REPO: ${{ github.event.pull_request.head.repo.owner.login }}
TRUE_SHA: ${{ github.event.pull_request.head.sha }} TRUE_SHA: ${{ github.event.pull_request.head.sha }}
SKIP_CHANGELOG: true
jobs: jobs:
setup: setup:
@ -42,7 +43,7 @@ jobs:
server: ${{ steps.artifactNames.outputs.server }} server: ${{ steps.artifactNames.outputs.server }}
lang: ${{ steps.artifactNames.outputs.lang }} lang: ${{ steps.artifactNames.outputs.lang }}
mmc: ${{ steps.artifactNames.outputs.mmc }} mmc: ${{ steps.artifactNames.outputs.mmc }}
steps: steps:
- name: Checkout Ref - name: Checkout Ref
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -96,7 +97,7 @@ jobs:
run: npm run gulp buildClient run: npm run gulp buildClient
env: env:
CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }}
- name: Upload Client Zip - name: Upload Client Zip
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
@ -144,7 +145,7 @@ jobs:
compression-level: 9 compression-level: 9
buildLang: buildLang:
name: Build Fork PR Lang and Changelogs (${{ github.event.pull_request.head.sha }}) name: Build Fork PR Lang (${{ github.event.pull_request.head.sha }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: setup needs: setup
steps: steps:
@ -167,7 +168,7 @@ jobs:
working-directory: ./tools working-directory: ./tools
run: npm ci run: npm ci
- name: Build Lang and Changelogs - name: Build Lang
working-directory: ./tools working-directory: ./tools
run: npm run gulp buildLang run: npm run gulp buildLang
env: env:
@ -180,11 +181,3 @@ jobs:
path: ./build/lang/**/* path: ./build/lang/**/*
if-no-files-found: error if-no-files-found: error
compression-level: 9 compression-level: 9
- name: Upload Changelogs
uses: actions/upload-artifact@v4
with:
name: Changelogs
path: ./build/*.md
if-no-files-found: error
compression-level: 9

View File

@ -12,12 +12,16 @@ on:
pull_request: pull_request:
paths-ignore: paths-ignore:
- "README.md" - "README.md"
types:
- opened
- reopened
- synchronize
# if a second commit is pushed quickly after the first, cancel the first one's build # if a second commit is pushed quickly after the first, cancel the first one's build
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
build: build:
# Only allow runs from commits to Nomi-CEu Branches or from pull requests from Nomi-CEu repo without dev/ (That is handled by push) # Only allow runs from commits to Nomi-CEu Branches or from pull requests from Nomi-CEu repo without dev/ (That is handled by push)
@ -28,5 +32,5 @@ jobs:
separate_upload: true separate_upload: true
head_ref: ${{ github.head_ref }} head_ref: ${{ github.head_ref }}
true_sha: ${{ github.event.pull_request.head.sha }} true_sha: ${{ github.event.pull_request.head.sha }}
skip_changelog: ${{ github.event.pull_request != null }}
secrets: inherit secrets: inherit

View File

@ -1 +1,6 @@
{"pack":{"pack_format":3,"description":"B.A.S.E External Resources"}} {
"pack": {
"pack_format": 3,
"description": "Default Nomi-CEu Texture and Language Resources"
}
}

View File

@ -10,7 +10,7 @@ import buildConfig from "#buildConfig";
import { deleteAsync } from "del"; import { deleteAsync } from "del";
import { createModList, ModFileInfo } from "../misc/createModList.ts"; import { createModList, ModFileInfo } from "../misc/createModList.ts";
import dedent from "dedent-js"; import dedent from "dedent-js";
import { cleanupVersion } from "#utils/util.ts"; import { cleanupVersion, shouldSkipChangelog } from "#utils/util.ts";
async function clientCleanUp() { async function clientCleanUp() {
return deleteAsync(upath.join(clientDestDirectory, "*"), { force: true }); return deleteAsync(upath.join(clientDestDirectory, "*"), { force: true });
@ -70,7 +70,7 @@ async function copyClientLicense() {
/** /**
* Copies the update notes file. * Copies the update notes file.
*/ */
function copyClientUpdateNotes() { async function copyClientUpdateNotes() {
return src("../UPDATENOTES.md", { allowEmpty: true }).pipe( return src("../UPDATENOTES.md", { allowEmpty: true }).pipe(
dest(clientDestDirectory), dest(clientDestDirectory),
); );
@ -79,7 +79,9 @@ function copyClientUpdateNotes() {
/** /**
* Copies the changelog file. * Copies the changelog file.
*/ */
function copyClientChangelog() { async function copyClientChangelog() {
if (shouldSkipChangelog()) return;
return src( return src(
upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"), upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"),
).pipe(dest(clientDestDirectory)); ).pipe(dest(clientDestDirectory));
@ -88,7 +90,7 @@ function copyClientChangelog() {
/** /**
* Copies modpack overrides. * Copies modpack overrides.
*/ */
function copyClientOverrides() { async function copyClientOverrides() {
return src(buildConfig.copyFromSharedClientGlobs, { return src(buildConfig.copyFromSharedClientGlobs, {
cwd: sharedDestDirectory, cwd: sharedDestDirectory,
allowEmpty: true, allowEmpty: true,

View File

@ -1,6 +1,4 @@
import gulp from "gulp"; import { dest, series, src } from "gulp";
import rename from "gulp-rename";
import merge from "merge-stream";
import upath from "upath"; import upath from "upath";
import buildConfig from "#buildConfig"; import buildConfig from "#buildConfig";
import { import {
@ -9,6 +7,18 @@ import {
sharedDestDirectory, sharedDestDirectory,
} from "#globals"; } from "#globals";
import fs from "fs"; import fs from "fs";
import { deleteAsync } from "del";
import { shouldSkipChangelog } from "#utils/util.ts";
const resourcesPath = upath.join(
sharedDestDirectory,
overridesFolder,
"resources",
);
async function langCleanUp() {
return deleteAsync(upath.join(langDestDirectory, "*"), { force: true });
}
/** /**
* Checks and creates all necessary directories so we can build the lang safely. * Checks and creates all necessary directories so we can build the lang safely.
@ -19,32 +29,51 @@ async function createLangDirs() {
} }
} }
async function copyLang() { /**
const resourcesPath = upath.join( * Copies the license file.
sharedDestDirectory, */
overridesFolder, async function copyLangLicense() {
"resources", return src("../LICENSE").pipe(dest(langDestDirectory));
);
const opts = { base: resourcesPath, resolveSymlinks: true };
const streams = [
gulp.src(upath.join(resourcesPath, "pack.mcmeta"), opts),
gulp.src(upath.join(resourcesPath, "**/*.lang"), opts).pipe(
rename((f) => {
f.dirname = upath.join("assets", f.dirname);
}),
),
];
return await new Promise((resolve) => {
merge(...streams)
.pipe(
gulp.dest(
upath.join(buildConfig.buildDestinationDirectory, langDestDirectory),
),
)
.on("end", resolve);
});
} }
export default gulp.series(createLangDirs, copyLang); /**
* Copies the update notes file.
*/
async function copyLangUpdateNotes() {
return src("../UPDATENOTES.md", { allowEmpty: true }).pipe(
dest(langDestDirectory),
);
}
/**
* Copies the changelog file.
*/
async function copyLangChangelog() {
if (shouldSkipChangelog()) return;
return src(
upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"),
).pipe(dest(langDestDirectory));
}
async function copyLangFiles() {
return src(upath.join("**", "*.lang"), { cwd: resourcesPath }).pipe(
dest(upath.join(langDestDirectory, "assets")),
);
}
async function copyLangMcMeta() {
return src("pack.mcmeta", { cwd: resourcesPath }).pipe(
dest(upath.join(langDestDirectory)),
);
}
export default series(
langCleanUp,
createLangDirs,
copyLangFiles,
copyLangMcMeta,
copyLangLicense,
copyLangChangelog,
copyLangUpdateNotes,
);

View File

@ -8,6 +8,7 @@ import * as upath from "upath";
import * as fs from "fs"; import * as fs from "fs";
import { dest, series, src } from "gulp"; import { dest, series, src } from "gulp";
import buildConfig from "#buildConfig"; import buildConfig from "#buildConfig";
import { shouldSkipChangelog } from "#utils/util.ts";
async function mmcCleanUp() { async function mmcCleanUp() {
if (fs.existsSync(mmcDestDirectory)) { if (fs.existsSync(mmcDestDirectory)) {
@ -27,7 +28,7 @@ async function createMMCDirs() {
/** /**
* Copies the update notes file. * Copies the update notes file.
*/ */
function copyMMCUpdateNotes() { async function copyMMCUpdateNotes() {
return src("../UPDATENOTES.md", { allowEmpty: true }).pipe( return src("../UPDATENOTES.md", { allowEmpty: true }).pipe(
dest(mmcDestDirectory), dest(mmcDestDirectory),
); );
@ -43,7 +44,9 @@ async function copyMMCLicense() {
/** /**
* Copies the changelog file. * Copies the changelog file.
*/ */
function copyMMCChangelog() { async function copyMMCChangelog() {
if (shouldSkipChangelog()) return;
return src( return src(
upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"), upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"),
).pipe(dest(mmcDestDirectory)); ).pipe(dest(mmcDestDirectory));
@ -52,7 +55,7 @@ function copyMMCChangelog() {
/** /**
* Copies modpack overrides. * Copies modpack overrides.
*/ */
function copyOverrides() { async function copyOverrides() {
return src(upath.join(clientDestDirectory, "**/*"), { return src(upath.join(clientDestDirectory, "**/*"), {
resolveSymlinks: false, resolveSymlinks: false,
}).pipe(dest(upath.join(mmcDestDirectory))); }).pipe(dest(upath.join(mmcDestDirectory)));

View File

@ -11,6 +11,7 @@ import {
downloadOrRetrieveFileDef, downloadOrRetrieveFileDef,
getForgeJar, getForgeJar,
getVersionManifest, getVersionManifest,
shouldSkipChangelog,
} from "#utils/util.ts"; } from "#utils/util.ts";
import { import {
modDestDirectory, modDestDirectory,
@ -182,7 +183,7 @@ async function copyServerMods() {
/** /**
* Copies modpack overrides. * Copies modpack overrides.
*/ */
function copyServerOverrides() { async function copyServerOverrides() {
return src(buildConfig.copyFromSharedServerGlobs, { return src(buildConfig.copyFromSharedServerGlobs, {
cwd: sharedDestDirectory, cwd: sharedDestDirectory,
allowEmpty: true, allowEmpty: true,
@ -194,7 +195,7 @@ function copyServerOverrides() {
/** /**
* Copies files from ./serverfiles into dest folder. * Copies files from ./serverfiles into dest folder.
*/ */
function copyServerFiles() { async function copyServerFiles() {
return src(["../serverfiles/**"], { return src(["../serverfiles/**"], {
encoding: false, // Needed because of the Server Icon encoding: false, // Needed because of the Server Icon
}).pipe(dest(serverDestDirectory)); }).pipe(dest(serverDestDirectory));
@ -203,14 +204,14 @@ function copyServerFiles() {
/** /**
* Copies the license file. * Copies the license file.
*/ */
function copyServerLicense() { async function copyServerLicense() {
return src("../LICENSE").pipe(dest(serverDestDirectory)); return src("../LICENSE").pipe(dest(serverDestDirectory));
} }
/** /**
* Copies the update notes file. * Copies the update notes file.
*/ */
function copyServerUpdateNotes() { async function copyServerUpdateNotes() {
return src("../UPDATENOTES.md", { allowEmpty: true }).pipe( return src("../UPDATENOTES.md", { allowEmpty: true }).pipe(
dest(serverDestDirectory), dest(serverDestDirectory),
); );
@ -219,7 +220,9 @@ function copyServerUpdateNotes() {
/** /**
* Copies the changelog file. * Copies the changelog file.
*/ */
function copyServerChangelog() { async function copyServerChangelog() {
if (shouldSkipChangelog()) return;
return src( return src(
upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"), upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"),
).pipe(dest(serverDestDirectory)); ).pipe(dest(serverDestDirectory));
@ -230,7 +233,7 @@ function copyServerChangelog() {
* *
* Replaces jvmArgs, minRAM, maxRAM and forgeJar. * Replaces jvmArgs, minRAM, maxRAM and forgeJar.
*/ */
function processLaunchscripts() { async function processLaunchscripts() {
const rules = { const rules = {
jvmArgs: buildConfig.launchscriptsJVMArgs, jvmArgs: buildConfig.launchscriptsJVMArgs,
minRAM: buildConfig.launchscriptsMinRAM, minRAM: buildConfig.launchscriptsMinRAM,

View File

@ -16,6 +16,7 @@ import {
downloadFileDef, downloadFileDef,
downloadOrRetrieveFileDef, downloadOrRetrieveFileDef,
isEnvVariableSet, isEnvVariableSet,
shouldSkipChangelog,
} from "#utils/util.ts"; } from "#utils/util.ts";
import transformVersion from "./transformVersion.ts"; import transformVersion from "./transformVersion.ts";
import { createBuildChangelog } from "../changelog/index.ts"; import { createBuildChangelog } from "../changelog/index.ts";
@ -112,9 +113,11 @@ async function fetchExternalDependencies() {
} }
/** /**
* Either fetches the Changelog File, or makes one. * Either fetches the Changelog File, or makes one. Does nothing if 'SKIP_CHANGELOG' is set to a truthy value.
*/ */
async function fetchOrMakeChangelog() { async function fetchOrMakeChangelog() {
if (shouldSkipChangelog()) return;
if ( if (
isEnvVariableSet("CHANGELOG_URL") && isEnvVariableSet("CHANGELOG_URL") &&
isEnvVariableSet("CHANGELOG_CF_URL") isEnvVariableSet("CHANGELOG_CF_URL")

View File

@ -870,3 +870,18 @@ export function getUniqueToArray<T>(
arr2Unique: lodash.difference(arr2, arr1), arr2Unique: lodash.difference(arr2, arr1),
}; };
} }
export function shouldSkipChangelog(): boolean {
if (!isEnvVariableSet("SKIP_CHANGELOG")) return false;
let skip = false;
try {
skip = JSON.parse((process.env.SKIP_CHANGELOG ?? "false").toLowerCase());
} catch (err) {
throw new Error("Skip Changelog Env Variable set to Invalid Value.");
}
if (skip)
logInfo("Skipping Changelogs...");
return skip;
}