support local
This commit is contained in:
Vendored
+24
-10
@@ -1,10 +1,29 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cleanup = exports.create = exports.lsRemote = void 0;
|
||||
const exec_1 = require("@actions/exec");
|
||||
const io = require("@actions/io");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
const io = __importStar(require("@actions/io"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
function makeOpt(ref) {
|
||||
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
|
||||
}
|
||||
@@ -22,21 +41,16 @@ async function lsRemote(repo) {
|
||||
const [ref, tag] = line.trim().split('\t');
|
||||
if (ref && tag && tag.startsWith('refs/')) {
|
||||
const tagPath = tag.split('/').splice(1);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let ldata = data; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
||||
let ldata = data;
|
||||
for (let i = 0; i < tagPath.length - 1; i++) {
|
||||
const seg = tagPath[i];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
if (typeof ldata[seg] === 'object') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
ldata = ldata[seg]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
||||
ldata = ldata[seg];
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
ldata = ldata[seg] = {};
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
ldata[tagPath[tagPath.length - 1]] = ref;
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+21
-2
@@ -1,8 +1,27 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = require("@actions/core");
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec_1 = require("@actions/exec");
|
||||
const os = require("os");
|
||||
const os = __importStar(require("os"));
|
||||
const versions_1 = require("./versions");
|
||||
const win_install_1 = require("./win-install");
|
||||
const unix_install_1 = require("./unix-install");
|
||||
|
||||
Vendored
+59
-25
@@ -1,35 +1,69 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.unixInstall = void 0;
|
||||
const core = require("@actions/core");
|
||||
const core_1 = __importDefault(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");
|
||||
const git = require("./git");
|
||||
const io_1 = __importDefault(require("@actions/io"));
|
||||
const tool_cache_1 = __importDefault(require("@actions/tool-cache"));
|
||||
const os_1 = __importDefault(require("os"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const semver_1 = __importDefault(require("semver"));
|
||||
const git = __importStar(require("./git"));
|
||||
async function install(sourceDir, binDir) {
|
||||
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
||||
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||
}
|
||||
async function unixInstall(version) {
|
||||
const ver = version.version;
|
||||
let toolDir = toolCache.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
const sourceDir = await core.group(`download xmake ${String(version)}`, () => git.create(version.repo, version.sha));
|
||||
toolDir = await core.group(`install xmake ${String(version)}`, 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', ver);
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
// for versions 2.3.2 and above, xmake will be installed directly into the bin directory, and no script will be used to wrap it.
|
||||
if (version.type !== 'tags' || semver.gt(ver, '2.3.1')) {
|
||||
core.addPath(path.join(toolDir, 'bin'));
|
||||
let toolDir;
|
||||
if (version.type !== 'local') {
|
||||
const ver = version.version;
|
||||
toolDir = tool_cache_1.default.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
const sourceDir = await core_1.default.group(`download xmake ${String(version)}`, () => git.create(version.repo, version.sha));
|
||||
toolDir = await core_1.default.group(`install xmake ${String(version)}`, async () => {
|
||||
const binDir = path_1.default.join(os_1.default.tmpdir(), `xmake-${version.sha}`);
|
||||
await install(sourceDir, binDir);
|
||||
const cacheDir = await tool_cache_1.default.cacheDir(binDir, 'xmake', ver);
|
||||
await io_1.default.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||
toolDir = await core_1.default.group(`install local xmake at '${version.path}'`, async () => {
|
||||
const binDir = path_1.default.join(os_1.default.tmpdir(), `xmake-${Date.now()}`);
|
||||
await install(version.path, binDir);
|
||||
return binDir;
|
||||
});
|
||||
}
|
||||
if (version.type !== 'tags' || semver_1.default.gt(version.version, '2.3.1')) {
|
||||
core_1.default.addPath(path_1.default.join(toolDir, 'bin'));
|
||||
}
|
||||
else {
|
||||
core_1.default.addPath(path_1.default.join(toolDir, 'share', 'xmake'));
|
||||
}
|
||||
}
|
||||
exports.unixInstall = unixInstall;
|
||||
|
||||
Vendored
+53
-20
@@ -1,4 +1,23 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to set private field on non-instance");
|
||||
@@ -12,13 +31,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
||||
}
|
||||
return privateMap.get(receiver);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var _string;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.selectVersion = void 0;
|
||||
const core = require("@actions/core");
|
||||
const semver = require("semver");
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const semver_1 = __importDefault(require("semver"));
|
||||
const git_1 = require("./git");
|
||||
const interfaces_1 = require("./interfaces");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const DEFAULT_REPO = interfaces_1.Repo('xmake-io/xmake');
|
||||
const VERSIONS = new Map();
|
||||
async function getVersions(repo) {
|
||||
@@ -29,7 +52,7 @@ async function getVersions(repo) {
|
||||
VERSIONS.set(repo, result);
|
||||
return result;
|
||||
}
|
||||
class VersionImpl {
|
||||
class GitVersionImpl {
|
||||
constructor(repo, version, sha, type, toString) {
|
||||
this.repo = repo;
|
||||
this.version = version;
|
||||
@@ -43,10 +66,17 @@ class VersionImpl {
|
||||
}
|
||||
}
|
||||
_string = new WeakMap();
|
||||
class LocalVersionImpl {
|
||||
constructor(path) {
|
||||
this.path = path;
|
||||
this.type = 'local';
|
||||
this.path = path_1.default.resolve(path);
|
||||
}
|
||||
}
|
||||
async function selectBranch(repo, branch) {
|
||||
const versions = await getVersions(repo);
|
||||
if (branch in versions.heads) {
|
||||
return new VersionImpl(repo, branch, versions.heads[branch], 'heads', `branch ${branch}`);
|
||||
return new GitVersionImpl(repo, branch, versions.heads[branch], 'heads', `branch ${branch}`);
|
||||
}
|
||||
throw new Error(`Branch ${branch} not found`);
|
||||
}
|
||||
@@ -54,27 +84,26 @@ async function selectPr(repo, pr) {
|
||||
var _a;
|
||||
const versions = await getVersions(repo);
|
||||
if (pr in versions.pull) {
|
||||
const prheads = versions.pull[pr];
|
||||
const sha = (_a = prheads.merge) !== null && _a !== void 0 ? _a : prheads.head;
|
||||
const prHeads = versions.pull[pr];
|
||||
const sha = (_a = prHeads.merge) !== null && _a !== void 0 ? _a : prHeads.head;
|
||||
if (sha) {
|
||||
return new VersionImpl(repo, `pr#${pr}`, sha, 'pull', `pull request #${pr}`);
|
||||
return new GitVersionImpl(repo, `pr#${pr}`, sha, 'pull', `pull request #${pr}`);
|
||||
}
|
||||
}
|
||||
throw new Error(`Pull requrest #${pr} not found`);
|
||||
}
|
||||
async function selectSemver(repo, version) {
|
||||
// check version valid
|
||||
const v = new semver.Range(version);
|
||||
const v = new semver_1.default.Range(version);
|
||||
if (!v) {
|
||||
throw new Error(`Invalid semver`);
|
||||
}
|
||||
const versions = await getVersions(repo);
|
||||
const ver = semver.maxSatisfying(Object.keys(versions.tags), v);
|
||||
const ver = semver_1.default.maxSatisfying(Object.keys(versions.tags), v);
|
||||
if (!ver) {
|
||||
throw new Error(`No matched releases of xmake-version ${v.format()}`);
|
||||
}
|
||||
const sha = versions.tags[ver];
|
||||
return new VersionImpl(repo, ver, sha, 'tags', ver);
|
||||
return new GitVersionImpl(repo, ver, sha, 'tags', ver);
|
||||
}
|
||||
async function selectSha(repo, sha) {
|
||||
var _a;
|
||||
@@ -96,15 +125,18 @@ async function selectSha(repo, sha) {
|
||||
return selectPr(repo, Number.parseInt(pr));
|
||||
}
|
||||
}
|
||||
return Promise.resolve(new VersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substr(0, 8)}`));
|
||||
return Promise.resolve(new GitVersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substr(0, 8)}`));
|
||||
}
|
||||
async function selectVersion(version) {
|
||||
// get version string
|
||||
version = (version !== null && version !== void 0 ? version : core.getInput('xmake-version')) || 'latest';
|
||||
if (version.toLowerCase() === 'latest')
|
||||
version = '';
|
||||
let repo = DEFAULT_REPO;
|
||||
let ret;
|
||||
if (version.startsWith('local#')) {
|
||||
const path = version.slice('local#'.length);
|
||||
ret = new LocalVersionImpl(path);
|
||||
}
|
||||
{
|
||||
const match = /^([^/#]+\/[^/#]+)#(.+)$/.exec(version);
|
||||
if (match) {
|
||||
@@ -112,12 +144,10 @@ async function selectVersion(version) {
|
||||
version = match[2];
|
||||
}
|
||||
}
|
||||
// select branch
|
||||
if (version.startsWith('branch@')) {
|
||||
const branch = version.substr('branch@'.length);
|
||||
ret = await selectBranch(repo, branch);
|
||||
}
|
||||
// select pr
|
||||
if (version.startsWith('pr@')) {
|
||||
const pr = Number.parseInt(version.substr('pr@'.length));
|
||||
if (Number.isNaN(pr) || pr <= 0) {
|
||||
@@ -125,20 +155,23 @@ async function selectVersion(version) {
|
||||
}
|
||||
ret = await selectPr(repo, pr);
|
||||
}
|
||||
// select sha
|
||||
if (version.startsWith('sha@')) {
|
||||
const sha = version.substr('sha@'.length);
|
||||
ret = await selectSha(repo, sha);
|
||||
}
|
||||
// select version
|
||||
if (semver.validRange(version)) {
|
||||
if (semver_1.default.validRange(version)) {
|
||||
ret = await selectSemver(repo, version);
|
||||
}
|
||||
if (!ret) {
|
||||
throw new Error(`Invalid input xmake-version ${core.getInput('xmake-version')}`);
|
||||
}
|
||||
core.info(`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` +
|
||||
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''));
|
||||
if (ret.type === 'local') {
|
||||
core.info(`Use local xmake at '${ret.path}'`);
|
||||
}
|
||||
else {
|
||||
core.info(`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` +
|
||||
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
exports.selectVersion = selectVersion;
|
||||
|
||||
Vendored
+28
-10
@@ -1,18 +1,36 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.winInstall = void 0;
|
||||
const core = require("@actions/core");
|
||||
const core = __importStar(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");
|
||||
const io = __importStar(require("@actions/io"));
|
||||
const toolCache = __importStar(require("@actions/tool-cache"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const semver = __importStar(require("semver"));
|
||||
function getInstallerUrl(version) {
|
||||
const ver = version.version;
|
||||
switch (version.type) {
|
||||
case 'heads': {
|
||||
// we only use appveyor ci artifacts for branch version
|
||||
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
|
||||
return `https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=${ver}&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+${arch}`;
|
||||
}
|
||||
@@ -23,21 +41,21 @@ function getInstallerUrl(version) {
|
||||
throw new Error('Sha builds for windows is not supported');
|
||||
}
|
||||
case 'tags': {
|
||||
// we cannot use appveyor ci artifacts, the old version links may be broken.
|
||||
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
|
||||
return semver.gt(ver, '2.2.6')
|
||||
? `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.${arch}.exe`
|
||||
: `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.exe`;
|
||||
}
|
||||
default: {
|
||||
// check that we have tested all types
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const _ = version.type;
|
||||
throw new Error('Unknown version type');
|
||||
}
|
||||
}
|
||||
}
|
||||
async function winInstall(version) {
|
||||
if (version.type === 'local') {
|
||||
throw new Error('Local builds for windows is not supported');
|
||||
}
|
||||
const ver = version.version;
|
||||
let toolDir = toolCache.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
|
||||
Reference in New Issue
Block a user