diff --git a/README.md b/README.md index d94b99b..eaf280f 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This action runs cached `esy install` and `esy build` in the current directory `${{ hashFiles('esy.lock/index.json') }}` - `esy-prefix`: The prefix of esy folder - `working-directory`: Working directory. +- `manifest`: JSON or opam file to be used ## Example usage diff --git a/action.yml b/action.yml index 2ac98b1..1d2a616 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,9 @@ inputs: esy-prefix: description: Prefix of esy folder required: false + manifest: + description: JSON or opam file to be used + required: false runs: using: node12 main: dist/index.js diff --git a/dist/index.js b/dist/index.js index 4e86884..bdbe4c6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -48437,6 +48437,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; exports.__esModule = true; var cache = __webpack_require__(7799); var core = __webpack_require__(2186); @@ -48446,6 +48453,7 @@ var os = __webpack_require__(2087); var path = __webpack_require__(5622); var esyPrefix = core.getInput("esy-prefix"); var cacheKey = core.getInput("cache-key"); +var manifestKey = core.getInput("manifest"); function run(name, command, args) { return __awaiter(this, void 0, void 0, function () { var PATH; @@ -48463,6 +48471,9 @@ function run(name, command, args) { }); }); } +function runEsyCommand(name, args) { + return run(name, "esy", manifestKey ? __spreadArrays(["@" + manifestKey], args) : args); +} function main() { return __awaiter(this, void 0, void 0, function () { var workingDirectory, platform, installPath, installKey, installCacheKey, ESY_FOLDER, esy3, depsPath, buildKey, restoreKeys, buildCacheKey, e_1; @@ -48484,7 +48495,7 @@ function main() { console.log("Restored the install cache"); } core.endGroup(); - return [4 /*yield*/, run("Run esy install", "esy", ["install"])]; + return [4 /*yield*/, runEsyCommand("Run esy install", ["install"])]; case 2: _a.sent(); if (!(installCacheKey != installKey)) return [3 /*break*/, 4]; @@ -48511,11 +48522,11 @@ function main() { } core.endGroup(); if (!!buildCacheKey) return [3 /*break*/, 7]; - return [4 /*yield*/, run("Run esy build-dependencies", "esy", ["build-dependencies"])]; + return [4 /*yield*/, runEsyCommand("Run esy build-dependencies", ["build-dependencies"])]; case 6: _a.sent(); _a.label = 7; - case 7: return [4 /*yield*/, run("Run esy build", "esy", ["build"])]; + case 7: return [4 /*yield*/, runEsyCommand("Run esy build", ["build"])]; case 8: _a.sent(); if (!(buildCacheKey != buildKey)) return [3 /*break*/, 10]; @@ -48524,7 +48535,7 @@ function main() { _a.sent(); _a.label = 10; case 10: - if (!!buildCacheKey) return [3 /*break*/, 12]; + if (!(!manifestKey && !buildCacheKey)) return [3 /*break*/, 12]; return [4 /*yield*/, run("Run esy cleanup", "esy", ["cleanup", "."])]; case 11: _a.sent(); diff --git a/index.ts b/index.ts index 7a3334c..f0060a0 100644 --- a/index.ts +++ b/index.ts @@ -7,6 +7,7 @@ import * as path from "path"; const esyPrefix = core.getInput("esy-prefix"); const cacheKey = core.getInput("cache-key"); +const manifestKey = core.getInput("manifest"); async function run(name: string, command: string, args: string[]) { const PATH = process.env.PATH ? process.env.PATH : ""; @@ -14,6 +15,9 @@ async function run(name: string, command: string, args: string[]) { await exec(command, args, { env: { ...process.env, PATH } }); core.endGroup(); } +function runEsyCommand(name: string, args: string[]) { + return run(name, "esy", manifestKey ? [`@${manifestKey}`, ...args] : args); +} async function main() { try { @@ -36,7 +40,7 @@ async function main() { } core.endGroup(); - await run("Run esy install", "esy", ["install"]); + await runEsyCommand("Run esy install", ["install"]); if (installCacheKey != installKey) { await cache.saveCache(installPath, installKey); @@ -65,16 +69,17 @@ async function main() { core.endGroup(); if (!buildCacheKey) { - await run("Run esy build-dependencies", "esy", ["build-dependencies"]); + await runEsyCommand("Run esy build-dependencies", ["build-dependencies"]); } - await run("Run esy build", "esy", ["build"]); + await runEsyCommand("Run esy build", ["build"]); if (buildCacheKey != buildKey) { await cache.saveCache(depsPath, buildKey); } - if (!buildCacheKey) { + // TODO: support cleanup + manifest + if (!manifestKey && !buildCacheKey) { await run("Run esy cleanup", "esy", ["cleanup", "."]); } } catch (e) {