mirror of
https://github.com/subosito/flutter-action.git
synced 2024-08-16 10:19:50 +02:00
handle .x version syntax
This commit is contained in:
parent
9421912880
commit
be0241570a
2 changed files with 28 additions and 0 deletions
|
@ -24,6 +24,7 @@ const tc = __importStar(require("@actions/tool-cache"));
|
|||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const restm = __importStar(require("typed-rest-client/RestClient"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const v4_1 = __importDefault(require("uuid/v4"));
|
||||
const exec_1 = require("@actions/exec/lib/exec");
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
|
@ -179,6 +180,14 @@ function getLatestVersion(version, channel) {
|
|||
if (!storage) {
|
||||
throw new Error('unable to get latest version');
|
||||
}
|
||||
if (version.endsWith('.x')) {
|
||||
const sver = version.slice(0, version.length - 2);
|
||||
const releases = storage.releases.filter(release => release.version.startsWith(`v${sver}`) && release.channel === channel);
|
||||
const versions = releases.map(release => release.version.slice(1, release.version.length));
|
||||
const sortedVersions = versions.sort(semver.rcompare);
|
||||
core.debug(`latest version of ${version} from channel ${channel} is ${sortedVersions[0]}`);
|
||||
return sortedVersions[0];
|
||||
}
|
||||
const channelVersion = storage.releases.find(release => release.hash === storage.current_release[channel]);
|
||||
if (!channelVersion) {
|
||||
throw new Error(`unable to get latest version from channel ${channel}`);
|
||||
|
|
|
@ -4,6 +4,7 @@ import * as tc from '@actions/tool-cache';
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as restm from 'typed-rest-client/RestClient';
|
||||
import * as semver from 'semver';
|
||||
import uuidV4 from 'uuid/v4';
|
||||
import {exec} from '@actions/exec/lib/exec';
|
||||
|
||||
|
@ -218,6 +219,24 @@ async function getLatestVersion(
|
|||
throw new Error('unable to get latest version');
|
||||
}
|
||||
|
||||
if (version.endsWith('.x')) {
|
||||
const sver = version.slice(0, version.length - 2);
|
||||
const releases = storage.releases.filter(
|
||||
release =>
|
||||
release.version.startsWith(`v${sver}`) && release.channel === channel
|
||||
);
|
||||
const versions = releases.map(release =>
|
||||
release.version.slice(1, release.version.length)
|
||||
);
|
||||
const sortedVersions = versions.sort(semver.rcompare);
|
||||
|
||||
core.debug(
|
||||
`latest version of ${version} from channel ${channel} is ${sortedVersions[0]}`
|
||||
);
|
||||
|
||||
return sortedVersions[0];
|
||||
}
|
||||
|
||||
const channelVersion = storage.releases.find(
|
||||
release => release.hash === storage.current_release[channel]
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue