Merge pull request #2 from waruqi/master
support to select xmake/branch and fix links
This commit is contained in:
@@ -7,10 +7,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
- ubuntu-latest
|
|
||||||
- windows-latest
|
|
||||||
- macOS-latest
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ with:
|
|||||||
xmake-version: '2.3.1'
|
xmake-version: '2.3.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Use specified branch:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: branch@master
|
||||||
|
```
|
||||||
|
|
||||||
Use semver:
|
Use semver:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
|
|||||||
Vendored
+25
-10
@@ -9,14 +9,23 @@ const path = require("path");
|
|||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
const git = require("./git");
|
const git = require("./git");
|
||||||
const versions_1 = require("./versions");
|
const versions_1 = require("./versions");
|
||||||
async function winInstall(version) {
|
async function winInstall(version, sha) {
|
||||||
let toolDir = toolCache.find('xmake', version);
|
let toolDir = toolCache.find('xmake', version);
|
||||||
if (!toolDir) {
|
if (!toolDir) {
|
||||||
const installer = await core.group('download xmake', async () => {
|
const installer = await core.group(`download xmake ${version}`, async () => {
|
||||||
|
let url = "";
|
||||||
|
if (version.startsWith("branch@")) {
|
||||||
|
// we only use appveyor ci artifacts for branch version
|
||||||
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
|
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
|
||||||
const url = semver.gt(version, '2.2.6')
|
url = `https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=${sha}&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+${arch}`;
|
||||||
? `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`;
|
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, '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}`);
|
core.info(`downloading from ${url}`);
|
||||||
const file = await toolCache.downloadTool(url);
|
const file = await toolCache.downloadTool(url);
|
||||||
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });
|
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });
|
||||||
@@ -24,7 +33,7 @@ async function winInstall(version) {
|
|||||||
core.info(`downloaded to ${exe}`);
|
core.info(`downloaded to ${exe}`);
|
||||||
return exe;
|
return exe;
|
||||||
});
|
});
|
||||||
toolDir = await core.group('install xmake', async () => {
|
toolDir = await core.group(`install xmake ${version}`, async () => {
|
||||||
const binDir = path.join(os.tmpdir(), `xmake-${version}`);
|
const binDir = path.join(os.tmpdir(), `xmake-${version}`);
|
||||||
core.info(`installing to ${binDir}`);
|
core.info(`installing to ${binDir}`);
|
||||||
await exec_1.exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
await exec_1.exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
||||||
@@ -40,8 +49,8 @@ async function winInstall(version) {
|
|||||||
async function unixInstall(version, sha) {
|
async function unixInstall(version, sha) {
|
||||||
let toolDir = toolCache.find('xmake', version);
|
let toolDir = toolCache.find('xmake', version);
|
||||||
if (!toolDir) {
|
if (!toolDir) {
|
||||||
const sourceDir = await core.group('download xmake', () => git.create(sha));
|
const sourceDir = await core.group(`download xmake ${version}`, () => git.create(sha));
|
||||||
toolDir = await core.group('install xmake', async () => {
|
toolDir = await core.group(`install xmake ${version}`, async () => {
|
||||||
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
||||||
const binDir = path.join(os.tmpdir(), `xmake-${version}-${sha}`);
|
const binDir = path.join(os.tmpdir(), `xmake-${version}-${sha}`);
|
||||||
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||||
@@ -51,13 +60,19 @@ async function unixInstall(version, sha) {
|
|||||||
return cacheDir;
|
return cacheDir;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
core.addPath(path.join(toolDir, 'share', 'xmake'));
|
// 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.startsWith("branch@") || semver.gt(version, '2.3.1')) {
|
||||||
|
core.addPath(path.join(toolDir, 'bin'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const { version, sha } = await versions_1.selectVersion();
|
const { version, sha } = await versions_1.selectVersion();
|
||||||
if (os.platform() === 'win32' || os.platform() === 'cygwin')
|
if (os.platform() === 'win32' || os.platform() === 'cygwin')
|
||||||
await winInstall(version);
|
await winInstall(version, sha);
|
||||||
else
|
else
|
||||||
await unixInstall(version, sha);
|
await unixInstall(version, sha);
|
||||||
await exec_1.exec('xmake --version');
|
await exec_1.exec('xmake --version');
|
||||||
|
|||||||
Vendored
+9
-1
@@ -4,9 +4,17 @@ const core = require("@actions/core");
|
|||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
const git_1 = require("./git");
|
const git_1 = require("./git");
|
||||||
async function selectVersion(version) {
|
async function selectVersion(version) {
|
||||||
|
// get version string
|
||||||
version = (version !== null && version !== void 0 ? version : core.getInput('xmake-version')) || 'latest';
|
version = (version !== null && version !== void 0 ? version : core.getInput('xmake-version')) || 'latest';
|
||||||
if (version.toLowerCase() === 'latest')
|
if (version.toLowerCase() === 'latest')
|
||||||
version = '';
|
version = '';
|
||||||
|
// select branch
|
||||||
|
if (version.startsWith('branch@')) {
|
||||||
|
const branch = version.substr(7);
|
||||||
|
core.info(`Selected xmake branch: ${branch}`);
|
||||||
|
return { version: version, sha: branch };
|
||||||
|
}
|
||||||
|
// select version
|
||||||
version = semver.validRange(version);
|
version = semver.validRange(version);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
throw new Error(`Invalid input xmake-version: ${core.getInput('xmake-version')}`);
|
throw new Error(`Invalid input xmake-version: ${core.getInput('xmake-version')}`);
|
||||||
@@ -17,7 +25,7 @@ async function selectVersion(version) {
|
|||||||
throw new Error(`No matched releases of xmake-version: ${version}`);
|
throw new Error(`No matched releases of xmake-version: ${version}`);
|
||||||
}
|
}
|
||||||
const sha = versions[ver];
|
const sha = versions[ver];
|
||||||
core.info(`selected xmake v${ver} (commit: ${sha.substr(0, 8)})`);
|
core.info(`Selected xmake v${ver} (commit: ${sha.substr(0, 8)})`);
|
||||||
return { version: ver, sha };
|
return { version: ver, sha };
|
||||||
}
|
}
|
||||||
exports.selectVersion = selectVersion;
|
exports.selectVersion = selectVersion;
|
||||||
|
|||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../semver/bin/semver.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../semver/bin/semver.js
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\semver\bin\semver.js" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\semver\bin\semver.js" %*
|
|
||||||
)
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../uuid/bin/uuid" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../uuid/bin/uuid" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../uuid/bin/uuid
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\uuid\bin\uuid" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\uuid\bin\uuid" %*
|
|
||||||
)
|
|
||||||
+2
-4
@@ -1,11 +1,9 @@
|
|||||||
{
|
{
|
||||||
"systemParams": "win32-x64-72",
|
"systemParams": "darwin-x64-72",
|
||||||
"modulesFolders": [
|
"modulesFolders": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
],
|
],
|
||||||
"flags": [
|
"flags": [],
|
||||||
"production"
|
|
||||||
],
|
|
||||||
"linkedModules": [],
|
"linkedModules": [],
|
||||||
"topLevelPatterns": [
|
"topLevelPatterns": [
|
||||||
"@actions/core@^1.1.3",
|
"@actions/core@^1.1.3",
|
||||||
|
|||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../semver/bin/semver.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../semver/bin/semver.js
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\semver\bin\semver.js" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\semver\bin\semver.js" %*
|
|
||||||
)
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../../../../uuid/bin/uuid" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../../../../uuid/bin/uuid" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../../../../uuid/bin/uuid
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\..\..\..\uuid\bin\uuid" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\..\..\..\uuid\bin\uuid" %*
|
|
||||||
)
|
|
||||||
Generated
Vendored
Regular → Executable
+24
-10
@@ -8,14 +8,22 @@ import * as semver from 'semver';
|
|||||||
import * as git from './git';
|
import * as git from './git';
|
||||||
import { selectVersion } from './versions';
|
import { selectVersion } from './versions';
|
||||||
|
|
||||||
async function winInstall(version: string): Promise<void> {
|
async function winInstall(version: string, sha: string): Promise<void> {
|
||||||
let toolDir = toolCache.find('xmake', version);
|
let toolDir = toolCache.find('xmake', version);
|
||||||
if (!toolDir) {
|
if (!toolDir) {
|
||||||
const installer = await core.group('download xmake', async () => {
|
const installer = await core.group(`download xmake ${version}`, async () => {
|
||||||
|
let url = "";
|
||||||
|
if (version.startsWith("branch@")) {
|
||||||
|
// we only use appveyor ci artifacts for branch version
|
||||||
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
|
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
|
||||||
const url = semver.gt(version, '2.2.6')
|
url = `https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=${sha}&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+${arch}`;
|
||||||
? `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}`
|
} else {
|
||||||
: `https://github.com/xmake-io/xmake/releases/download/v$v/xmake-v${version}.exe`;
|
// we cannot use appveyor ci artifacts, the old version links may be broken.
|
||||||
|
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
|
||||||
|
url = semver.gt(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}`);
|
core.info(`downloading from ${url}`);
|
||||||
const file = await toolCache.downloadTool(url);
|
const file = await toolCache.downloadTool(url);
|
||||||
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });
|
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });
|
||||||
@@ -23,7 +31,7 @@ async function winInstall(version: string): Promise<void> {
|
|||||||
core.info(`downloaded to ${exe}`);
|
core.info(`downloaded to ${exe}`);
|
||||||
return exe;
|
return exe;
|
||||||
});
|
});
|
||||||
toolDir = await core.group('install xmake', async () => {
|
toolDir = await core.group(`install xmake ${version}`, async () => {
|
||||||
const binDir = path.join(os.tmpdir(), `xmake-${version}`);
|
const binDir = path.join(os.tmpdir(), `xmake-${version}`);
|
||||||
core.info(`installing to ${binDir}`);
|
core.info(`installing to ${binDir}`);
|
||||||
await exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
await exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
||||||
@@ -40,8 +48,8 @@ async function winInstall(version: string): Promise<void> {
|
|||||||
async function unixInstall(version: string, sha: string): Promise<void> {
|
async function unixInstall(version: string, sha: string): Promise<void> {
|
||||||
let toolDir = toolCache.find('xmake', version);
|
let toolDir = toolCache.find('xmake', version);
|
||||||
if (!toolDir) {
|
if (!toolDir) {
|
||||||
const sourceDir = await core.group('download xmake', () => git.create(sha));
|
const sourceDir = await core.group(`download xmake ${version}`, () => git.create(sha));
|
||||||
toolDir = await core.group('install xmake', async () => {
|
toolDir = await core.group(`install xmake ${version}`, async () => {
|
||||||
await exec('make', ['build'], { cwd: sourceDir });
|
await exec('make', ['build'], { cwd: sourceDir });
|
||||||
const binDir = path.join(os.tmpdir(), `xmake-${version}-${sha}`);
|
const binDir = path.join(os.tmpdir(), `xmake-${version}-${sha}`);
|
||||||
await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||||
@@ -51,13 +59,19 @@ async function unixInstall(version: string, sha: string): Promise<void> {
|
|||||||
return cacheDir;
|
return cacheDir;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
core.addPath(path.join(toolDir, 'share', 'xmake'));
|
|
||||||
|
// 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.startsWith("branch@") || semver.gt(version, '2.3.1')) {
|
||||||
|
core.addPath(path.join(toolDir, 'bin'));
|
||||||
|
} else {
|
||||||
|
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const { version, sha } = await selectVersion();
|
const { version, sha } = await selectVersion();
|
||||||
if (os.platform() === 'win32' || os.platform() === 'cygwin') await winInstall(version);
|
if (os.platform() === 'win32' || os.platform() === 'cygwin') await winInstall(version, sha);
|
||||||
else await unixInstall(version, sha);
|
else await unixInstall(version, sha);
|
||||||
await exec('xmake --version');
|
await exec('xmake --version');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
+12
-1
@@ -3,8 +3,19 @@ import * as semver from 'semver';
|
|||||||
import { lsRemote } from './git';
|
import { lsRemote } from './git';
|
||||||
|
|
||||||
export async function selectVersion(version?: string): Promise<{ version: string; sha: string }> {
|
export async function selectVersion(version?: string): Promise<{ version: string; sha: string }> {
|
||||||
|
|
||||||
|
// get version string
|
||||||
version = (version ?? core.getInput('xmake-version')) || 'latest';
|
version = (version ?? core.getInput('xmake-version')) || 'latest';
|
||||||
if (version.toLowerCase() === 'latest') version = '';
|
if (version.toLowerCase() === 'latest') version = '';
|
||||||
|
|
||||||
|
// select branch
|
||||||
|
if (version.startsWith('branch@')) {
|
||||||
|
const branch = version.substr(7);
|
||||||
|
core.info(`Selected xmake branch: ${branch}`);
|
||||||
|
return { version: version, sha: branch };
|
||||||
|
}
|
||||||
|
|
||||||
|
// select version
|
||||||
version = semver.validRange(version);
|
version = semver.validRange(version);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
throw new Error(`Invalid input xmake-version: ${core.getInput('xmake-version')}`);
|
throw new Error(`Invalid input xmake-version: ${core.getInput('xmake-version')}`);
|
||||||
@@ -17,6 +28,6 @@ export async function selectVersion(version?: string): Promise<{ version: string
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sha = versions[ver];
|
const sha = versions[ver];
|
||||||
core.info(`selected xmake v${ver} (commit: ${sha.substr(0, 8)})`);
|
core.info(`Selected xmake v${ver} (commit: ${sha.substr(0, 8)})`);
|
||||||
return { version: ver, sha };
|
return { version: ver, sha };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user