Migrate to GH releases for Clojure CLI

closes #88
This commit is contained in:
Kirill Chernyshov 2023-09-06 15:29:15 +02:00
parent 1c76ab0e15
commit fdcd988040
No known key found for this signature in database
GPG Key ID: 83C196363AF97C4C
14 changed files with 2913 additions and 2310 deletions

View File

@ -50,7 +50,32 @@ jobs:
- name: Install Clojure CLI
uses: ./
with:
cli: 1.10.1.693
cli: 1.11.1.1409
- name: Execute clojure code
run: clojure -e "(+ 1 1)"
test-clojure-cli-latest:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@main
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
- name: Install Clojure CLI
uses: ./
with:
cli: latest
- name: Execute clojure code
run: clojure -e "(+ 1 1)"

View File

@ -46,7 +46,7 @@ jobs:
java-version: '8'
- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@11.0
uses: DeLaGuardo/setup-clojure@12.0
with:
# Install just one or all simultaneously
# The value must indicate a particular version of the tool, or use 'latest'

View File

@ -37,9 +37,11 @@ jest.mock('@actions/http-client', () => {
return {
HttpClient: jest.fn().mockImplementation(() => {
return {
get: jest.fn().mockImplementation(() => {
getJson: jest.fn().mockImplementation(() => {
return {
readBody: jest.fn().mockResolvedValue('1.2.3 123qwe')
result: {
tag_name: '1.2.3'
}
}
})
}
@ -76,7 +78,9 @@ describe('tdeps tests', () => {
await tdeps.setup('1.10.1.469')
expect(tc.downloadTool).toHaveBeenCalledWith(
'https://download.clojure.org/install/linux-install-1.10.1.469.sh'
'https://download.clojure.org/install/linux-install-1.10.1.469.sh',
undefined,
undefined
)
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
expect(exec.exec).toHaveBeenCalledWith('bash', [
@ -105,7 +109,9 @@ describe('tdeps tests', () => {
await tdeps.setup('latest')
expect(tc.downloadTool).toHaveBeenCalledWith(
'https://download.clojure.org/install/linux-install-1.2.3.sh'
'https://download.clojure.org/install/linux-install-1.2.3.sh',
undefined,
undefined
)
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
expect(exec.exec).toHaveBeenCalledWith('bash', [
@ -136,10 +142,12 @@ describe('tdeps tests', () => {
tc.downloadTool.mockResolvedValueOnce(downloadPath)
tc.cacheDir.mockResolvedValueOnce(cachePath)
await tdeps.setup('latest')
await tdeps.setup('latest', 'foo')
expect(tc.downloadTool).toHaveBeenCalledWith(
'https://download.clojure.org/install/linux-install-1.2.3.sh'
'https://download.clojure.org/install/linux-install-1.2.3.sh',
undefined,
'foo'
)
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
expect(fs.writeFile).toHaveBeenCalledWith(

269
dist/index.js vendored
View File

@ -50,7 +50,7 @@ function getLatestBabashka(githubAuth) {
return __awaiter(this, void 0, void 0, function* () {
const client = new http.HttpClient('actions/setup-clojure', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
});
const res = yield client.getJson(`https://api.github.com/repos/babashka/babashka/releases/latest`, githubAuth ? { Authorization: githubAuth } : undefined);
const result = (_b = (_a = res.result) === null || _a === void 0 ? void 0 : _a.tag_name) === null || _b === void 0 ? void 0 : _b.replace(/^v/, '');
@ -396,23 +396,47 @@ const utils = __importStar(__nccwpck_require__(918));
exports.identifier = 'ClojureToolsDeps';
const client = new http.HttpClient('actions/setup-clojure', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
});
function toolVersion(version) {
function toolVersion(version, githubAuth) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
if (version === 'latest') {
const res = yield client.get('https://download.clojure.org/install/stable.properties');
const versionString = yield res.readBody();
return versionString.split(' ')[0];
const res = yield client.getJson('https://api.github.com/repos/clojure/brew-install/releases/latest', githubAuth ? { Authorization: githubAuth } : undefined);
const versionString = (_a = res.result) === null || _a === void 0 ? void 0 : _a.tag_name;
if (versionString) {
return versionString;
}
throw new Error(`Can't obtain latest Clojure CLI version`);
}
else {
return version;
}
});
}
function getUrls(tag, githubAuth) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const res = yield client.getJson(`https://api.github.com/repos/clojure/brew-install/releases/tags/${tag}`, githubAuth ? { Authorization: githubAuth } : undefined);
const assets = (_a = res.result) === null || _a === void 0 ? void 0 : _a.assets;
if (assets) {
return {
posix: `https://github.com/clojure/brew-install/releases/download/${tag}/posix-install.sh`,
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`
};
}
else {
return {
linux: `https://download.clojure.org/install/linux-install-${tag}.sh`,
windows: `download.clojure.org/install/win-install-${tag}.ps1`
};
}
});
}
function setup(requestedVersion, githubToken) {
return __awaiter(this, void 0, void 0, function* () {
const version = yield toolVersion(requestedVersion);
const version = yield toolVersion(requestedVersion, githubToken);
const installDir = utils.isWindows()
? 'C:\\Program Files\\WindowsPowerShell\\Modules'
: '/tmp/usr/local/opt';
@ -425,9 +449,9 @@ function setup(requestedVersion, githubToken) {
});
}
else {
const { linux, posix, windows } = yield getUrls(version, githubToken);
if (utils.isWindows()) {
const url = `download.clojure.org/install/win-install-${version}.ps1`;
yield exec.exec(`powershell -c "iwr -useb ${url} | iex"`, [], {
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')
@ -436,9 +460,18 @@ function setup(requestedVersion, githubToken) {
yield tc.cacheDir(path.join(installDir, 'ClojureTools'), exports.identifier, utils.getCacheVersionString(version));
}
else {
const clojureInstallScript = yield tc.downloadTool(`https://download.clojure.org/install/linux-install-${version}.sh`);
let clojureInstallScript;
if (utils.isMacOS()) {
yield MacOSDeps(clojureInstallScript, githubToken);
if (posix) {
clojureInstallScript = yield tc.downloadTool(posix, undefined, githubToken);
}
else {
clojureInstallScript = yield tc.downloadTool(linux, undefined, githubToken);
yield MacOSDeps(clojureInstallScript, githubToken);
}
}
else {
clojureInstallScript = yield tc.downloadTool(linux, undefined, githubToken);
}
const clojureToolsDir = yield runLinuxInstall(clojureInstallScript, path.join(installDir, 'ClojureTools'));
core.debug(`clojure tools deps installed to ${clojureToolsDir}`);
@ -536,7 +569,7 @@ function getLatestCljKondo(githubAuth) {
return __awaiter(this, void 0, void 0, function* () {
const client = new http.HttpClient('actions/setup-clj-kondo', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
});
const res = yield client.getJson(`https://api.github.com/repos/clj-kondo/clj-kondo/releases/latest`, githubAuth ? { Authorization: githubAuth } : undefined);
const result = (_b = (_a = res.result) === null || _a === void 0 ? void 0 : _a.tag_name) === null || _b === void 0 ? void 0 : _b.replace(/^v/, '');
@ -636,7 +669,7 @@ function getLatestCljFmt(githubAuth) {
return __awaiter(this, void 0, void 0, function* () {
const client = new http.HttpClient('actions/setup-cljfmt', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
});
const res = yield client.getJson(`https://api.github.com/repos/weavejester/cljfmt/releases/latest`, githubAuth ? { Authorization: githubAuth } : undefined);
const result = (_a = res.result) === null || _a === void 0 ? void 0 : _a.tag_name;
@ -744,7 +777,7 @@ function getLatestCljstyle(githubAuth) {
return __awaiter(this, void 0, void 0, function* () {
const client = new http.HttpClient('actions/setup-clojure', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
});
const res = yield client.getJson(`https://api.github.com/repos/greglook/cljstyle/releases/latest`, githubAuth ? { Authorization: githubAuth } : undefined);
const result = (_b = (_a = res.result) === null || _a === void 0 ? void 0 : _a.tag_name) === null || _b === void 0 ? void 0 : _b.replace(/^v/, '');
@ -1259,7 +1292,7 @@ exports.isMacOS = isMacOS;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.VERSION = void 0;
exports.VERSION = '11-0';
exports.VERSION = '12-0';
/***/ }),
@ -1314,7 +1347,7 @@ function getLatestZprint(githubAuth) {
return __awaiter(this, void 0, void 0, function* () {
const client = new http.HttpClient('actions/setup-zprint', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
});
const res = yield client.getJson(`https://api.github.com/repos/kkinnear/zprint/releases/latest`, githubAuth ? { Authorization: githubAuth } : undefined);
const result = (_b = (_a = res.result) === null || _a === void 0 ? void 0 : _a.tag_name) === null || _b === void 0 ? void 0 : _b.replace(/^v/, '');
@ -1695,10 +1728,7 @@ function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false)
}
// Add salt to cache version to support breaking changes in cache entry
components.push(versionSalt);
return crypto
.createHash('sha256')
.update(components.join('|'))
.digest('hex');
return crypto.createHash('sha256').update(components.join('|')).digest('hex');
}
exports.getCacheVersion = getCacheVersion;
function getCacheEntry(keys, paths, options) {
@ -1751,13 +1781,21 @@ function downloadCache(archiveLocation, archivePath, options) {
return __awaiter(this, void 0, void 0, function* () {
const archiveUrl = new url_1.URL(archiveLocation);
const downloadOptions = (0, options_1.getDownloadOptions)(options);
if (downloadOptions.useAzureSdk &&
archiveUrl.hostname.endsWith('.blob.core.windows.net')) {
// Use Azure storage SDK to download caches hosted on Azure to improve speed and reliability.
yield (0, downloadUtils_1.downloadCacheStorageSDK)(archiveLocation, archivePath, downloadOptions);
if (archiveUrl.hostname.endsWith('.blob.core.windows.net')) {
if (downloadOptions.useAzureSdk) {
// Use Azure storage SDK to download caches hosted on Azure to improve speed and reliability.
yield (0, downloadUtils_1.downloadCacheStorageSDK)(archiveLocation, archivePath, downloadOptions);
}
else if (downloadOptions.concurrentBlobDownloads) {
// Use concurrent implementation with HttpClient to work around blob SDK issue
yield (0, downloadUtils_1.downloadCacheHttpClientConcurrent)(archiveLocation, archivePath, downloadOptions);
}
else {
// Otherwise, download using the Actions http-client.
yield (0, downloadUtils_1.downloadCacheHttpClient)(archiveLocation, archivePath);
}
}
else {
// Otherwise, download using the Actions http-client.
yield (0, downloadUtils_1.downloadCacheHttpClient)(archiveLocation, archivePath);
}
});
@ -1790,9 +1828,7 @@ function getContentRange(start, end) {
}
function uploadChunk(httpClient, resourceUrl, openStream, start, end) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(`Uploading chunk of size ${end -
start +
1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`);
core.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`);
const additionalHeaders = {
'Content-Type': 'application/octet-stream',
'Content-Range': getContentRange(start, end)
@ -1960,35 +1996,42 @@ function getArchiveFileSizeInBytes(filePath) {
}
exports.getArchiveFileSizeInBytes = getArchiveFileSizeInBytes;
function resolvePaths(patterns) {
var e_1, _a;
var _b;
var _a, e_1, _b, _c;
var _d;
return __awaiter(this, void 0, void 0, function* () {
const paths = [];
const workspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd();
const workspace = (_d = process.env['GITHUB_WORKSPACE']) !== null && _d !== void 0 ? _d : process.cwd();
const globber = yield glob.create(patterns.join('\n'), {
implicitDescendants: false
});
try {
for (var _c = __asyncValues(globber.globGenerator()), _d; _d = yield _c.next(), !_d.done;) {
const file = _d.value;
const relativeFile = path
.relative(workspace, file)
.replace(new RegExp(`\\${path.sep}`, 'g'), '/');
core.debug(`Matched: ${relativeFile}`);
// Paths are made relative so the tar entries are all relative to the root of the workspace.
if (relativeFile === '') {
// path.relative returns empty string if workspace and file are equal
paths.push('.');
for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a;) {
_c = _g.value;
_e = false;
try {
const file = _c;
const relativeFile = path
.relative(workspace, file)
.replace(new RegExp(`\\${path.sep}`, 'g'), '/');
core.debug(`Matched: ${relativeFile}`);
// Paths are made relative so the tar entries are all relative to the root of the workspace.
if (relativeFile === '') {
// path.relative returns empty string if workspace and file are equal
paths.push('.');
}
else {
paths.push(`${relativeFile}`);
}
}
else {
paths.push(`${relativeFile}`);
finally {
_e = true;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f);
}
finally { if (e_1) throw e_1.error; }
}
@ -2153,7 +2196,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.downloadCacheStorageSDK = exports.downloadCacheHttpClient = exports.DownloadProgress = void 0;
exports.downloadCacheStorageSDK = exports.downloadCacheHttpClientConcurrent = exports.downloadCacheHttpClient = exports.DownloadProgress = void 0;
const core = __importStar(__nccwpck_require__(2186));
const http_client_1 = __nccwpck_require__(6255);
const storage_blob_1 = __nccwpck_require__(4100);
@ -2310,6 +2353,115 @@ function downloadCacheHttpClient(archiveLocation, archivePath) {
});
}
exports.downloadCacheHttpClient = downloadCacheHttpClient;
/**
* Download the cache using the Actions toolkit http-client concurrently
*
* @param archiveLocation the URL for the cache
* @param archivePath the local path where the cache is saved
*/
function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const archiveDescriptor = yield fs.promises.open(archivePath, 'w');
const httpClient = new http_client_1.HttpClient('actions/cache', undefined, {
socketTimeout: options.timeoutInMs,
keepAlive: true
});
try {
const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.request('HEAD', archiveLocation, null, {}); }));
const lengthHeader = res.message.headers['content-length'];
if (lengthHeader === undefined || lengthHeader === null) {
throw new Error('Content-Length not found on blob response');
}
const length = parseInt(lengthHeader);
if (Number.isNaN(length)) {
throw new Error(`Could not interpret Content-Length: ${length}`);
}
const downloads = [];
const blockSize = 4 * 1024 * 1024;
for (let offset = 0; offset < length; offset += blockSize) {
const count = Math.min(blockSize, length - offset);
downloads.push({
offset,
promiseGetter: () => __awaiter(this, void 0, void 0, function* () {
return yield downloadSegmentRetry(httpClient, archiveLocation, offset, count);
})
});
}
// reverse to use .pop instead of .shift
downloads.reverse();
let actives = 0;
let bytesDownloaded = 0;
const progress = new DownloadProgress(length);
progress.startDisplayTimer();
const progressFn = progress.onProgress();
const activeDownloads = [];
let nextDownload;
const waitAndWrite = () => __awaiter(this, void 0, void 0, function* () {
const segment = yield Promise.race(Object.values(activeDownloads));
yield archiveDescriptor.write(segment.buffer, 0, segment.count, segment.offset);
actives--;
delete activeDownloads[segment.offset];
bytesDownloaded += segment.count;
progressFn({ loadedBytes: bytesDownloaded });
});
while ((nextDownload = downloads.pop())) {
activeDownloads[nextDownload.offset] = nextDownload.promiseGetter();
actives++;
if (actives >= ((_a = options.downloadConcurrency) !== null && _a !== void 0 ? _a : 10)) {
yield waitAndWrite();
}
}
while (actives > 0) {
yield waitAndWrite();
}
}
finally {
httpClient.dispose();
yield archiveDescriptor.close();
}
});
}
exports.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent;
function downloadSegmentRetry(httpClient, archiveLocation, offset, count) {
return __awaiter(this, void 0, void 0, function* () {
const retries = 5;
let failures = 0;
while (true) {
try {
const timeout = 30000;
const result = yield promiseWithTimeout(timeout, downloadSegment(httpClient, archiveLocation, offset, count));
if (typeof result === 'string') {
throw new Error('downloadSegmentRetry failed due to timeout');
}
return result;
}
catch (err) {
if (failures >= retries) {
throw err;
}
failures++;
}
}
});
}
function downloadSegment(httpClient, archiveLocation, offset, count) {
return __awaiter(this, void 0, void 0, function* () {
const partRes = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCachePart', () => __awaiter(this, void 0, void 0, function* () {
return yield httpClient.get(archiveLocation, {
Range: `bytes=${offset}-${offset + count - 1}`
});
}));
if (!partRes.readBodyBuffer) {
throw new Error('Expected HttpClientResponse to implement readBodyBuffer');
}
return {
offset,
count,
buffer: yield partRes.readBodyBuffer()
};
});
}
/**
* Download the cache using the Azure Storage SDK. Only call this method if the
* URL points to an Azure Storage endpoint.
@ -2875,7 +3027,8 @@ exports.getUploadOptions = getUploadOptions;
*/
function getDownloadOptions(copy) {
const result = {
useAzureSdk: true,
useAzureSdk: false,
concurrentBlobDownloads: true,
downloadConcurrency: 8,
timeoutInMs: 30000,
segmentTimeoutInMs: 600000,
@ -2885,6 +3038,9 @@ function getDownloadOptions(copy) {
if (typeof copy.useAzureSdk === 'boolean') {
result.useAzureSdk = copy.useAzureSdk;
}
if (typeof copy.concurrentBlobDownloads === 'boolean') {
result.concurrentBlobDownloads = copy.concurrentBlobDownloads;
}
if (typeof copy.downloadConcurrency === 'number') {
result.downloadConcurrency = copy.downloadConcurrency;
}
@ -6571,6 +6727,19 @@ class HttpClientResponse {
}));
});
}
readBodyBuffer() {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
const chunks = [];
this.message.on('data', (chunk) => {
chunks.push(chunk);
});
this.message.on('end', () => {
resolve(Buffer.concat(chunks));
});
}));
});
}
}
exports.HttpClientResponse = HttpClientResponse;
function isHttps(requestUrl) {
@ -7075,7 +7244,13 @@ function getProxyUrl(reqUrl) {
}
})();
if (proxyVar) {
return new URL(proxyVar);
try {
return new URL(proxyVar);
}
catch (_a) {
if (!proxyVar.startsWith('http://') && !proxyVar.startsWith('https://'))
return new URL(`http://${proxyVar}`);
}
}
else {
return undefined;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

4780
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "setup-clojure",
"version": "11.0",
"version": "12.0",
"private": true,
"description": "setup clojure action",
"main": "lib/setup-clojure.js",
@ -27,28 +27,28 @@
"author": "DeLaGuardo",
"license": "MIT",
"dependencies": {
"@actions/cache": "^3.2.1",
"@actions/cache": "^3.2.2",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/http-client": "^2.1.0",
"@actions/http-client": "^2.1.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1"
},
"devDependencies": {
"@types/jest": "^29.5.1",
"@types/node": "^20.2.4",
"@types/semver": "^7.5.0",
"@typescript-eslint/parser": "^5.59.7",
"@types/jest": "^29.5.4",
"@types/node": "^20.5.9",
"@types/semver": "^7.5.1",
"@typescript-eslint/parser": "^6.6.0",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.41.0",
"eslint-plugin-github": "^4.7.0",
"eslint-plugin-jest": "^27.2.1",
"jest": "^29.5.0",
"jest-circus": "^29.5.0",
"eslint": "^8.48.0",
"eslint-plugin-github": "^4.10.0",
"eslint-plugin-jest": "^27.2.3",
"jest": "^29.6.4",
"jest-circus": "^29.6.4",
"js-yaml": "^4.1.0",
"npm-check-updates": "^16.10.12",
"prettier": "2.8.8",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4"
"npm-check-updates": "^16.13.2",
"prettier": "3.0.3",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
}
}

View File

@ -9,7 +9,7 @@ export const identifier = 'Babashka'
export async function getLatestBabashka(githubAuth?: string): Promise<string> {
const client = new http.HttpClient('actions/setup-clojure', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
})
const res = await client.getJson<{tag_name: string}>(

View File

@ -12,26 +12,60 @@ export const identifier = 'ClojureToolsDeps'
const client = new http.HttpClient('actions/setup-clojure', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
})
async function toolVersion(version: string): Promise<string> {
async function toolVersion(
version: string,
githubAuth?: string
): Promise<string> {
if (version === 'latest') {
const res = await client.get(
'https://download.clojure.org/install/stable.properties'
const res = await client.getJson<{tag_name: string}>(
'https://api.github.com/repos/clojure/brew-install/releases/latest',
githubAuth ? {Authorization: githubAuth} : undefined
)
const versionString = await res.readBody()
return versionString.split(' ')[0]
const versionString = res.result?.tag_name
if (versionString) {
return versionString
}
throw new Error(`Can't obtain latest Clojure CLI version`)
} else {
return version
}
}
async function getUrls(
tag: string,
githubAuth?: string
): Promise<{posix?: string; linux: string; windows: string}> {
const res = await client.getJson<{
assets: {browser_download_url: string}[]
}>(
`https://api.github.com/repos/clojure/brew-install/releases/tags/${tag}`,
githubAuth ? {Authorization: githubAuth} : undefined
)
const assets = res.result?.assets
if (assets) {
return {
posix: `https://github.com/clojure/brew-install/releases/download/${tag}/posix-install.sh`,
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`
}
} else {
return {
linux: `https://download.clojure.org/install/linux-install-${tag}.sh`,
windows: `download.clojure.org/install/win-install-${tag}.ps1`
}
}
}
export async function setup(
requestedVersion: string,
githubToken?: string
): Promise<void> {
const version = await toolVersion(requestedVersion)
const version = await toolVersion(requestedVersion, githubToken)
const installDir = utils.isWindows()
? 'C:\\Program Files\\WindowsPowerShell\\Modules'
: '/tmp/usr/local/opt'
@ -48,10 +82,10 @@ export async function setup(
recursive: true
})
} else {
if (utils.isWindows()) {
const url = `download.clojure.org/install/win-install-${version}.ps1`
const {linux, posix, windows} = await getUrls(version, githubToken)
await exec.exec(`powershell -c "iwr -useb ${url} | iex"`, [], {
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')
@ -69,12 +103,29 @@ export async function setup(
utils.getCacheVersionString(version)
)
} else {
const clojureInstallScript = await tc.downloadTool(
`https://download.clojure.org/install/linux-install-${version}.sh`
)
let clojureInstallScript
if (utils.isMacOS()) {
await MacOSDeps(clojureInstallScript, githubToken)
if (posix) {
clojureInstallScript = await tc.downloadTool(
posix,
undefined,
githubToken
)
} else {
clojureInstallScript = await tc.downloadTool(
linux,
undefined,
githubToken
)
await MacOSDeps(clojureInstallScript, githubToken)
}
} else {
clojureInstallScript = await tc.downloadTool(
linux,
undefined,
githubToken
)
}
const clojureToolsDir = await runLinuxInstall(

View File

@ -8,7 +8,7 @@ export const identifier = 'clj-kondo'
export async function getLatestCljKondo(githubAuth?: string): Promise<string> {
const client = new http.HttpClient('actions/setup-clj-kondo', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
})
const res = await client.getJson<{tag_name: string}>(

View File

@ -8,7 +8,7 @@ export const identifier = 'cljfmt'
export async function getLatestCljFmt(githubAuth?: string): Promise<string> {
const client = new http.HttpClient('actions/setup-cljfmt', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
})
const res = await client.getJson<{tag_name: string}>(

View File

@ -8,7 +8,7 @@ export const identifier = 'cljstyle'
export async function getLatestCljstyle(githubAuth?: string): Promise<string> {
const client = new http.HttpClient('actions/setup-clojure', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
})
const res = await client.getJson<{tag_name: string}>(

View File

@ -1 +1 @@
export const VERSION = '11-0'
export const VERSION = '12-0'

View File

@ -9,7 +9,7 @@ export const identifier = 'zprint'
export async function getLatestZprint(githubAuth?: string): Promise<string> {
const client = new http.HttpClient('actions/setup-zprint', undefined, {
allowRetries: true,
maxRetries: 3
maxRetries: 1
})
const res = await client.getJson<{tag_name: string}>(