parent
6364796c38
commit
df58232c56
@ -29,7 +29,7 @@ const variablesToCheck = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
async function upload(files: { name: string; displayName: string }[]) {
|
async function upload(files: { name: string; displayName: string }[]) {
|
||||||
files.forEach((file) => {
|
const filePaths = files.map((file) => {
|
||||||
const path = upath.join(
|
const path = upath.join(
|
||||||
buildConfig.buildDestinationDirectory,
|
buildConfig.buildDestinationDirectory,
|
||||||
"cf",
|
"cf",
|
||||||
@ -38,6 +38,7 @@ async function upload(files: { name: string; displayName: string }[]) {
|
|||||||
if (!fs.existsSync(path)) {
|
if (!fs.existsSync(path)) {
|
||||||
throw new Error(`File ${path} doesn't exist!`);
|
throw new Error(`File ${path} doesn't exist!`);
|
||||||
}
|
}
|
||||||
|
return { path: path, file: file };
|
||||||
});
|
});
|
||||||
|
|
||||||
// Since we've built everything beforehand, the changelog must be available in the shared directory.
|
// Since we've built everything beforehand, the changelog must be available in the shared directory.
|
||||||
@ -91,8 +92,7 @@ async function upload(files: { name: string; displayName: string }[]) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Upload artifacts.
|
// Upload artifacts.
|
||||||
for (const file of files) {
|
for (const filePath of filePaths) {
|
||||||
const path = upath.join(buildConfig.buildDestinationDirectory, file.name);
|
|
||||||
const options: AxiosRequestConfig<unknown> = {
|
const options: AxiosRequestConfig<unknown> = {
|
||||||
url:
|
url:
|
||||||
CURSEFORGE_LEGACY_ENDPOINT +
|
CURSEFORGE_LEGACY_ENDPOINT +
|
||||||
@ -109,15 +109,15 @@ async function upload(files: { name: string; displayName: string }[]) {
|
|||||||
releaseType: releaseType ? releaseType.cfReleaseType : "release",
|
releaseType: releaseType ? releaseType.cfReleaseType : "release",
|
||||||
parentFileID: parentID ? parentID : undefined,
|
parentFileID: parentID ? parentID : undefined,
|
||||||
gameVersions: parentID ? undefined : [version.id],
|
gameVersions: parentID ? undefined : [version.id],
|
||||||
displayName: file.displayName,
|
displayName: filePath.file.displayName,
|
||||||
}),
|
}),
|
||||||
file: fs.createReadStream(path),
|
file: fs.createReadStream(filePath.path),
|
||||||
},
|
},
|
||||||
responseType: "json",
|
responseType: "json",
|
||||||
};
|
};
|
||||||
|
|
||||||
logInfo(
|
logInfo(
|
||||||
`Uploading ${file.name} to CurseForge...` +
|
`Uploading ${filePath.file.name} to CurseForge...` +
|
||||||
(parentID ? `(child of ${parentID})` : ""),
|
(parentID ? `(child of ${parentID})` : ""),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -125,15 +125,17 @@ async function upload(files: { name: string; displayName: string }[]) {
|
|||||||
|
|
||||||
if (response && response.id) {
|
if (response && response.id) {
|
||||||
uploadedIDs.push({
|
uploadedIDs.push({
|
||||||
filePath: path,
|
filePath: filePath.path,
|
||||||
displayName: file.displayName,
|
displayName: filePath.file.displayName,
|
||||||
id: response.id,
|
id: response.id,
|
||||||
});
|
});
|
||||||
if (!parentID) {
|
if (!parentID) {
|
||||||
parentID = response.id;
|
parentID = response.id;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Failed to upload ${file.name}: Invalid Response.`);
|
throw new Error(
|
||||||
|
`Failed to upload ${filePath.file.name}: Invalid Response.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isEnvVariableSet("GITHUB_STEP_SUMMARY"))
|
if (isEnvVariableSet("GITHUB_STEP_SUMMARY"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user