diff --git a/.github/workflows/buildpack.yml b/.github/workflows/buildpack.yml index af76772..441c81e 100644 --- a/.github/workflows/buildpack.yml +++ b/.github/workflows/buildpack.yml @@ -34,9 +34,14 @@ on: required: false type: string 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 type: boolean + skip_changelog: + description: Whether to skip changelog generation. + type: boolean + default: false + required: true workflow_call: inputs: @@ -66,7 +71,7 @@ on: required: false type: string 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 default: false type: boolean @@ -76,12 +81,18 @@ on: true_sha: type: string required: false + skip_changelog: + description: Whether to skip changelog generation. + type: boolean + default: false + required: false env: GITHUB_TAG: ${{ inputs.tag }} RELEASE_TYPE: ${{ inputs.release_type }} HEAD_REF: ${{ inputs.head_ref }} TRUE_SHA: ${{ inputs.true_sha }} + SKIP_CHANGELOG: ${{ inputs.skip_changelog }} jobs: buildSingle: @@ -396,6 +407,7 @@ jobs: compression-level: 9 - name: Upload Changelogs + if: ${{ !inputs.skip_changelog }} uses: actions/upload-artifact@v4 with: name: Changelogs diff --git a/.github/workflows/forkprbuildpack.yml b/.github/workflows/forkprbuildpack.yml index fcb73bd..aedf13c 100644 --- a/.github/workflows/forkprbuildpack.yml +++ b/.github/workflows/forkprbuildpack.yml @@ -29,6 +29,7 @@ env: HEAD_REF: ${{ github.head_ref }} HEAD_REPO: ${{ github.event.pull_request.head.repo.owner.login }} TRUE_SHA: ${{ github.event.pull_request.head.sha }} + SKIP_CHANGELOG: true jobs: setup: @@ -42,7 +43,7 @@ jobs: server: ${{ steps.artifactNames.outputs.server }} lang: ${{ steps.artifactNames.outputs.lang }} mmc: ${{ steps.artifactNames.outputs.mmc }} - steps: + steps: - name: Checkout Ref uses: actions/checkout@v4 with: @@ -96,7 +97,7 @@ jobs: run: npm run gulp buildClient env: CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} - + - name: Upload Client Zip uses: actions/upload-artifact@v4 with: @@ -144,7 +145,7 @@ jobs: compression-level: 9 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 needs: setup steps: @@ -167,7 +168,7 @@ jobs: working-directory: ./tools run: npm ci - - name: Build Lang and Changelogs + - name: Build Lang working-directory: ./tools run: npm run gulp buildLang env: @@ -180,11 +181,3 @@ jobs: path: ./build/lang/**/* if-no-files-found: error 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 diff --git a/.github/workflows/testbuildpack.yml b/.github/workflows/testbuildpack.yml index aa4f03f..07b6a0e 100644 --- a/.github/workflows/testbuildpack.yml +++ b/.github/workflows/testbuildpack.yml @@ -12,12 +12,16 @@ on: pull_request: paths-ignore: - "README.md" + types: + - opened + - reopened + - synchronize # if a second commit is pushed quickly after the first, cancel the first one's build concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - + jobs: 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) @@ -28,5 +32,5 @@ jobs: separate_upload: true head_ref: ${{ github.head_ref }} true_sha: ${{ github.event.pull_request.head.sha }} + skip_changelog: ${{ github.event.pull_request != null }} secrets: inherit - diff --git a/overrides/resources/pack.mcmeta b/overrides/resources/pack.mcmeta index 0a7d879..a083168 100644 --- a/overrides/resources/pack.mcmeta +++ b/overrides/resources/pack.mcmeta @@ -1 +1,6 @@ -{"pack":{"pack_format":3,"description":"B.A.S.E External Resources"}} \ No newline at end of file +{ + "pack": { + "pack_format": 3, + "description": "Default Nomi-CEu Texture and Language Resources" + } +} diff --git a/tools/tasks/client/index.ts b/tools/tasks/client/index.ts index 47b1192..a70ae9f 100644 --- a/tools/tasks/client/index.ts +++ b/tools/tasks/client/index.ts @@ -10,7 +10,7 @@ import buildConfig from "#buildConfig"; import { deleteAsync } from "del"; import { createModList, ModFileInfo } from "../misc/createModList.ts"; import dedent from "dedent-js"; -import { cleanupVersion } from "#utils/util.ts"; +import { cleanupVersion, shouldSkipChangelog } from "#utils/util.ts"; async function clientCleanUp() { return deleteAsync(upath.join(clientDestDirectory, "*"), { force: true }); @@ -70,7 +70,7 @@ async function copyClientLicense() { /** * Copies the update notes file. */ -function copyClientUpdateNotes() { +async function copyClientUpdateNotes() { return src("../UPDATENOTES.md", { allowEmpty: true }).pipe( dest(clientDestDirectory), ); @@ -79,7 +79,9 @@ function copyClientUpdateNotes() { /** * Copies the changelog file. */ -function copyClientChangelog() { +async function copyClientChangelog() { + if (shouldSkipChangelog()) return; + return src( upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"), ).pipe(dest(clientDestDirectory)); @@ -88,7 +90,7 @@ function copyClientChangelog() { /** * Copies modpack overrides. */ -function copyClientOverrides() { +async function copyClientOverrides() { return src(buildConfig.copyFromSharedClientGlobs, { cwd: sharedDestDirectory, allowEmpty: true, diff --git a/tools/tasks/lang/index.ts b/tools/tasks/lang/index.ts index b0c8f37..261d8d3 100644 --- a/tools/tasks/lang/index.ts +++ b/tools/tasks/lang/index.ts @@ -1,6 +1,4 @@ -import gulp from "gulp"; -import rename from "gulp-rename"; -import merge from "merge-stream"; +import { dest, series, src } from "gulp"; import upath from "upath"; import buildConfig from "#buildConfig"; import { @@ -9,6 +7,18 @@ import { sharedDestDirectory, } from "#globals"; 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. @@ -19,32 +29,51 @@ async function createLangDirs() { } } -async function copyLang() { - const resourcesPath = upath.join( - sharedDestDirectory, - overridesFolder, - "resources", - ); - - 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); - }); +/** + * Copies the license file. + */ +async function copyLangLicense() { + return src("../LICENSE").pipe(dest(langDestDirectory)); } -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, +); diff --git a/tools/tasks/mmc/index.ts b/tools/tasks/mmc/index.ts index 0ff0ade..a7cbf98 100644 --- a/tools/tasks/mmc/index.ts +++ b/tools/tasks/mmc/index.ts @@ -8,6 +8,7 @@ import * as upath from "upath"; import * as fs from "fs"; import { dest, series, src } from "gulp"; import buildConfig from "#buildConfig"; +import { shouldSkipChangelog } from "#utils/util.ts"; async function mmcCleanUp() { if (fs.existsSync(mmcDestDirectory)) { @@ -27,7 +28,7 @@ async function createMMCDirs() { /** * Copies the update notes file. */ -function copyMMCUpdateNotes() { +async function copyMMCUpdateNotes() { return src("../UPDATENOTES.md", { allowEmpty: true }).pipe( dest(mmcDestDirectory), ); @@ -43,7 +44,9 @@ async function copyMMCLicense() { /** * Copies the changelog file. */ -function copyMMCChangelog() { +async function copyMMCChangelog() { + if (shouldSkipChangelog()) return; + return src( upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"), ).pipe(dest(mmcDestDirectory)); @@ -52,7 +55,7 @@ function copyMMCChangelog() { /** * Copies modpack overrides. */ -function copyOverrides() { +async function copyOverrides() { return src(upath.join(clientDestDirectory, "**/*"), { resolveSymlinks: false, }).pipe(dest(upath.join(mmcDestDirectory))); diff --git a/tools/tasks/server/index.ts b/tools/tasks/server/index.ts index 0100ad6..4f82077 100644 --- a/tools/tasks/server/index.ts +++ b/tools/tasks/server/index.ts @@ -11,6 +11,7 @@ import { downloadOrRetrieveFileDef, getForgeJar, getVersionManifest, + shouldSkipChangelog, } from "#utils/util.ts"; import { modDestDirectory, @@ -182,7 +183,7 @@ async function copyServerMods() { /** * Copies modpack overrides. */ -function copyServerOverrides() { +async function copyServerOverrides() { return src(buildConfig.copyFromSharedServerGlobs, { cwd: sharedDestDirectory, allowEmpty: true, @@ -194,7 +195,7 @@ function copyServerOverrides() { /** * Copies files from ./serverfiles into dest folder. */ -function copyServerFiles() { +async function copyServerFiles() { return src(["../serverfiles/**"], { encoding: false, // Needed because of the Server Icon }).pipe(dest(serverDestDirectory)); @@ -203,14 +204,14 @@ function copyServerFiles() { /** * Copies the license file. */ -function copyServerLicense() { +async function copyServerLicense() { return src("../LICENSE").pipe(dest(serverDestDirectory)); } /** * Copies the update notes file. */ -function copyServerUpdateNotes() { +async function copyServerUpdateNotes() { return src("../UPDATENOTES.md", { allowEmpty: true }).pipe( dest(serverDestDirectory), ); @@ -219,7 +220,9 @@ function copyServerUpdateNotes() { /** * Copies the changelog file. */ -function copyServerChangelog() { +async function copyServerChangelog() { + if (shouldSkipChangelog()) return; + return src( upath.join(buildConfig.buildDestinationDirectory, "CHANGELOG.md"), ).pipe(dest(serverDestDirectory)); @@ -230,7 +233,7 @@ function copyServerChangelog() { * * Replaces jvmArgs, minRAM, maxRAM and forgeJar. */ -function processLaunchscripts() { +async function processLaunchscripts() { const rules = { jvmArgs: buildConfig.launchscriptsJVMArgs, minRAM: buildConfig.launchscriptsMinRAM, diff --git a/tools/tasks/shared/index.ts b/tools/tasks/shared/index.ts index 681f2f0..3839e52 100644 --- a/tools/tasks/shared/index.ts +++ b/tools/tasks/shared/index.ts @@ -16,6 +16,7 @@ import { downloadFileDef, downloadOrRetrieveFileDef, isEnvVariableSet, + shouldSkipChangelog, } from "#utils/util.ts"; import transformVersion from "./transformVersion.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() { + if (shouldSkipChangelog()) return; + if ( isEnvVariableSet("CHANGELOG_URL") && isEnvVariableSet("CHANGELOG_CF_URL") diff --git a/tools/utils/util.ts b/tools/utils/util.ts index a979a38..25a9b2e 100644 --- a/tools/utils/util.ts +++ b/tools/utils/util.ts @@ -870,3 +870,18 @@ export function getUniqueToArray( 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; +}