diff --git a/dist/unix-install.js b/dist/unix-install.js index f02fb51..79e931d 100644 --- a/dist/unix-install.js +++ b/dist/unix-install.js @@ -9,21 +9,22 @@ const path = require("path"); const semver = require("semver"); const git = require("./git"); async function unixInstall(version) { - let toolDir = toolCache.find('xmake', version.version); + const ver = version.version; + let toolDir = toolCache.find('xmake', ver); if (!toolDir) { const sourceDir = await core.group(`download xmake ${version}`, () => git.create(version.sha)); toolDir = await core.group(`install xmake ${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', version.version); + 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(version.version, '2.3.1')) { + if (version.type !== 'tags' || semver.gt(ver, '2.3.1')) { core.addPath(path.join(toolDir, 'bin')); } else { diff --git a/dist/win-install.js b/dist/win-install.js index bf9f00f..fe1c8e0 100644 --- a/dist/win-install.js +++ b/dist/win-install.js @@ -8,14 +8,15 @@ const os = require("os"); const path = require("path"); const semver = require("semver"); async function winInstall(version) { - let toolDir = toolCache.find('xmake', version.version); + const ver = version.version; + let toolDir = toolCache.find('xmake', ver); 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}`; + url = `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}`; } else if (version.type === 'pull') { throw new Error('PR builds for windows is not supported'); @@ -23,9 +24,9 @@ async function winInstall(version) { 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`; + url = 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`; } core.info(`downloading from ${url}`); const file = await toolCache.downloadTool(url); @@ -39,7 +40,7 @@ async function winInstall(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.version); + const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver); await io.rmRF(binDir); await io.rmRF(installer); return cacheDir; diff --git a/src/unix-install.ts b/src/unix-install.ts index ba9f9fe..63608eb 100644 --- a/src/unix-install.ts +++ b/src/unix-install.ts @@ -9,21 +9,22 @@ import * as git from './git'; import { Version } from './versions'; export async function unixInstall(version: Version): Promise { - let toolDir = toolCache.find('xmake', version.version); + const ver = version.version; + let toolDir = toolCache.find('xmake', ver); if (!toolDir) { const sourceDir = await core.group(`download xmake ${version}`, () => git.create(version.sha)); toolDir = await core.group(`install xmake ${version}`, async () => { await exec('make', ['build'], { cwd: sourceDir }); const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`); await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir }); - const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version.version); + 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(version.version, '2.3.1')) { + if (version.type !== 'tags' || semver.gt(ver, '2.3.1')) { core.addPath(path.join(toolDir, 'bin')); } else { core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1 diff --git a/src/win-install.ts b/src/win-install.ts index cff24e6..2507db0 100644 --- a/src/win-install.ts +++ b/src/win-install.ts @@ -8,22 +8,23 @@ import * as semver from 'semver'; import { Version } from './versions'; export async function winInstall(version: Version): Promise { - let toolDir = toolCache.find('xmake', version.version); + const ver = version.version; + let toolDir = toolCache.find('xmake', ver); 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}`; + url = `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}`; } 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`; + url = 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`; } core.info(`downloading from ${url}`); const file = await toolCache.downloadTool(url); @@ -37,7 +38,7 @@ export async function winInstall(version: Version): Promise { core.info(`installing to ${binDir}`); await exec(`"${installer}" /NOADMIN /S /D=${binDir}`); core.info(`installed to ${binDir}`); - const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version.version); + const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver); await io.rmRF(binDir); await io.rmRF(installer); return cacheDir;