use ts
This commit is contained in:
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const exec_1 = require("@actions/exec");
|
||||
const io = require("@actions/io");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
exports.folder = path.join(os.tmpdir(), `xmake${Date.now()}`);
|
||||
const opt = { cwd: exports.folder };
|
||||
const a = 121212;
|
||||
async function create(ref) {
|
||||
await io.rmRF(exports.folder);
|
||||
await io.mkdirP(exports.folder);
|
||||
await exec_1.exec('git', ['init'], opt);
|
||||
await exec_1.exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], opt);
|
||||
await exec_1.exec('git', ['fetch'], opt);
|
||||
await exec_1.exec('git', ['checkout', ref], opt);
|
||||
await exec_1.exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
|
||||
return exports.folder;
|
||||
}
|
||||
exports.create = create;
|
||||
async function cleanup() {
|
||||
await io.rmRF(exports.folder);
|
||||
}
|
||||
exports.cleanup = cleanup;
|
||||
Vendored
+71
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = require("@actions/core");
|
||||
const exec_1 = require("@actions/exec");
|
||||
const _fs = require("fs");
|
||||
const fs = _fs.promises;
|
||||
const io = require("@actions/io");
|
||||
const toolCache = require("@actions/tool-cache");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
const semver = require("semver");
|
||||
const git = require("./git");
|
||||
const versions_1 = require("./versions");
|
||||
async function winInstall(version) {
|
||||
let toolDir = toolCache.find('xmake', version);
|
||||
if (!toolDir) {
|
||||
const installer = await core.group("download xmake", async () => {
|
||||
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
|
||||
const url = semver.gt(version, '2.2.6')
|
||||
? `https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?tag=v${version}&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+${arch}`
|
||||
: `https://github.com/xmake-io/xmake/releases/download/v$v/xmake-v${version}.exe`;
|
||||
core.info(`downloading from ${url}`);
|
||||
const file = await toolCache.downloadTool(url);
|
||||
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });
|
||||
await fs.rename(file, exe);
|
||||
core.info(`downloaded to ${exe}`);
|
||||
return exe;
|
||||
});
|
||||
toolDir = await core.group("install xmake", async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version}`);
|
||||
core.info(`installing to ${binDir}`);
|
||||
await exec_1.exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
||||
core.info(`installed to ${binDir}`);
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version);
|
||||
await io.rmRF(binDir);
|
||||
await io.rmRF(installer);
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
core.addPath(toolDir);
|
||||
}
|
||||
async function unixInstall(version, sha) {
|
||||
let toolDir = toolCache.find('xmake', version);
|
||||
if (!toolDir) {
|
||||
const sourceDir = await core.group("download xmake", () => git.create(sha));
|
||||
toolDir = await core.group("install xmake", async () => {
|
||||
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version}-${sha}`);
|
||||
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version);
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup();
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
core.addPath(path.join(toolDir, 'share', 'xmake'));
|
||||
}
|
||||
async function run() {
|
||||
try {
|
||||
const { version, sha } = versions_1.selectVersion();
|
||||
if (os.platform() === 'win32' || os.platform() === 'cygwin')
|
||||
await winInstall(version);
|
||||
else
|
||||
await unixInstall(version, sha);
|
||||
await exec_1.exec('xmake --version');
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
run();
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = require("@actions/core");
|
||||
const semver = require("semver");
|
||||
exports.versions = {
|
||||
"1.0.1": "723ec3e970e17f48a601fe2a919b9802b5e516fa",
|
||||
"1.0.2": "84fa20ca3ded99b9667609c5cb2e56b2308c8e4b",
|
||||
"1.0.3": "e56812a09d3677957c41bccc8988599208e3b49a",
|
||||
"1.0.4": "825dda9d93448ba783e18f7947eef0b4eb07942e",
|
||||
"2.0.1": "432fd6a40018f4c29e08f1d4cadf1ccc387a0cff",
|
||||
"2.0.2": "d24fcddbc2f1093f3943a917d99c5a8989ef2644",
|
||||
"2.0.3": "b5f21a05b1cdaf46314238b4cc665976294df1da",
|
||||
"2.0.4": "2b15a1b5b149e5156e22358f3d29b4de63473376",
|
||||
"2.0.5": "b168ce05d763957ed05844141d77d155bf842e7a",
|
||||
"2.1.1": "5ba22ca230c3f3f9477491df6d39f11d53132fb1",
|
||||
"2.1.2": "bf69a2413117cf21c53bde1edbda713e77d4fd9b",
|
||||
"2.1.3": "248b2cc8a96d41445a2e46d259d14fea8e4203ec",
|
||||
"2.1.4": "1d94a23a7db35631f4b33b8b0b3968d0e62ffe2a",
|
||||
"2.1.5": "72f68f941f9b6d07f71811fe403a2dc178270af0",
|
||||
"2.1.6": "7ea60d24da152469258a4cb35b3ce591ea2fd961",
|
||||
"2.1.7": "a04725662933fbbe3ad4a319d03267fc32907242",
|
||||
"2.1.8": "6c3f42dad5840210ee7294ca295f6c7b18c32291",
|
||||
"2.1.9": "0f1e8530e89a9432678ed6fe4fef25d0485d1293",
|
||||
"2.2.1": "f15ff1ca73b02ff5f522c9fe59004331b1b410fb",
|
||||
"2.2.2": "18a42e0e8980e3edc39198b18c5c4b9a464ea381",
|
||||
"2.2.3": "c4d0e69abf2b9caa88b997ca1f2935b6e0b00c9f",
|
||||
"2.2.5": "d71a01615883fffa53fbd28e578db14353628a52",
|
||||
"2.2.6": "eb60a76b7454975d151f2d8b5d9e19b26d561c2d",
|
||||
"2.2.7": "72bd93de8dd64cc5de8986860819a5873ce08fe5",
|
||||
"2.2.8": "6a2e390a79c4f0444a03b566d4bf24849a6ee3a3",
|
||||
};
|
||||
function selectVersion(version) {
|
||||
version = version || core.getInput('xmake-version') || 'latest';
|
||||
if (version.toLowerCase() === 'latest')
|
||||
version = '';
|
||||
version = semver.validRange(version);
|
||||
if (!version)
|
||||
throw new Error(`Invalid input xmake-version: ${core.getInput('xmake-version')}`);
|
||||
const ver = semver.maxSatisfying(Object.keys(exports.versions), version);
|
||||
if (!ver)
|
||||
throw new Error(`No matched releases of xmake-version: ${version}`);
|
||||
const sha = exports.versions[ver];
|
||||
core.info(`selected xmake v${ver} (commit: ${sha.substr(0, 8)})`);
|
||||
return { version: ver, sha };
|
||||
}
|
||||
exports.selectVersion = selectVersion;
|
||||
Reference in New Issue
Block a user