diff --git a/.github/workflows/buildpack.yml b/.github/workflows/buildpack.yml index 8a87072..af76772 100644 --- a/.github/workflows/buildpack.yml +++ b/.github/workflows/buildpack.yml @@ -37,7 +37,7 @@ on: 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). required: true type: boolean - + workflow_call: inputs: tag: @@ -150,7 +150,7 @@ jobs: with: name: Built Pack path: | - ./build/*.zip + ./build/**/*.zip ./build/*.md if-no-files-found: error compression-level: 0 @@ -257,7 +257,7 @@ jobs: CHANGELOG_URL: ${{ inputs.changelog_url }} CHANGELOG_CF_URL: ${{ inputs.changelog_cf_url }} COMPARE_TAG: ${{ inputs.compare_tag }} - + - name: Upload Client Zip uses: actions/upload-artifact@v4 with: diff --git a/tools/gulpfile.ts b/tools/gulpfile.ts index 4d21157..850563a 100644 --- a/tools/gulpfile.ts +++ b/tools/gulpfile.ts @@ -52,6 +52,8 @@ export const zipClient = zip.zipClient; export const zipServer = zip.zipServer; export const zipLang = zip.zipLang; export const zipMMC = zip.zipMMC; +export const zipClientCF = zip.zipClientCF; +export const zipServerCF = zip.zipServerCF; export const zipAll = zip.zipAll; export default gulp.series(buildAll, zipAll); diff --git a/tools/tasks/changelog/index.ts b/tools/tasks/changelog/index.ts index 822ba9a..6ad0265 100644 --- a/tools/tasks/changelog/index.ts +++ b/tools/tasks/changelog/index.ts @@ -52,7 +52,7 @@ async function createChangelog(): Promise { } return data; } - logInfo("No Iterations Detected."); + logInfo("Default Iteration Detected."); categoriesSetup(); specialParserSetup(data); diff --git a/tools/tasks/deploy/curseforge.ts b/tools/tasks/deploy/curseforge.ts index da5f324..946ca69 100644 --- a/tools/tasks/deploy/curseforge.ts +++ b/tools/tasks/deploy/curseforge.ts @@ -30,7 +30,11 @@ const variablesToCheck = [ async function upload(files: { name: string; displayName: string }[]) { files.forEach((file) => { - const path = upath.join(buildConfig.buildDestinationDirectory, file.name); + const path = upath.join( + buildConfig.buildDestinationDirectory, + "cf", + file.name, + ); if (!fs.existsSync(path)) { throw new Error(`File ${path} doesn't exist!`); } @@ -120,7 +124,11 @@ async function upload(files: { name: string; displayName: string }[]) { const response: { id: number } = (await getAxios()(options)).data; if (response && response.id) { - uploadedIDs.push({ filePath: path, displayName: file.displayName, id: response.id }); + uploadedIDs.push({ + filePath: path, + displayName: file.displayName, + id: response.id, + }); if (!parentID) { parentID = response.id; } diff --git a/tools/tasks/misc/zip.ts b/tools/tasks/misc/zip.ts index 812bf4b..2427e68 100644 --- a/tools/tasks/misc/zip.ts +++ b/tools/tasks/misc/zip.ts @@ -14,20 +14,26 @@ import sanitize from "sanitize-filename"; async function zipFolder( path: string, - zipName: string = upath.basename(path) + ".zip", + globs: string[], + dest: string, + zipName: string, ): Promise { return new Promise((resolve) => { - src(upath.join(path, "**"), { base: path, dot: true, encoding: false }) + src(globs, { cwd: path, dot: true, encoding: false }) .pipe(zip(zipName)) - .pipe(gulp.dest(buildConfig.buildDestinationDirectory)) + .pipe(gulp.dest(dest)) .on("end", resolve); }); } -function makeZipper(src: string, artifactName: string) { +function makeZipper(src: string, artifactName: string, isCFZip = false) { const zipFn = () => { return zipFolder( - upath.join(src), + src, + isCFZip ? buildConfig.cfZipGlobs : buildConfig.normalZipGlobs, + isCFZip + ? upath.join(buildConfig.buildDestinationDirectory, "cf") + : buildConfig.buildDestinationDirectory, sanitize( ( makeArtifactNameBody(modpackManifest.name) + `-${artifactName}.zip` @@ -37,7 +43,7 @@ function makeZipper(src: string, artifactName: string) { }; Object.defineProperty(zipFn, "name", { - value: `zip${artifactName}`, + value: `zip${artifactName}${isCFZip ? "CF" : ""}`, configurable: true, }); @@ -48,5 +54,13 @@ export const zipServer = makeZipper(serverDestDirectory, "Server"); export const zipClient = makeZipper(clientDestDirectory, "Client"); export const zipLang = makeZipper(langDestDirectory, "Lang"); export const zipMMC = makeZipper(mmcDestDirectory, "MMC"); +export const zipServerCF = makeZipper(serverDestDirectory, "Server", true); +export const zipClientCF = makeZipper(clientDestDirectory, "Client", true); -export const zipAll = gulp.parallel(zipServer, zipClient, zipLang); +export const zipAll = gulp.parallel( + zipServer, + zipClient, + zipLang, + zipServerCF, + zipClientCF, +); diff --git a/tools/tasks/shared/index.ts b/tools/tasks/shared/index.ts index f21a1a0..681f2f0 100644 --- a/tools/tasks/shared/index.ts +++ b/tools/tasks/shared/index.ts @@ -60,6 +60,19 @@ async function copyOverrides() { }); } +/** + * Copies Modpack Pack Mode Switcher Scripts. + */ +async function copyPackModeSwitchers() { + return new Promise((resolve) => { + src(buildConfig.packModeSwitcherGlobs, { + cwd: upath.join(rootDirectory), + }) + .pipe(dest(upath.join(sharedDestDirectory, overridesFolder))) + .on("end", resolve); + }); +} + /** * Fetch external dependencies and remove the field from the manifest file. */ @@ -176,6 +189,7 @@ export default gulp.series( sharedCleanUp, createSharedDirs, copyOverrides, + copyPackModeSwitchers, fetchOrMakeChangelog, fetchExternalDependencies, updateFilesBuildSetup, diff --git a/tools/utils/buildConfig.default.json b/tools/utils/buildConfig.default.json index 0e4426f..cb818c3 100644 --- a/tools/utils/buildConfig.default.json +++ b/tools/utils/buildConfig.default.json @@ -4,12 +4,16 @@ "downloaderConcurrency": 50, "downloaderCheckHashes": true, "downloaderCacheDirectory": "../.cache", + "changelogCacheMaxPages": 5, "launchscriptsMinRAM": "2048M", "launchscriptsMaxRAM": "2048M", "launchscriptsJVMArgs": "", "copyToSharedDirGlobs": ["overrides/**/*"], + "packModeSwitcherGlobs": ["pack-mode-switcher.*"], "copyFromSharedServerGlobs": ["overrides/**/*", "!overrides/resources/**/*"], "copyFromSharedClientGlobs": ["overrides/**/*"], + "normalZipGlobs": ["**/*"], + "cfZipGlobs": ["**/*", "!**/pack-mode-switcher.*"], "buildDestinationDirectory": "../build", "nightlyHookAvatar": "", "nightlyHookName": "" diff --git a/tools/utils/util.ts b/tools/utils/util.ts index 426c501..a979a38 100644 --- a/tools/utils/util.ts +++ b/tools/utils/util.ts @@ -642,13 +642,26 @@ const issueURLCache: Map = new Map(); export async function getIssueURLs(): Promise { if (issueURLCache.size > 0) return; try { - const issues = await octokit.paginate(octokit.issues.listForRepo, { - owner: repoOwner, - repo: repoName, - per_page: 100, - state: "closed", - sort: "updated", - }); + let page = 1; + const issues = await octokit.paginate( + octokit.issues.listForRepo, + { + owner: repoOwner, + repo: repoName, + per_page: 100, + state: "closed", + sort: "updated", + }, + (response, done) => { + if (page++ >= buildConfig.changelogCacheMaxPages) { + logInfo( + `Fetched ${buildConfig.changelogCacheMaxPages} Pages of 100 Issues! Final Issue Fetched: #${response.data.at(-1)?.number ?? 0}`, + ); + done(); + } + return response.data; + }, + ); issues.forEach((issue) => { if (!issueURLCache.has(issue.number)) issueURLCache.set(issue.number, issue.html_url); @@ -703,11 +716,24 @@ const commitAuthorCache: Map = new Map(); export async function getCommitAuthors(): Promise { if (commitAuthorCache.size > 0) return; try { - const commits = await octokit.paginate(octokit.repos.listCommits, { - owner: repoOwner, - repo: repoName, - per_page: 100, - }); + let page = 1; + const commits = await octokit.paginate( + octokit.repos.listCommits, + { + owner: repoOwner, + repo: repoName, + per_page: 100, + }, + (response, done) => { + if (page++ >= buildConfig.changelogCacheMaxPages) { + logInfo( + `Fetched ${buildConfig.changelogCacheMaxPages} Pages of 100 Commits! Final Commit Fetched: ${response.data.at(-1)?.sha ?? ""}`, + ); + done(); + } + return response.data; + }, + ); commits.forEach((commit) => { if (!commitAuthorCache.has(commit.sha)) commitAuthorCache.set(commit.sha, commit.author?.login ?? "");