Update buildscripts (#335)
Merged changes from https://github.com/Nomifactory/Nomifactory/tree/dev/buildtools made after February 2022 (when I helped @tracer4b get the build scripts at the time set up). CurseForge subsequently did its API changes so the old scripts don't work anymore. You will need to create a Secret called CFCORE_API_TOKEN which contains the CurseForge API authentication token you wish to use (for https://api.curseforge.com). When running build scripts locally, you need to have an environment variable set with the same name and value. This token allows the script to download mod jars required for building the server zip. Without this token, at the very least mods that disallow third-party downloads would return blank download links and that build target would fail. It might be needed to use the API at all, but @NotMyWing is our CICD author and resident expert, so I would defer to him on details. /* Commits */ * Switch API calls to CFCore (#914) Necessary to continue using the CurseForge API. * Propagate the CFCore token to GHA * Move download URL forging to fetchFileInfo * Add CurseForge Beta deployment workflow (#944) --------- Co-authored-by: Neeve <winwyv@gmail.com>
This commit is contained in:
parent
36dfebfcf0
commit
d3c771d94f
83
.github/workflows/deploycfrc.yml
vendored
Normal file
83
.github/workflows/deploycfrc.yml
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
name: Deploy to CurseForge (RC)
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch:
|
||||
description: 'Branch to checkout'
|
||||
required: true
|
||||
default: 'dev'
|
||||
version:
|
||||
description: 'RC version to deploy (e. g. "v1.3")'
|
||||
required: true
|
||||
flavorTitle:
|
||||
description: 'Flavor title (e. g. "Community Update")'
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy to CurseForge (RC) (${{ github.event.inputs.version }})
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITHUB_BRANCH: ${{ github.event.inputs.branch }}
|
||||
RC_VERSION: ${{ github.event.inputs.version }}
|
||||
BUILD_FLAVOR_TITLE: ${{ github.event.inputs.flavorTitle }}
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.inputs.tag }}
|
||||
|
||||
- name: "Restore cached files"
|
||||
uses: actions/cache@v2
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
~/.npm
|
||||
./.cache
|
||||
./buildtools/node_modules
|
||||
key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }}
|
||||
restore-keys: ${{ runner.os }}-bunny-
|
||||
|
||||
- name: "Setup NodeJS v16"
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "16"
|
||||
check-latest: true
|
||||
|
||||
- name: "Download NPM packages"
|
||||
working-directory: ./buildtools
|
||||
run: npm ci
|
||||
|
||||
- name: "Check environmental variables"
|
||||
working-directory: ./buildtools
|
||||
run: npx gulp check
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }}
|
||||
CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }}
|
||||
CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }}
|
||||
|
||||
- name: "Build everything"
|
||||
working-directory: ./buildtools
|
||||
run: npx gulp buildAll
|
||||
env:
|
||||
CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }}
|
||||
|
||||
- name: "Prune cache"
|
||||
working-directory: ./buildtools
|
||||
run: npx gulp pruneCache
|
||||
env:
|
||||
CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }}
|
||||
|
||||
- name: "Zip everything"
|
||||
working-directory: ./buildtools
|
||||
run: npx gulp zipAll
|
||||
|
||||
- name: "Deploy to CurseForge"
|
||||
env:
|
||||
CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }}
|
||||
CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }}
|
||||
working-directory: ./buildtools
|
||||
run: npx gulp deployCurseForgeBeta
|
2
.github/workflows/nightly.yml.disabled
vendored
2
.github/workflows/nightly.yml.disabled
vendored
@ -59,8 +59,6 @@ jobs:
|
||||
- name: "Prune cache"
|
||||
working-directory: ./buildtools
|
||||
run: npx gulp pruneCache
|
||||
env:
|
||||
CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }}
|
||||
|
||||
##
|
||||
## Upload artifacts.
|
||||
|
@ -28,8 +28,7 @@ export const zipMMC = zip.zipMMC;
|
||||
import * as gha from "./tasks/misc/gha";
|
||||
export const makeArtifactNames = gha.makeArtifactNames;
|
||||
|
||||
import deployCurseForgeTask from "./tasks/deploy/curseforge";
|
||||
export const deployCurseForge = deployCurseForgeTask;
|
||||
export { deployCurseForge, deployCurseForgeBeta } from "./tasks/deploy/curseforge";
|
||||
|
||||
import deployReleasesTask from "./tasks/deploy/releases";
|
||||
export const deployReleases = deployReleasesTask;
|
||||
|
3252
buildtools/package-lock.json
generated
3252
buildtools/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -40,8 +40,8 @@
|
||||
"requestretry": "^5.0.0",
|
||||
"sanitize-filename": "^1.6.3",
|
||||
"sha1": "^1.1.1",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.2.3",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.8.4",
|
||||
"unzipper": "^0.10.11",
|
||||
"upath": "^2.0.1"
|
||||
},
|
||||
|
@ -9,24 +9,30 @@ import { makeArtifactNameBody } from "../../util/util";
|
||||
import sanitize from "sanitize-filename";
|
||||
|
||||
const CURSEFORGE_LEGACY_ENDPOINT = "https://minecraft.curseforge.com/";
|
||||
const variablesToCheck = ["CURSEFORGE_API_TOKEN", "CURSEFORGE_PROJECT_ID", "GITHUB_TAG"];
|
||||
const variablesToCheck = ["CURSEFORGE_API_TOKEN", "CURSEFORGE_PROJECT_ID"];
|
||||
|
||||
interface CFUploadOptions {
|
||||
releaseType?: "release" | "beta";
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads build artifacts to CurseForge.
|
||||
* Uploads beta artifacts to CurseForge.
|
||||
*/
|
||||
async function deployCurseForge(): Promise<void> {
|
||||
export async function deployCurseForgeBeta(): Promise<void> {
|
||||
/**
|
||||
* Obligatory variable check.
|
||||
*/
|
||||
variablesToCheck.forEach((vari) => {
|
||||
["RC_VERSION", ...variablesToCheck].forEach((vari) => {
|
||||
if (!process.env[vari]) {
|
||||
throw new Error(`Environmental variable ${vari} is unset.`);
|
||||
}
|
||||
});
|
||||
|
||||
const tag = process.env.GITHUB_TAG;
|
||||
const version = process.env.RC_VERSION;
|
||||
const flavorTitle = process.env.BUILD_FLAVOR_TITLE;
|
||||
const displayName = [modpackManifest.name, tag.replace(/^v/, ""), flavorTitle].filter(Boolean).join(" - ");
|
||||
const displayName = [modpackManifest.name, [version.replace(/^v/, ""), "Release Candidate"].join(" "), flavorTitle]
|
||||
.filter(Boolean)
|
||||
.join(" - ");
|
||||
|
||||
const files = [
|
||||
{
|
||||
@ -42,6 +48,14 @@ async function deployCurseForge(): Promise<void> {
|
||||
/**
|
||||
* Obligatory file check.
|
||||
*/
|
||||
await upload(files, {
|
||||
releaseType: "beta",
|
||||
});
|
||||
}
|
||||
|
||||
async function upload(files: { name: string; displayName: string }[], opts?: CFUploadOptions) {
|
||||
opts = opts || {};
|
||||
|
||||
files.forEach((file) => {
|
||||
const path = upath.join(buildConfig.buildDestinationDirectory, file.name);
|
||||
if (!fs.existsSync(path)) {
|
||||
@ -71,6 +85,10 @@ async function deployCurseForge(): Promise<void> {
|
||||
maxAttempts: 5,
|
||||
})) || [];
|
||||
|
||||
if (!versionsManifest) {
|
||||
throw new Error("Failed to fetch CurseForge version manifest.");
|
||||
}
|
||||
|
||||
const version = versionsManifest.find((m) => m.name == modpackManifest.minecraft.version);
|
||||
|
||||
if (!version) {
|
||||
@ -92,7 +110,7 @@ async function deployCurseForge(): Promise<void> {
|
||||
metadata: JSON.stringify({
|
||||
changelog: changelog,
|
||||
changelogType: "markdown",
|
||||
releaseType: "release",
|
||||
releaseType: opts.releaseType || "release",
|
||||
parentFileID: clientFileID,
|
||||
gameVersions: clientFileID ? undefined : [version.id],
|
||||
displayName: file.displayName,
|
||||
@ -117,4 +135,33 @@ async function deployCurseForge(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export default deployCurseForge;
|
||||
/**
|
||||
* Uploads build artifacts to CurseForge.
|
||||
*/
|
||||
export async function deployCurseForge(): Promise<void> {
|
||||
/**
|
||||
* Obligatory variable check.
|
||||
*/
|
||||
["GITHUB_TAG", ...variablesToCheck].forEach((vari) => {
|
||||
if (!process.env[vari]) {
|
||||
throw new Error(`Environmental variable ${vari} is unset.`);
|
||||
}
|
||||
});
|
||||
|
||||
const tag = process.env.GITHUB_TAG;
|
||||
const flavorTitle = process.env.BUILD_FLAVOR_TITLE;
|
||||
const displayName = [modpackManifest.name, tag.replace(/^v/, ""), flavorTitle].filter(Boolean).join(" - ");
|
||||
|
||||
const files = [
|
||||
{
|
||||
name: sanitize((makeArtifactNameBody(modpackManifest.name) + "-client.zip").toLowerCase()),
|
||||
displayName: displayName,
|
||||
},
|
||||
{
|
||||
name: sanitize((makeArtifactNameBody(modpackManifest.name) + "-server.zip").toLowerCase()),
|
||||
displayName: `${displayName} Server`,
|
||||
},
|
||||
];
|
||||
|
||||
upload(files);
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ const randomPatchesConfigFile = "config/randompatches.cfg";
|
||||
*/
|
||||
export default async function transformManifestVersion(): Promise<void> {
|
||||
let versionTitle;
|
||||
|
||||
// We're building a tag.
|
||||
if (process.env.GITHUB_TAG) {
|
||||
const flavorTitle = process.env.BUILD_FLAVOR_TITLE;
|
||||
const tag = process.env.GITHUB_TAG.replace(/^v/, "");
|
||||
@ -18,6 +20,18 @@ export default async function transformManifestVersion(): Promise<void> {
|
||||
|
||||
modpackManifest.version = tag;
|
||||
}
|
||||
// If we're buildig a release candidate, transform it appropriately.
|
||||
else if (process.env.RC_VERSION) {
|
||||
const rcVer = process.env.RC_VERSION;
|
||||
const flavorTitle = process.env.BUILD_FLAVOR_TITLE;
|
||||
const tag = rcVer.replace(/^v/, "");
|
||||
|
||||
versionTitle = [modpackManifest.name, [tag, "Release Candidate"].join(" "), flavorTitle]
|
||||
.filter(Boolean)
|
||||
.join(" - ");
|
||||
|
||||
modpackManifest.version = [rcVer, "rc"].join("-");
|
||||
}
|
||||
// If SHA is provided and the build isn't tagged, append both the branch and short SHA.
|
||||
else if (process.env.GITHUB_SHA && process.env.GITHUB_REF && process.env.GITHUB_REF.startsWith("refs/heads/")) {
|
||||
const shortCommit = process.env.GITHUB_SHA.substr(0, 7);
|
||||
|
@ -156,6 +156,10 @@ export function makeArtifactNameBody(baseName: string): string {
|
||||
if (process.env.GITHUB_TAG) {
|
||||
return `${baseName}-${process.env.GITHUB_TAG}`;
|
||||
}
|
||||
// RC.
|
||||
else if (process.env.RC_VERSION) {
|
||||
return `${baseName}-${process.env.RC_VERSION.replace(/^v/, "")}-rc`;
|
||||
}
|
||||
// If SHA is provided and the build isn't tagged, append both the branch and short SHA.
|
||||
else if (process.env.GITHUB_SHA && process.env.GITHUB_REF && process.env.GITHUB_REF.startsWith("refs/heads/")) {
|
||||
const shortCommit = process.env.GITHUB_SHA.substr(0, 7);
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
:: DO NOT EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
|
||||
@ECHO OFF
|
||||
SET FORGEJAR={{forgeJar}}
|
||||
SET JAVA_PARAMETERS={{jvmArgs}}
|
||||
SET FORGEJAR={{{forgeJar}}}
|
||||
SET JAVA_PARAMETERS={{{jvmArgs}}}
|
||||
|
||||
:: these you can edit
|
||||
SET MIN_RAM={{minRAM}}
|
||||
SET MAX_RAM={{maxRAM}}
|
||||
SET MIN_RAM={{{minRAM}}}
|
||||
SET MAX_RAM={{{maxRAM}}}
|
||||
|
||||
:: DO NOT EDIT ANYTHING PAST THIS LINE
|
||||
SET LAUNCHPARAMS=-server -Xms%MIN_RAM% -Xmx%MAX_RAM% %JAVA_PARAMETERS% -Dlog4j.configurationFile=log4j2_112-116.xml -jar %FORGEJAR% nogui
|
||||
|
@ -9,12 +9,12 @@
|
||||
# https://github.com/t0suj4
|
||||
|
||||
# DO NOT EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
|
||||
FORGEJAR='{{forgeJar}}'
|
||||
JAVA_PARAMETERS='{{jvmArgs}}'
|
||||
FORGEJAR='{{{forgeJar}}}'
|
||||
JAVA_PARAMETERS='{{{jvmArgs}}}'
|
||||
|
||||
# these you can edit
|
||||
MIN_RAM='{{minRAM}}'
|
||||
MAX_RAM='{{maxRAM}}'
|
||||
MIN_RAM='{{{minRAM}}}'
|
||||
MAX_RAM='{{{maxRAM}}}'
|
||||
|
||||
# DO NOT EDIT ANYTHING PAST THIS LINE
|
||||
LAUNCHPARAMS="-server -Xms$MIN_RAM -Xmx$MAX_RAM $JAVA_PARAMETERS -Dlog4j.configurationFile=log4j2_112-116.xml -jar $FORGEJAR nogui"
|
||||
|
Loading…
x
Reference in New Issue
Block a user