This commit is contained in:
OpportunityLiu
2020-03-31 19:03:08 +08:00
Unverified
parent 11d52ba768
commit 2836246660
151 changed files with 0 additions and 12284 deletions
-50
View File
@@ -1,50 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core = require("@actions/core");
const exec_1 = require("@actions/exec");
const io = require("@actions/io");
const toolCache = require("@actions/tool-cache");
const os = require("os");
const path = require("path");
const semver = require("semver");
async function winInstall(version) {
let toolDir = toolCache.find('xmake', version.version);
if (!toolDir) {
const installer = await core.group(`download xmake ${version}`, async () => {
let url = '';
if (version.type === 'heads') {
// we only use appveyor ci artifacts for branch version
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
url = `https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=${version.version}&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+${arch}`;
}
else if (version.type === 'pull') {
throw new Error('PR builds for windows is not supported');
}
else {
// we cannot use appveyor ci artifacts, the old version links may be broken.
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
url = semver.gt(version.version, '2.2.6')
? `https://github.com/xmake-io/xmake/releases/download/v${version}/xmake-v${version}.${arch}.exe`
: `https://github.com/xmake-io/xmake/releases/download/v${version}/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 io.mv(file, exe);
core.info(`downloaded to ${exe}`);
return exe;
});
toolDir = await core.group(`install xmake ${version}`, async () => {
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
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.version);
await io.rmRF(binDir);
await io.rmRF(installer);
return cacheDir;
});
}
core.addPath(toolDir);
}
exports.winInstall = winInstall;