mirror of
https://github.com/DeLaGuardo/setup-clojure.git
synced 2024-12-25 23:40:49 +08:00
Use clj-msi to install ClojureCLI on Windows
This commit is contained in:
parent
0747838008
commit
6104f5473d
57
.github/workflows/smoke-tests.yml
vendored
57
.github/workflows/smoke-tests.yml
vendored
@ -19,13 +19,13 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install clojure tools-deps
|
||||
uses: ./
|
||||
with:
|
||||
tools-deps: 1.10.1.693
|
||||
tools-deps: 1.11.4.1474
|
||||
|
||||
- name: Execute clojure code
|
||||
run: clojure -e "(+ 1 1)"
|
||||
@ -44,13 +44,13 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install Clojure CLI
|
||||
uses: ./
|
||||
with:
|
||||
cli: 1.11.1.1409
|
||||
cli: 1.11.4.1474
|
||||
|
||||
- name: Execute clojure code
|
||||
run: clojure -e "(+ 1 1)"
|
||||
@ -69,8 +69,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install Clojure CLI
|
||||
uses: ./
|
||||
@ -94,8 +94,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install leiningen
|
||||
uses: ./
|
||||
@ -115,8 +115,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install leiningen
|
||||
uses: ./
|
||||
@ -147,8 +147,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '11'
|
||||
distribution: "zulu"
|
||||
java-version: "11"
|
||||
|
||||
- name: Install boot
|
||||
uses: ./
|
||||
@ -173,8 +173,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install babashka
|
||||
uses: ./
|
||||
@ -199,8 +199,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install clj-kondo
|
||||
uses: ./
|
||||
@ -225,8 +225,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install cljfmt
|
||||
uses: ./
|
||||
@ -240,7 +240,7 @@ jobs:
|
||||
test-cljstyle:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest]
|
||||
os: [ubuntu-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@ -251,8 +251,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install cljstyle
|
||||
uses: ./
|
||||
@ -264,7 +264,6 @@ jobs:
|
||||
run: cljstyle version
|
||||
|
||||
test-zprint:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
@ -278,8 +277,8 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install zprint
|
||||
uses: ./
|
||||
@ -300,13 +299,13 @@ jobs:
|
||||
- name: Prepare java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
distribution: "zulu"
|
||||
java-version: "8"
|
||||
|
||||
- name: Install all the tools
|
||||
uses: ./
|
||||
with:
|
||||
cli: 1.11.1.1149
|
||||
cli: 1.11.4.1474
|
||||
lein: 2.11.0
|
||||
boot: 2.8.3
|
||||
bb: 0.8.157
|
||||
|
@ -46,7 +46,7 @@ jobs:
|
||||
java-version: '8'
|
||||
|
||||
- name: Install clojure tools
|
||||
uses: DeLaGuardo/setup-clojure@12.5
|
||||
uses: DeLaGuardo/setup-clojure@13.0
|
||||
with:
|
||||
# Install just one or all simultaneously
|
||||
# The value must indicate a particular version of the tool, or use 'latest'
|
||||
@ -58,7 +58,6 @@ jobs:
|
||||
clj-kondo: 2022.05.31 # Clj-kondo
|
||||
cljfmt: 0.10.2 # cljfmt
|
||||
cljstyle: 0.16.626 # cljstyle
|
||||
cmd-exe-workaround: 'latest' # Replaces `clojure` with `deps.clj` on Windows
|
||||
zprint: 1.2.3 # zprint
|
||||
|
||||
# Optional step:
|
||||
@ -95,8 +94,8 @@ jobs:
|
||||
run: cljfmt --version
|
||||
|
||||
- name: Get cljstyle version
|
||||
# cljstyle is not yet available for windows
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
# cljstyle is not yet available for windows and mac os
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: cljstyle version
|
||||
|
||||
- name: Get zprint version
|
||||
|
@ -74,7 +74,11 @@ describe('setup-clojure', () => {
|
||||
|
||||
await main()
|
||||
|
||||
expect(cli.setup).toHaveBeenCalledWith('1.2.3', 'Bearer auth token')
|
||||
expect(cli.setup).toHaveBeenCalledWith(
|
||||
'1.2.3',
|
||||
'auth token',
|
||||
'Bearer auth token'
|
||||
)
|
||||
})
|
||||
|
||||
it('sets up Clojure CLI tools', async () => {
|
||||
@ -83,7 +87,11 @@ describe('setup-clojure', () => {
|
||||
|
||||
await main()
|
||||
|
||||
expect(cli.setup).toHaveBeenCalledWith('1.2.3', 'Bearer auth token')
|
||||
expect(cli.setup).toHaveBeenCalledWith(
|
||||
'1.2.3',
|
||||
'auth token',
|
||||
'Bearer auth token'
|
||||
)
|
||||
})
|
||||
|
||||
it('sets up Babashka', async () => {
|
||||
|
@ -4,7 +4,9 @@ import * as _io from '@actions/io'
|
||||
import * as _tc from '@actions/tool-cache'
|
||||
import * as _http from '@actions/http-client'
|
||||
import * as _os from 'os'
|
||||
import * as _crypto from 'crypto'
|
||||
import * as _fs from '../src/fs'
|
||||
import * as _utils from '../src/utils'
|
||||
import {join} from 'path'
|
||||
import {VERSION} from '../src/version'
|
||||
|
||||
@ -33,6 +35,13 @@ const fs: jest.Mocked<typeof _fs> = _fs as never
|
||||
jest.mock('os')
|
||||
const os: jest.Mocked<typeof _os> = _os as never
|
||||
|
||||
jest.mock('../src/utils', () => ({
|
||||
...jest.requireActual('../src/utils'),
|
||||
getTempDir: jest.fn(),
|
||||
isMacOS: jest.fn()
|
||||
}))
|
||||
const utils: jest.Mocked<typeof _utils> = _utils as never
|
||||
|
||||
jest.mock('@actions/http-client', () => {
|
||||
return {
|
||||
HttpClient: jest.fn().mockImplementation(() => {
|
||||
@ -49,12 +58,17 @@ jest.mock('@actions/http-client', () => {
|
||||
}
|
||||
})
|
||||
|
||||
jest.mock('crypto')
|
||||
const crypto: jest.Mocked<typeof _crypto> = _crypto as never
|
||||
|
||||
describe('tdeps tests', () => {
|
||||
beforeAll(async () => {
|
||||
process.env['RUNNER_TOOL_CACHE'] = toolPath
|
||||
process.env['RUNNER_TEMP'] = tempPath
|
||||
os.arch.mockReturnValue('x64')
|
||||
os.platform.mockReturnValue('linux')
|
||||
utils.getTempDir.mockReturnValue(tempPath)
|
||||
crypto.randomUUID.mockReturnValue('123-123-123-123-123')
|
||||
jest.spyOn(global.Math, 'random').mockReturnValue(1)
|
||||
})
|
||||
|
||||
@ -75,11 +89,11 @@ describe('tdeps tests', () => {
|
||||
tc.downloadTool.mockResolvedValueOnce(downloadPath)
|
||||
tc.cacheDir.mockResolvedValueOnce(cachePath)
|
||||
|
||||
await tdeps.setup('1.10.1.469', 'auth token')
|
||||
await tdeps.setup('1.10.1.469', 'auth token', 'Bearer auth token')
|
||||
|
||||
expect(tc.downloadTool).toHaveBeenCalledWith(
|
||||
'https://download.clojure.org/install/linux-install-1.10.1.469.sh',
|
||||
undefined,
|
||||
join(tempPath, '123-123-123-123-123', 'linux-install-1.10.1.469.sh'),
|
||||
'auth token'
|
||||
)
|
||||
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
|
||||
@ -110,7 +124,7 @@ describe('tdeps tests', () => {
|
||||
|
||||
expect(tc.downloadTool).toHaveBeenCalledWith(
|
||||
'https://download.clojure.org/install/linux-install-1.2.3.sh',
|
||||
undefined,
|
||||
join(tempPath, '123-123-123-123-123', 'linux-install-1.2.3.sh'),
|
||||
'auth token'
|
||||
)
|
||||
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
|
||||
@ -134,7 +148,7 @@ describe('tdeps tests', () => {
|
||||
})
|
||||
|
||||
it('Supports macOS', async () => {
|
||||
os.platform.mockReturnValue('darwin')
|
||||
utils.isMacOS.mockReturnValue(true)
|
||||
|
||||
fs.readFile.mockResolvedValueOnce('install -D')
|
||||
fs.writeFile.mockResolvedValueOnce()
|
||||
@ -146,7 +160,7 @@ describe('tdeps tests', () => {
|
||||
|
||||
expect(tc.downloadTool).toHaveBeenCalledWith(
|
||||
'https://download.clojure.org/install/linux-install-1.2.3.sh',
|
||||
undefined,
|
||||
join(tempPath, '123-123-123-123-123', 'linux-install-1.2.3.sh'),
|
||||
'foo'
|
||||
)
|
||||
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
|
||||
|
163
dist/index.js
vendored
163
dist/index.js
vendored
@ -394,6 +394,7 @@ const path = __importStar(__nccwpck_require__(6928));
|
||||
const os = __importStar(__nccwpck_require__(857));
|
||||
const fs = __importStar(__nccwpck_require__(2621));
|
||||
const utils = __importStar(__nccwpck_require__(9277));
|
||||
const crypto = __importStar(__nccwpck_require__(6982));
|
||||
exports.identifier = 'ClojureToolsDeps';
|
||||
const client = new http.HttpClient('actions/setup-clojure', undefined, {
|
||||
allowRetries: true,
|
||||
@ -404,7 +405,7 @@ function toolVersion(version, githubAuth) {
|
||||
var _a;
|
||||
core.debug('=== Check tool version');
|
||||
if (version === 'latest') {
|
||||
const res = yield client.getJson('https://api.github.com/repos/clojure/brew-install/releases/latest', { Authorization: githubAuth });
|
||||
const res = yield client.getJson('https://api.github.com/repos/clojure/brew-install/releases/latest', githubAuth ? { Authorization: githubAuth } : {});
|
||||
const versionString = (_a = res.result) === null || _a === void 0 ? void 0 : _a.tag_name;
|
||||
if (versionString) {
|
||||
return versionString;
|
||||
@ -428,33 +429,33 @@ function getUrls(tag, githubAuth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
core.debug('=== Get download URLs');
|
||||
const res = yield client.getJson(`https://api.github.com/repos/clojure/brew-install/releases/tags/${tag}`, {
|
||||
Authorization: githubAuth
|
||||
});
|
||||
const res = yield client.getJson(`https://api.github.com/repos/clojure/brew-install/releases/tags/${tag}`, githubAuth
|
||||
? {
|
||||
Authorization: githubAuth
|
||||
}
|
||||
: {});
|
||||
const posix_install_url = `https://github.com/clojure/brew-install/releases/download/${tag}/posix-install.sh`;
|
||||
const assets = (_a = res.result) === null || _a === void 0 ? void 0 : _a.assets;
|
||||
if (assets && isResourceProvided(posix_install_url, assets)) {
|
||||
return {
|
||||
posix: posix_install_url,
|
||||
linux: `https://github.com/clojure/brew-install/releases/download/${tag}/linux-install.sh`,
|
||||
windows: `github.com/clojure/brew-install/releases/download/${tag}/win-install.ps1`
|
||||
windows: `https://github.com/casselc/clj-msi/releases/tag/v${tag}/clojure-${tag}.msi`
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
linux: `https://download.clojure.org/install/linux-install-${tag}.sh`,
|
||||
windows: `download.clojure.org/install/win-install-${tag}.ps1`
|
||||
windows: `https://github.com/casselc/clj-msi/releases/tag/v${tag}/clojure-${tag}.msi`
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
function setup(requestedVersion, githubAuth) {
|
||||
function setup(requestedVersion, githubToken, githubAuthToken) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.debug('=== Run setup');
|
||||
const version = yield toolVersion(requestedVersion, githubAuth);
|
||||
const installDir = utils.isWindows()
|
||||
? 'C:\\Program Files\\WindowsPowerShell\\Modules'
|
||||
: '/tmp/usr/local/opt';
|
||||
const version = yield toolVersion(requestedVersion, githubAuthToken);
|
||||
const installDir = utils.isWindows() ? 'C:\\tools' : '/tmp/usr/local/opt';
|
||||
const toolPath = tc.find(exports.identifier, utils.getCacheVersionString(version), os.arch());
|
||||
if (toolPath) {
|
||||
core.info(`Clojure CLI found in cache ${toolPath}`);
|
||||
@ -464,37 +465,48 @@ function setup(requestedVersion, githubAuth) {
|
||||
});
|
||||
}
|
||||
else {
|
||||
const { linux, posix, windows } = yield getUrls(version, githubAuth);
|
||||
const { linux, posix, windows } = yield getUrls(version, githubAuthToken);
|
||||
const url = utils.isMacOS()
|
||||
? posix || linux
|
||||
: utils.isWindows()
|
||||
? windows
|
||||
: linux;
|
||||
const installerFileName = url.split(/\//).pop() || '';
|
||||
const outputDir = path.join(utils.getTempDir(), crypto.randomUUID());
|
||||
const outputFile = path.join(outputDir, installerFileName);
|
||||
let clojureInstallScript;
|
||||
if (utils.isWindows()) {
|
||||
yield exec.exec(`powershell -c "iwr -useb ${windows} | iex"`, [], {
|
||||
// Install to a modules location common to powershell/pwsh
|
||||
env: { PSModulePath: installDir },
|
||||
input: Buffer.from('1')
|
||||
yield exec.exec('gh', [
|
||||
'release',
|
||||
'-R',
|
||||
'casselc/clj-msi',
|
||||
'download',
|
||||
`v${version}`,
|
||||
'-D',
|
||||
`${outputDir}`
|
||||
], {
|
||||
env: { GH_TOKEN: githubToken }
|
||||
});
|
||||
core.debug(`clojure tools deps installed to ${path.join(installDir, 'ClojureTools')}`);
|
||||
yield tc.cacheDir(path.join(installDir, 'ClojureTools'), exports.identifier, utils.getCacheVersionString(version));
|
||||
clojureInstallScript = path.join(outputDir, `clojure-${version}.msi`);
|
||||
}
|
||||
else {
|
||||
let clojureInstallScript;
|
||||
if (utils.isMacOS()) {
|
||||
if (posix) {
|
||||
clojureInstallScript = yield tc.downloadTool(posix, undefined, githubAuth);
|
||||
}
|
||||
else {
|
||||
clojureInstallScript = yield tc.downloadTool(linux, undefined, githubAuth);
|
||||
yield MacOSDeps(clojureInstallScript, githubAuth);
|
||||
}
|
||||
}
|
||||
else {
|
||||
clojureInstallScript = yield tc.downloadTool(linux, undefined, githubAuth);
|
||||
}
|
||||
const clojureToolsDir = yield runLinuxInstall(clojureInstallScript, path.join(installDir, 'ClojureTools'));
|
||||
core.debug(`clojure tools deps installed to ${clojureToolsDir}`);
|
||||
yield tc.cacheDir(clojureToolsDir, exports.identifier, utils.getCacheVersionString(version));
|
||||
clojureInstallScript = yield tc.downloadTool(url, outputFile, githubToken);
|
||||
}
|
||||
core.debug(`Finish downloading of installation script to ${clojureInstallScript}`);
|
||||
if (utils.isMacOS() && !posix) {
|
||||
yield MacOSDeps(clojureInstallScript, githubToken);
|
||||
}
|
||||
const clojureToolsDir = utils.isWindows()
|
||||
? yield runWindowsInstall(clojureInstallScript, path.join(installDir, 'ClojureTools'), githubToken)
|
||||
: yield runLinuxInstall(clojureInstallScript, path.join(installDir, 'ClojureTools'));
|
||||
core.debug(`clojure tools deps installed to ${clojureToolsDir}`);
|
||||
yield tc.cacheDir(clojureToolsDir, exports.identifier, utils.getCacheVersionString(version));
|
||||
}
|
||||
core.exportVariable('CLOJURE_INSTALL_DIR', path.join(installDir, 'ClojureTools'));
|
||||
if (!utils.isWindows()) {
|
||||
if (utils.isWindows()) {
|
||||
core.addPath(path.join(installDir, 'ClojureTools'));
|
||||
}
|
||||
else {
|
||||
core.addPath(path.join(installDir, 'ClojureTools', 'bin'));
|
||||
}
|
||||
});
|
||||
@ -508,6 +520,23 @@ function runLinuxInstall(installScript, destinationFolder) {
|
||||
return destinationFolder;
|
||||
});
|
||||
}
|
||||
function runWindowsInstall(installScript, destinationFolder, githubAuth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.debug('=== Install on Windows');
|
||||
yield io.mkdirP(destinationFolder);
|
||||
core.debug(`installing from ${installScript} to ${destinationFolder}`);
|
||||
yield exec.getExecOutput('msiexec', [
|
||||
'/i',
|
||||
`"${installScript}"`,
|
||||
'/qn',
|
||||
`APPLICATIONFOLDER="${destinationFolder}"`
|
||||
], {
|
||||
env: { GH_TOKEN: githubAuth },
|
||||
windowsVerbatimArguments: true
|
||||
});
|
||||
return destinationFolder;
|
||||
});
|
||||
}
|
||||
function MacOSDeps(file, githubAuth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.debug('=== Install extra deps for MacOS');
|
||||
@ -516,7 +545,7 @@ function MacOSDeps(file, githubAuth) {
|
||||
yield fs.writeFile(file, newValue, 'utf-8');
|
||||
yield exec.exec('brew', ['install', 'coreutils'], {
|
||||
env: {
|
||||
HOMEBREW_GITHUB_API_TOKEN: githubAuth.substring(7),
|
||||
HOMEBREW_GITHUB_API_TOKEN: githubAuth,
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 'true',
|
||||
HOME: process.env['HOME'] || ''
|
||||
}
|
||||
@ -900,8 +929,8 @@ const cljKondo = __importStar(__nccwpck_require__(4519));
|
||||
const cljfmt = __importStar(__nccwpck_require__(4964));
|
||||
const cljstyle = __importStar(__nccwpck_require__(1578));
|
||||
const zprint = __importStar(__nccwpck_require__(9283));
|
||||
const utils = __importStar(__nccwpck_require__(9277));
|
||||
const cache = __importStar(__nccwpck_require__(5914));
|
||||
const utils = __importStar(__nccwpck_require__(9277));
|
||||
const node_process_1 = __importDefault(__nccwpck_require__(1708));
|
||||
function main() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
@ -909,37 +938,36 @@ function main() {
|
||||
const { LEIN_VERSION, BOOT_VERSION, TDEPS_VERSION, CLI_VERSION, BB_VERSION, CLJ_KONDO_VERSION, CLJFMT_VERSION, CLJSTYLE_VERSION, ZPRINT_VERSION } = getTools();
|
||||
const tools = [];
|
||||
const githubToken = core.getInput('github-token', { required: true });
|
||||
const githubAuth = `Bearer ${githubToken}`;
|
||||
const IS_WINDOWS = utils.isWindows();
|
||||
const githubAuthToken = (githubToken === null || githubToken === void 0 ? void 0 : githubToken.length) > 0 ? `Bearer ${githubToken}` : undefined;
|
||||
if (LEIN_VERSION) {
|
||||
tools.push(lein.setup(LEIN_VERSION, githubAuth));
|
||||
tools.push(lein.setup(LEIN_VERSION, githubAuthToken));
|
||||
}
|
||||
if (BOOT_VERSION) {
|
||||
tools.push(boot.setup(BOOT_VERSION, githubAuth));
|
||||
tools.push(boot.setup(BOOT_VERSION, githubAuthToken));
|
||||
}
|
||||
if (CLI_VERSION) {
|
||||
tools.push(cli.setup(CLI_VERSION, githubAuth));
|
||||
tools.push(cli.setup(CLI_VERSION, githubToken, githubAuthToken));
|
||||
}
|
||||
if (TDEPS_VERSION && !CLI_VERSION) {
|
||||
tools.push(cli.setup(TDEPS_VERSION, githubAuth));
|
||||
tools.push(cli.setup(TDEPS_VERSION, githubToken, githubAuthToken));
|
||||
}
|
||||
if (BB_VERSION) {
|
||||
tools.push(bb.setup(BB_VERSION, githubAuth));
|
||||
tools.push(bb.setup(BB_VERSION, githubAuthToken));
|
||||
}
|
||||
if (CLJ_KONDO_VERSION) {
|
||||
tools.push(cljKondo.setup(CLJ_KONDO_VERSION, githubAuth));
|
||||
tools.push(cljKondo.setup(CLJ_KONDO_VERSION, githubAuthToken));
|
||||
}
|
||||
if (CLJFMT_VERSION) {
|
||||
tools.push(cljfmt.setup(CLJFMT_VERSION, githubAuth));
|
||||
tools.push(cljfmt.setup(CLJFMT_VERSION, githubAuthToken));
|
||||
}
|
||||
if (CLJSTYLE_VERSION) {
|
||||
if (IS_WINDOWS) {
|
||||
if (utils.isWindows()) {
|
||||
throw new Error('cljstyle on windows is not supported yet.');
|
||||
}
|
||||
tools.push(cljstyle.setup(CLJSTYLE_VERSION, githubAuth));
|
||||
tools.push(cljstyle.setup(CLJSTYLE_VERSION, githubAuthToken));
|
||||
}
|
||||
if (ZPRINT_VERSION) {
|
||||
tools.push(zprint.setup(ZPRINT_VERSION, githubAuth));
|
||||
tools.push(zprint.setup(ZPRINT_VERSION, githubAuthToken));
|
||||
}
|
||||
if (tools.length === 0) {
|
||||
throw new Error('You must specify at least one clojure tool.');
|
||||
@ -957,7 +985,6 @@ function pre() {
|
||||
if (!core.getBooleanInput('invalidate-cache')) {
|
||||
try {
|
||||
const { LEIN_VERSION, BOOT_VERSION, TDEPS_VERSION, CLI_VERSION, BB_VERSION, CLJ_KONDO_VERSION, CLJFMT_VERSION, CLJSTYLE_VERSION, ZPRINT_VERSION } = getTools();
|
||||
const IS_WINDOWS = utils.isWindows();
|
||||
const tools = [];
|
||||
if (LEIN_VERSION) {
|
||||
tools.push(cache.restore(lein.identifier, LEIN_VERSION));
|
||||
@ -981,7 +1008,7 @@ function pre() {
|
||||
tools.push(cache.restore(cljfmt.identifier, CLJFMT_VERSION));
|
||||
}
|
||||
if (CLJSTYLE_VERSION) {
|
||||
if (!IS_WINDOWS) {
|
||||
if (!utils.isWindows()) {
|
||||
tools.push(cache.restore(cljstyle.identifier, CLJSTYLE_VERSION));
|
||||
}
|
||||
}
|
||||
@ -1001,7 +1028,6 @@ function post() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const { LEIN_VERSION, BOOT_VERSION, TDEPS_VERSION, CLI_VERSION, BB_VERSION, CLJ_KONDO_VERSION, CLJFMT_VERSION, CLJSTYLE_VERSION, ZPRINT_VERSION } = getTools();
|
||||
const IS_WINDOWS = utils.isWindows();
|
||||
const tools = [];
|
||||
if (LEIN_VERSION) {
|
||||
tools.push(cache.save(lein.identifier, LEIN_VERSION));
|
||||
@ -1025,7 +1051,7 @@ function post() {
|
||||
tools.push(cache.save(cljfmt.identifier, CLJFMT_VERSION));
|
||||
}
|
||||
if (CLJSTYLE_VERSION) {
|
||||
if (!IS_WINDOWS) {
|
||||
if (!utils.isWindows()) {
|
||||
tools.push(cache.save(cljstyle.identifier, CLJSTYLE_VERSION));
|
||||
}
|
||||
}
|
||||
@ -1138,14 +1164,13 @@ const utils = __importStar(__nccwpck_require__(9277));
|
||||
exports.identifier = 'Leiningen';
|
||||
function setup(version, githubAuth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const isWindows = utils.isWindows();
|
||||
let toolPath = tc.find(exports.identifier, utils.getCacheVersionString(version), os.arch());
|
||||
if (toolPath && version !== 'latest') {
|
||||
core.info(`Leiningen found in cache ${toolPath}`);
|
||||
}
|
||||
else {
|
||||
const binScripts = [];
|
||||
if (isWindows) {
|
||||
if (utils.isWindows()) {
|
||||
for (const ext of ['ps1', 'bat']) {
|
||||
binScripts.push(yield tc.downloadTool(`https://raw.githubusercontent.com/technomancy/leiningen/${version === 'latest' ? 'stable' : version}/bin/lein.${ext}`, path.join(utils.getTempDir(), `lein.${ext}`), githubAuth));
|
||||
}
|
||||
@ -1168,7 +1193,6 @@ function setup(version, githubAuth) {
|
||||
}
|
||||
function installLeiningen(binScripts, destinationFolder) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const isWindows = utils.isWindows();
|
||||
yield io.mkdirP(destinationFolder);
|
||||
for (const binScript of binScripts) {
|
||||
const bin = path.normalize(binScript);
|
||||
@ -1177,7 +1201,7 @@ function installLeiningen(binScripts, destinationFolder) {
|
||||
const binDir = path.join(destinationFolder, 'leiningen', 'bin');
|
||||
yield io.mkdirP(binDir);
|
||||
yield io.mv(bin, path.join(binDir, `${path.basename(bin)}`));
|
||||
if (!isWindows) {
|
||||
if (!utils.isWindows()) {
|
||||
yield fs.chmod(path.join(binDir, 'lein'), '0755');
|
||||
}
|
||||
}
|
||||
@ -1185,7 +1209,7 @@ function installLeiningen(binScripts, destinationFolder) {
|
||||
throw new Error('Not a file');
|
||||
}
|
||||
}
|
||||
const version_cmd = isWindows
|
||||
const version_cmd = utils.isWindows()
|
||||
? 'powershell .\\lein.ps1 self-install'
|
||||
: './lein version';
|
||||
const toolDir = path.join(destinationFolder, 'leiningen');
|
||||
@ -1278,17 +1302,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
__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.getCacheVersionString = getCacheVersionString;
|
||||
exports.getTempDir = getTempDir;
|
||||
exports.isWindows = isWindows;
|
||||
exports.isMacOS = isMacOS;
|
||||
const os_1 = __importDefault(__nccwpck_require__(857));
|
||||
const path = __importStar(__nccwpck_require__(6928));
|
||||
const version_1 = __nccwpck_require__(7992);
|
||||
const core_1 = __nccwpck_require__(7484);
|
||||
function getCacheVersionString(version) {
|
||||
const versionArray = version.split('.');
|
||||
const major = versionArray[0];
|
||||
@ -1300,29 +1321,27 @@ function getTempDir() {
|
||||
let tempDirectory = process.env.RUNNER_TEMP;
|
||||
if (tempDirectory === undefined) {
|
||||
let baseLocation;
|
||||
if (isWindows()) {
|
||||
if (core_1.platform.isWindows) {
|
||||
// On windows use the USERPROFILE env variable
|
||||
baseLocation = process.env['USERPROFILE']
|
||||
? process.env['USERPROFILE']
|
||||
: 'C:\\';
|
||||
}
|
||||
else if (core_1.platform.isMacOS) {
|
||||
baseLocation = '/Users';
|
||||
}
|
||||
else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
}
|
||||
else {
|
||||
baseLocation = '/home';
|
||||
}
|
||||
baseLocation = '/home';
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
return tempDirectory;
|
||||
}
|
||||
function isWindows() {
|
||||
return os_1.default.platform() === 'win32';
|
||||
return core_1.platform.isWindows;
|
||||
}
|
||||
function isMacOS() {
|
||||
return os_1.default.platform() === 'darwin';
|
||||
return core_1.platform.isMacOS;
|
||||
}
|
||||
|
||||
|
||||
@ -1335,7 +1354,7 @@ function isMacOS() {
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.VERSION = void 0;
|
||||
exports.VERSION = '12-5';
|
||||
exports.VERSION = '13-0';
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-clojure",
|
||||
"version": "12.2",
|
||||
"version": "13.0",
|
||||
"private": true,
|
||||
"description": "setup clojure action",
|
||||
"main": "lib/setup-clojure.js",
|
||||
|
169
src/cli.ts
169
src/cli.ts
@ -7,6 +7,7 @@ import * as path from 'path'
|
||||
import * as os from 'os'
|
||||
import * as fs from './fs'
|
||||
import * as utils from './utils'
|
||||
import * as crypto from 'crypto'
|
||||
|
||||
export const identifier = 'ClojureToolsDeps'
|
||||
|
||||
@ -17,13 +18,13 @@ const client = new http.HttpClient('actions/setup-clojure', undefined, {
|
||||
|
||||
async function toolVersion(
|
||||
version: string,
|
||||
githubAuth: string
|
||||
githubAuth?: string
|
||||
): Promise<string> {
|
||||
core.debug('=== Check tool version')
|
||||
if (version === 'latest') {
|
||||
const res = await client.getJson<{tag_name: string}>(
|
||||
'https://api.github.com/repos/clojure/brew-install/releases/latest',
|
||||
{Authorization: githubAuth}
|
||||
githubAuth ? {Authorization: githubAuth} : {}
|
||||
)
|
||||
const versionString = res.result?.tag_name
|
||||
if (versionString) {
|
||||
@ -50,14 +51,19 @@ function isResourceProvided(
|
||||
|
||||
async function getUrls(
|
||||
tag: string,
|
||||
githubAuth: string
|
||||
githubAuth?: string
|
||||
): Promise<{posix?: string; linux: string; windows: string}> {
|
||||
core.debug('=== Get download URLs')
|
||||
const res = await client.getJson<{
|
||||
assets: {browser_download_url: string}[]
|
||||
}>(`https://api.github.com/repos/clojure/brew-install/releases/tags/${tag}`, {
|
||||
Authorization: githubAuth
|
||||
})
|
||||
}>(
|
||||
`https://api.github.com/repos/clojure/brew-install/releases/tags/${tag}`,
|
||||
githubAuth
|
||||
? {
|
||||
Authorization: githubAuth
|
||||
}
|
||||
: {}
|
||||
)
|
||||
const posix_install_url = `https://github.com/clojure/brew-install/releases/download/${tag}/posix-install.sh`
|
||||
|
||||
const assets = res.result?.assets
|
||||
@ -65,25 +71,24 @@ async function getUrls(
|
||||
return {
|
||||
posix: posix_install_url,
|
||||
linux: `https://github.com/clojure/brew-install/releases/download/${tag}/linux-install.sh`,
|
||||
windows: `github.com/clojure/brew-install/releases/download/${tag}/win-install.ps1`
|
||||
windows: `https://github.com/casselc/clj-msi/releases/tag/v${tag}/clojure-${tag}.msi`
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
linux: `https://download.clojure.org/install/linux-install-${tag}.sh`,
|
||||
windows: `download.clojure.org/install/win-install-${tag}.ps1`
|
||||
windows: `https://github.com/casselc/clj-msi/releases/tag/v${tag}/clojure-${tag}.msi`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function setup(
|
||||
requestedVersion: string,
|
||||
githubAuth: string
|
||||
githubToken: string,
|
||||
githubAuthToken?: string
|
||||
): Promise<void> {
|
||||
core.debug('=== Run setup')
|
||||
const version = await toolVersion(requestedVersion, githubAuth)
|
||||
const installDir = utils.isWindows()
|
||||
? 'C:\\Program Files\\WindowsPowerShell\\Modules'
|
||||
: '/tmp/usr/local/opt'
|
||||
const version = await toolVersion(requestedVersion, githubAuthToken)
|
||||
const installDir = utils.isWindows() ? 'C:\\tools' : '/tmp/usr/local/opt'
|
||||
const toolPath = tc.find(
|
||||
identifier,
|
||||
utils.getCacheVersionString(version),
|
||||
@ -97,70 +102,74 @@ export async function setup(
|
||||
recursive: true
|
||||
})
|
||||
} else {
|
||||
const {linux, posix, windows} = await getUrls(version, githubAuth)
|
||||
const {linux, posix, windows} = await getUrls(version, githubAuthToken)
|
||||
|
||||
const url = utils.isMacOS()
|
||||
? posix || linux
|
||||
: utils.isWindows()
|
||||
? windows
|
||||
: linux
|
||||
|
||||
const installerFileName = url.split(/\//).pop() || ''
|
||||
const outputDir = path.join(utils.getTempDir(), crypto.randomUUID())
|
||||
const outputFile = path.join(outputDir, installerFileName)
|
||||
|
||||
let clojureInstallScript
|
||||
if (utils.isWindows()) {
|
||||
await exec.exec(`powershell -c "iwr -useb ${windows} | iex"`, [], {
|
||||
// Install to a modules location common to powershell/pwsh
|
||||
env: {PSModulePath: installDir},
|
||||
input: Buffer.from('1')
|
||||
})
|
||||
|
||||
core.debug(
|
||||
`clojure tools deps installed to ${path.join(
|
||||
installDir,
|
||||
'ClojureTools'
|
||||
)}`
|
||||
)
|
||||
await tc.cacheDir(
|
||||
path.join(installDir, 'ClojureTools'),
|
||||
identifier,
|
||||
utils.getCacheVersionString(version)
|
||||
)
|
||||
} else {
|
||||
let clojureInstallScript
|
||||
|
||||
if (utils.isMacOS()) {
|
||||
if (posix) {
|
||||
clojureInstallScript = await tc.downloadTool(
|
||||
posix,
|
||||
undefined,
|
||||
githubAuth
|
||||
)
|
||||
} else {
|
||||
clojureInstallScript = await tc.downloadTool(
|
||||
linux,
|
||||
undefined,
|
||||
githubAuth
|
||||
)
|
||||
await MacOSDeps(clojureInstallScript, githubAuth)
|
||||
await exec.exec(
|
||||
'gh',
|
||||
[
|
||||
'release',
|
||||
'-R',
|
||||
'casselc/clj-msi',
|
||||
'download',
|
||||
`v${version}`,
|
||||
'-D',
|
||||
`${outputDir}`
|
||||
],
|
||||
{
|
||||
env: {GH_TOKEN: githubToken}
|
||||
}
|
||||
} else {
|
||||
clojureInstallScript = await tc.downloadTool(
|
||||
linux,
|
||||
undefined,
|
||||
githubAuth
|
||||
)
|
||||
}
|
||||
|
||||
const clojureToolsDir = await runLinuxInstall(
|
||||
clojureInstallScript,
|
||||
path.join(installDir, 'ClojureTools')
|
||||
)
|
||||
core.debug(`clojure tools deps installed to ${clojureToolsDir}`)
|
||||
await tc.cacheDir(
|
||||
clojureToolsDir,
|
||||
identifier,
|
||||
utils.getCacheVersionString(version)
|
||||
)
|
||||
clojureInstallScript = path.join(outputDir, `clojure-${version}.msi`)
|
||||
} else {
|
||||
clojureInstallScript = await tc.downloadTool(url, outputFile, githubToken)
|
||||
}
|
||||
|
||||
core.debug(
|
||||
`Finish downloading of installation script to ${clojureInstallScript}`
|
||||
)
|
||||
|
||||
if (utils.isMacOS() && !posix) {
|
||||
await MacOSDeps(clojureInstallScript, githubToken)
|
||||
}
|
||||
|
||||
const clojureToolsDir = utils.isWindows()
|
||||
? await runWindowsInstall(
|
||||
clojureInstallScript,
|
||||
path.join(installDir, 'ClojureTools'),
|
||||
githubToken
|
||||
)
|
||||
: await runLinuxInstall(
|
||||
clojureInstallScript,
|
||||
path.join(installDir, 'ClojureTools')
|
||||
)
|
||||
|
||||
core.debug(`clojure tools deps installed to ${clojureToolsDir}`)
|
||||
await tc.cacheDir(
|
||||
clojureToolsDir,
|
||||
identifier,
|
||||
utils.getCacheVersionString(version)
|
||||
)
|
||||
}
|
||||
|
||||
core.exportVariable(
|
||||
'CLOJURE_INSTALL_DIR',
|
||||
path.join(installDir, 'ClojureTools')
|
||||
)
|
||||
if (!utils.isWindows()) {
|
||||
if (utils.isWindows()) {
|
||||
core.addPath(path.join(installDir, 'ClojureTools'))
|
||||
} else {
|
||||
core.addPath(path.join(installDir, 'ClojureTools', 'bin'))
|
||||
}
|
||||
}
|
||||
@ -178,6 +187,32 @@ async function runLinuxInstall(
|
||||
return destinationFolder
|
||||
}
|
||||
|
||||
async function runWindowsInstall(
|
||||
installScript: string,
|
||||
destinationFolder: string,
|
||||
githubAuth: string
|
||||
): Promise<string> {
|
||||
core.debug('=== Install on Windows')
|
||||
await io.mkdirP(destinationFolder)
|
||||
|
||||
core.debug(`installing from ${installScript} to ${destinationFolder}`)
|
||||
await exec.getExecOutput(
|
||||
'msiexec',
|
||||
[
|
||||
'/i',
|
||||
`"${installScript}"`,
|
||||
'/qn',
|
||||
`APPLICATIONFOLDER="${destinationFolder}"`
|
||||
],
|
||||
{
|
||||
env: {GH_TOKEN: githubAuth},
|
||||
windowsVerbatimArguments: true
|
||||
}
|
||||
)
|
||||
|
||||
return destinationFolder
|
||||
}
|
||||
|
||||
async function MacOSDeps(file: string, githubAuth: string): Promise<void> {
|
||||
core.debug('=== Install extra deps for MacOS')
|
||||
const data = await fs.readFile(file, 'utf-8')
|
||||
@ -188,7 +223,7 @@ async function MacOSDeps(file: string, githubAuth: string): Promise<void> {
|
||||
await fs.writeFile(file, newValue, 'utf-8')
|
||||
await exec.exec('brew', ['install', 'coreutils'], {
|
||||
env: {
|
||||
HOMEBREW_GITHUB_API_TOKEN: githubAuth.substring(7),
|
||||
HOMEBREW_GITHUB_API_TOKEN: githubAuth,
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 'true',
|
||||
HOME: process.env['HOME'] || ''
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import * as cljKondo from './clj-kondo'
|
||||
import * as cljfmt from './cljfmt'
|
||||
import * as cljstyle from './cljstyle'
|
||||
import * as zprint from './zprint'
|
||||
import * as utils from './utils'
|
||||
import * as cache from './cache'
|
||||
import * as utils from './utils'
|
||||
import process from 'node:process'
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
@ -28,46 +28,46 @@ export async function main(): Promise<void> {
|
||||
const tools = []
|
||||
|
||||
const githubToken = core.getInput('github-token', {required: true})
|
||||
const githubAuth = `Bearer ${githubToken}`
|
||||
const IS_WINDOWS = utils.isWindows()
|
||||
const githubAuthToken =
|
||||
githubToken?.length > 0 ? `Bearer ${githubToken}` : undefined
|
||||
|
||||
if (LEIN_VERSION) {
|
||||
tools.push(lein.setup(LEIN_VERSION, githubAuth))
|
||||
tools.push(lein.setup(LEIN_VERSION, githubAuthToken))
|
||||
}
|
||||
|
||||
if (BOOT_VERSION) {
|
||||
tools.push(boot.setup(BOOT_VERSION, githubAuth))
|
||||
tools.push(boot.setup(BOOT_VERSION, githubAuthToken))
|
||||
}
|
||||
|
||||
if (CLI_VERSION) {
|
||||
tools.push(cli.setup(CLI_VERSION, githubAuth))
|
||||
tools.push(cli.setup(CLI_VERSION, githubToken, githubAuthToken))
|
||||
}
|
||||
|
||||
if (TDEPS_VERSION && !CLI_VERSION) {
|
||||
tools.push(cli.setup(TDEPS_VERSION, githubAuth))
|
||||
tools.push(cli.setup(TDEPS_VERSION, githubToken, githubAuthToken))
|
||||
}
|
||||
|
||||
if (BB_VERSION) {
|
||||
tools.push(bb.setup(BB_VERSION, githubAuth))
|
||||
tools.push(bb.setup(BB_VERSION, githubAuthToken))
|
||||
}
|
||||
|
||||
if (CLJ_KONDO_VERSION) {
|
||||
tools.push(cljKondo.setup(CLJ_KONDO_VERSION, githubAuth))
|
||||
tools.push(cljKondo.setup(CLJ_KONDO_VERSION, githubAuthToken))
|
||||
}
|
||||
|
||||
if (CLJFMT_VERSION) {
|
||||
tools.push(cljfmt.setup(CLJFMT_VERSION, githubAuth))
|
||||
tools.push(cljfmt.setup(CLJFMT_VERSION, githubAuthToken))
|
||||
}
|
||||
|
||||
if (CLJSTYLE_VERSION) {
|
||||
if (IS_WINDOWS) {
|
||||
if (utils.isWindows()) {
|
||||
throw new Error('cljstyle on windows is not supported yet.')
|
||||
}
|
||||
tools.push(cljstyle.setup(CLJSTYLE_VERSION, githubAuth))
|
||||
tools.push(cljstyle.setup(CLJSTYLE_VERSION, githubAuthToken))
|
||||
}
|
||||
|
||||
if (ZPRINT_VERSION) {
|
||||
tools.push(zprint.setup(ZPRINT_VERSION, githubAuth))
|
||||
tools.push(zprint.setup(ZPRINT_VERSION, githubAuthToken))
|
||||
}
|
||||
|
||||
if (tools.length === 0) {
|
||||
@ -96,7 +96,6 @@ export async function pre(): Promise<void> {
|
||||
ZPRINT_VERSION
|
||||
} = getTools()
|
||||
|
||||
const IS_WINDOWS = utils.isWindows()
|
||||
const tools = []
|
||||
|
||||
if (LEIN_VERSION) {
|
||||
@ -128,7 +127,7 @@ export async function pre(): Promise<void> {
|
||||
}
|
||||
|
||||
if (CLJSTYLE_VERSION) {
|
||||
if (!IS_WINDOWS) {
|
||||
if (!utils.isWindows()) {
|
||||
tools.push(cache.restore(cljstyle.identifier, CLJSTYLE_VERSION))
|
||||
}
|
||||
}
|
||||
@ -159,7 +158,6 @@ export async function post(): Promise<void> {
|
||||
ZPRINT_VERSION
|
||||
} = getTools()
|
||||
|
||||
const IS_WINDOWS = utils.isWindows()
|
||||
const tools = []
|
||||
|
||||
if (LEIN_VERSION) {
|
||||
@ -191,7 +189,7 @@ export async function post(): Promise<void> {
|
||||
}
|
||||
|
||||
if (CLJSTYLE_VERSION) {
|
||||
if (!IS_WINDOWS) {
|
||||
if (!utils.isWindows()) {
|
||||
tools.push(cache.save(cljstyle.identifier, CLJSTYLE_VERSION))
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ export async function setup(
|
||||
version: string,
|
||||
githubAuth?: string
|
||||
): Promise<void> {
|
||||
const isWindows = utils.isWindows()
|
||||
|
||||
let toolPath = tc.find(
|
||||
identifier,
|
||||
utils.getCacheVersionString(version),
|
||||
@ -25,7 +23,7 @@ export async function setup(
|
||||
core.info(`Leiningen found in cache ${toolPath}`)
|
||||
} else {
|
||||
const binScripts = []
|
||||
if (isWindows) {
|
||||
if (utils.isWindows()) {
|
||||
for (const ext of ['ps1', 'bat']) {
|
||||
binScripts.push(
|
||||
await tc.downloadTool(
|
||||
@ -76,8 +74,6 @@ async function installLeiningen(
|
||||
binScripts: string[],
|
||||
destinationFolder: string
|
||||
): Promise<string> {
|
||||
const isWindows = utils.isWindows()
|
||||
|
||||
await io.mkdirP(destinationFolder)
|
||||
|
||||
for (const binScript of binScripts) {
|
||||
@ -90,7 +86,7 @@ async function installLeiningen(
|
||||
|
||||
await io.mv(bin, path.join(binDir, `${path.basename(bin)}`))
|
||||
|
||||
if (!isWindows) {
|
||||
if (!utils.isWindows()) {
|
||||
await fs.chmod(path.join(binDir, 'lein'), '0755')
|
||||
}
|
||||
} else {
|
||||
@ -98,7 +94,7 @@ async function installLeiningen(
|
||||
}
|
||||
}
|
||||
|
||||
const version_cmd = isWindows
|
||||
const version_cmd = utils.isWindows()
|
||||
? 'powershell .\\lein.ps1 self-install'
|
||||
: './lein version'
|
||||
|
||||
|
16
src/utils.ts
16
src/utils.ts
@ -1,6 +1,6 @@
|
||||
import os from 'os'
|
||||
import * as path from 'path'
|
||||
import {VERSION} from './version'
|
||||
import {platform} from '@actions/core'
|
||||
|
||||
export function getCacheVersionString(version: string): string {
|
||||
const versionArray = version.split('.')
|
||||
@ -14,17 +14,15 @@ export function getTempDir(): string {
|
||||
let tempDirectory = process.env.RUNNER_TEMP
|
||||
if (tempDirectory === undefined) {
|
||||
let baseLocation
|
||||
if (isWindows()) {
|
||||
if (platform.isWindows) {
|
||||
// On windows use the USERPROFILE env variable
|
||||
baseLocation = process.env['USERPROFILE']
|
||||
? process.env['USERPROFILE']
|
||||
: 'C:\\'
|
||||
} else if (platform.isMacOS) {
|
||||
baseLocation = '/Users'
|
||||
} else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users'
|
||||
} else {
|
||||
baseLocation = '/home'
|
||||
}
|
||||
baseLocation = '/home'
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp')
|
||||
}
|
||||
@ -32,9 +30,9 @@ export function getTempDir(): string {
|
||||
}
|
||||
|
||||
export function isWindows(): boolean {
|
||||
return os.platform() === 'win32'
|
||||
return platform.isWindows
|
||||
}
|
||||
|
||||
export function isMacOS(): boolean {
|
||||
return os.platform() === 'darwin'
|
||||
return platform.isMacOS
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
export const VERSION = '12-5'
|
||||
export const VERSION = '13-0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user