diff --git a/package-lock.json b/package-lock.json index 02f0ecd2..2dddd43e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,8 @@ "dependencies": { "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", - "@actions/tool-cache": "^2.0.1" + "@actions/tool-cache": "^2.0.1", + "compare-versions": "^6.1.1" }, "devDependencies": { "@stylistic/eslint-plugin": "^2.10.1", @@ -945,6 +946,12 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/compare-versions": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-6.1.1.tgz", + "integrity": "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg==", + "license": "MIT" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", diff --git a/package.json b/package.json index bb048f20..a92032ce 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "dependencies": { "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", - "@actions/tool-cache": "^2.0.1" + "@actions/tool-cache": "^2.0.1", + "compare-versions": "^6.1.1" }, "devDependencies": { "@stylistic/eslint-plugin": "^2.10.1", diff --git a/src/main.ts b/src/main.ts index a7c38fa3..3c784854 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,10 @@ import * as os from 'os' import * as path from 'path' import * as tc from '@actions/tool-cache' +// would have preferred to use coursier.core.Version here, +// but coursier is not published on npm +import { compareVersions } from 'compare-versions' + const defaultVersion_x86_64 = '2.1.14' const defaultVersion_aarch64 = '2.1.14' @@ -16,7 +20,7 @@ const csVersion = (architecture === architecture_x86_64 ? defaultVersion_x86_64 : defaultVersion_aarch64) const coursierVersionSpec = csVersion const coursierBinariesGithubRepository = - architecture === architecture_x86_64 + architecture === architecture_x86_64 || compareVersions(csVersion, '2.1.16') >= 0 ? 'https://github.com/coursier/coursier/' : 'https://github.com/VirtusLab/coursier-m1/'