Use 'SpraxDev/Spigot-BuildTools' by default

The action can now be configured to use the original BuildTools or a fork of mine with some tweaks (More info at https://github.com/SpraxDev/Spigot-BuildTools/#breaking-changes)
This commit is contained in:
Christian Koop 2020-11-24 11:31:09 +01:00
parent ff431ef526
commit f88defe2ae
No known key found for this signature in database
GPG Key ID: DECCA4CEE0E46D6D
5 changed files with 33 additions and 8 deletions

View File

@ -72,4 +72,9 @@ as they are set automatically.
# The amount of builds allowed to run at the same time # The amount of builds allowed to run at the same time
# Set to '-1' to use system's cpu core count # Set to '-1' to use system's cpu core count
threads: -1 threads: -1
# You can choose between different BuildTools to be used by this action
# 'SpraxDev' is my fork of SpigotMC's that introduces some changes (https://github.com/SpraxDev/Spigot-BuildTools/#breaking-changes)
# Available: SpraxDev, SpigotMC
buildToolProvider: SpraxDev
``` ```

View File

@ -35,6 +35,10 @@ inputs:
required: false required: false
default: '-1' default: '-1'
description: The amount of builds allowed to run at a time, set to '-1' to use system's cpu count description: The amount of builds allowed to run at a time, set to '-1' to use system's cpu count
buildToolProvider:
required: false
default: SpraxDev
description: Whose BuildTool should be used? (SpraxDev [default], SpigotMC)
runs: runs:
using: node12 using: node12

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -2,14 +2,25 @@ import * as core from '@actions/core';
import { join as joinPath, resolve as resolvePath } from 'path'; import { join as joinPath, resolve as resolvePath } from 'path';
import { copy } from 'fs-extra'; import { copy } from 'fs-extra';
import { rmdirSync } from 'fs'; import { rmdirSync } from 'fs';
import { cpuCount, downloadFile, exit, fixArgArr, isNumeric, resetWorkingDir, runCmd } from './utils';
import { parallelLimit } from 'async'; import { parallelLimit } from 'async';
import { cpuCount, downloadFile, exit, fixArgArr, isNumeric, resetWorkingDir, runCmd } from './utils';
const rll = require('read-last-lines'); const rll = require('read-last-lines');
const supportedBuildTools: { [key: string]: { url: string, prepareArgs: string[] } } = {
spraxdev: {
url: 'https://github.com/SpraxDev/Spigot-BuildTools/releases/latest/download/BuildTools.jar',
prepareArgs: ['--exit-after-fetch']
},
spigotmc: {
url: 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar',
prepareArgs: ['--compile', 'None']
}
};
/* GitHub Actions inputs */ /* GitHub Actions inputs */
const buildToolProvider: string = (core.getInput('buildToolProvider') || 'SpraxDev').toLowerCase();
const versions: string[] = fixArgArr((core.getInput('versions') || 'latest').split(',')); const versions: string[] = fixArgArr((core.getInput('versions') || 'latest').split(','));
const target: string[] = fixArgArr((core.getInput('target') || 'Spigot').toUpperCase().split(',')); const target: string[] = fixArgArr((core.getInput('target') || 'Spigot').toUpperCase().split(','));
const generateSrc: boolean = core.getInput('generateSrc') == 'true'; const generateSrc: boolean = core.getInput('generateSrc') == 'true';
@ -22,17 +33,22 @@ const threadCount: number = isNumeric(core.getInput('threads')) ? parseInt(core.
const workingDir = resetWorkingDir(); const workingDir = resetWorkingDir();
async function run(): Promise<{ code: number, msg?: string }> { async function run(): Promise<{ code: number, msg?: string }> {
return new Promise<{ code: number, msg?: string }>(async (resolve, reject): Promise<void> => { return new Promise(async (resolve, reject): Promise<void> => {
if (versions.length == 0) return resolve({code: 0, msg: 'No version(s) provided to build'}); if (versions.length == 0) return resolve({code: 0, msg: 'No version(s) provided to build'});
if (target.length == 0) return resolve({code: 0, msg: 'No target(s) provided to build'}); if (target.length == 0) return resolve({code: 0, msg: 'No target(s) provided to build'});
if (!Object.keys(supportedBuildTools).includes(buildToolProvider)) {
return reject(new Error(`'${buildToolProvider}' is not a valid BuildTool-Provider (${Object.keys(supportedBuildTools).join(', ')})`));
}
const buildTool = supportedBuildTools[buildToolProvider];
const appLogFile = joinPath(workingDir.logs, 'SpraxDev_Actions-SpigotMC.log'); const appLogFile = joinPath(workingDir.logs, 'SpraxDev_Actions-SpigotMC.log');
console.log('Installed Java-Version:'); console.log('Installed Java-Version:');
await runCmd('java', ['-version'], workingDir.base, appLogFile); await runCmd('java', ['-version'], workingDir.base, appLogFile);
console.log(`Downloading BuildTools.jar from 'hub.spigotmc.org'...`); console.log(`Downloading '${buildTool.url}'...`);
await downloadFile('https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar', joinPath(workingDir.cache, 'BuildTools.jar')); await downloadFile(buildTool.url, joinPath(workingDir.cache, 'BuildTools.jar'));
const gotTemplateDirectory = versions.length != 1; const gotTemplateDirectory = versions.length != 1;
@ -42,7 +58,7 @@ async function run(): Promise<{ code: number, msg?: string }> {
try { try {
await core.group('Prepare BuildTools', async (): Promise<void> => { await core.group('Prepare BuildTools', async (): Promise<void> => {
return runCmd('java', ['-jar', 'BuildTools.jar', '--compile', 'NONE', (disableJavaCheck ? '--disable-java-check' : '')], return runCmd('java', ['-jar', 'BuildTools.jar', (disableJavaCheck ? '--disable-java-check' : ''), ...buildTool.prepareArgs],
workingDir.cache, appLogFile); workingDir.cache, appLogFile);
}); });
} catch (err) { } catch (err) {