Always use hardcoded versions to match ranges

This commit is contained in:
Sascha Mann
2019-11-11 18:11:32 +01:00
parent 5354e1e908
commit dc7c0defbe
4 changed files with 6 additions and 83 deletions

41
lib/installer.js generated
View File

@@ -18,51 +18,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec")); const exec = __importStar(require("@actions/exec"));
const tc = __importStar(require("@actions/tool-cache")); const tc = __importStar(require("@actions/tool-cache"));
const https = __importStar(require("https"));
const os = __importStar(require("os")); const os = __importStar(require("os"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const semver = __importStar(require("semver")); const semver = __importStar(require("semver"));
// Store information about the environment // Store information about the environment
const osPlat = os.platform(); // possible values: win32 (Windows), linux (Linux), darwin (macOS) const osPlat = os.platform(); // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`); core.debug(`platform: ${osPlat}`);
// This is temporary until we have a better way of fetching releases than GitHub's API // This is temporary until we have a better way of fetching releases (see #1, #4 for details)
const fallbackVersions = ['v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2']; exports.juliaVersions = ['v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2'];
function getJuliaReleases() {
return __awaiter(this, void 0, void 0, function* () {
// Wrap everything in a Promise so that it can be called with await.
return new Promise((resolve, reject) => {
const options = {
hostname: 'api.github.com',
path: '/repos/julialang/julia/releases?per_page=100',
method: 'GET',
headers: {
'Accept': 'application/vnd.github.v3+json',
'User-Agent': `${process.env.GITHUB_ACTION} Action running in ${process.env.GITHUB_REPOSITORY}`
}
};
https.request(options, res => {
let data = '';
res.on('data', d => {
data += d;
});
res.on('end', () => {
core.debug(data);
if (res.statusCode != 200) {
// This is temporary until we have a better way of fetching releases than GitHub's API
console.log(`GitHub API request failed with status code ${res.statusCode}`);
console.log('Check the debug logs for more information');
console.log('Falling back to hardcoded versions');
resolve(fallbackVersions);
}
resolve(JSON.parse(data).map((r) => r.tag_name));
});
}).on('error', err => {
reject(new Error(`Error while requesting Julia versions from GitHub:\n${err}`));
}).end();
});
});
}
exports.getJuliaReleases = getJuliaReleases;
function getJuliaVersion(availableReleases, versionInput) { function getJuliaVersion(availableReleases, versionInput) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (semver.valid(versionInput) == versionInput) { if (semver.valid(versionInput) == versionInput) {

2
lib/setup-julia.js generated
View File

@@ -25,7 +25,7 @@ function run() {
try { try {
const versionInput = core.getInput('version'); const versionInput = core.getInput('version');
const arch = core.getInput('arch'); const arch = core.getInput('arch');
const availableReleases = yield installer.getJuliaReleases(); const availableReleases = installer.juliaVersions;
const version = yield installer.getJuliaVersion(availableReleases, versionInput); const version = yield installer.getJuliaVersion(availableReleases, versionInput);
core.debug(`selected Julia version: ${arch}/${version}`); core.debug(`selected Julia version: ${arch}/${version}`);
// Search in cache // Search in cache

View File

@@ -12,48 +12,8 @@ import * as semver from 'semver'
const osPlat = os.platform() // possible values: win32 (Windows), linux (Linux), darwin (macOS) const osPlat = os.platform() // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`) core.debug(`platform: ${osPlat}`)
// This is temporary until we have a better way of fetching releases than GitHub's API // This is temporary until we have a better way of fetching releases (see #1, #4 for details)
const fallbackVersions = ['v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2'] export const juliaVersions = ['v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2']
export async function getJuliaReleases(): Promise<string[]> {
// Wrap everything in a Promise so that it can be called with await.
return new Promise((resolve, reject) => {
const options = {
hostname: 'api.github.com',
path: '/repos/julialang/julia/releases?per_page=100',
method: 'GET',
headers: {
'Accept': 'application/vnd.github.v3+json', // locks GitHub API version to v3
'User-Agent': `${process.env.GITHUB_ACTION} Action running in ${process.env.GITHUB_REPOSITORY}`
}
}
https.request(options, res => {
let data = ''
res.on('data', d => {
data += d
})
res.on('end', () => {
core.debug(data)
if (res.statusCode != 200) {
// This is temporary until we have a better way of fetching releases than GitHub's API
console.log(`GitHub API request failed with status code ${res.statusCode}`)
console.log('Check the debug logs for more information')
console.log('Falling back to hardcoded versions')
resolve(fallbackVersions)
}
resolve(JSON.parse(data).map((r) => r.tag_name as string))
})
}).on('error', err => {
reject(new Error(`Error while requesting Julia versions from GitHub:\n${err}`))
}).end()
})
}
export async function getJuliaVersion(availableReleases: string[], versionInput: string): Promise<string> { export async function getJuliaVersion(availableReleases: string[], versionInput: string): Promise<string> {
if (semver.valid(versionInput) == versionInput) { if (semver.valid(versionInput) == versionInput) {

View File

@@ -10,7 +10,7 @@ async function run() {
try { try {
const versionInput = core.getInput('version') const versionInput = core.getInput('version')
const arch = core.getInput('arch') const arch = core.getInput('arch')
const availableReleases = await installer.getJuliaReleases() const availableReleases = installer.juliaVersions
const version = await installer.getJuliaVersion(availableReleases, versionInput) const version = await installer.getJuliaVersion(availableReleases, versionInput)
core.debug(`selected Julia version: ${arch}/${version}`) core.debug(`selected Julia version: ${arch}/${version}`)