mirror of
https://github.com/dagger/dagger-for-github.git
synced 2026-01-01 21:19:44 +11:00
support major-minor version pinning
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
13b2e51327
commit
ad17c50af5
3 changed files with 21 additions and 12 deletions
|
|
@ -8,6 +8,12 @@ describe('install', () => {
|
|||
expect(fs.existsSync(daggerBin)).toBe(true);
|
||||
}, 100000);
|
||||
|
||||
it('acquires latest 0.1 version', async () => {
|
||||
const daggerBin = await dagger.install('0.1');
|
||||
console.log(daggerBin);
|
||||
expect(fs.existsSync(daggerBin)).toBe(true);
|
||||
}, 100000);
|
||||
|
||||
it('acquires 0.1.0-alpha.9 version of Dagger', async () => {
|
||||
const daggerBin = await dagger.install('0.1.0-alpha.9');
|
||||
console.log(daggerBin);
|
||||
|
|
|
|||
13
dist/index.js
generated
vendored
13
dist/index.js
generated
vendored
|
|
@ -101,9 +101,7 @@ const osPlat = os.platform();
|
|||
const osArch = os.arch();
|
||||
function install(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (version == 'latest') {
|
||||
version = yield getLatestVersion();
|
||||
}
|
||||
version = yield getVersionMapping(version);
|
||||
version = version.replace(/^v/, '');
|
||||
const downloadUrl = util.format('%s/releases/%s/%s', s3URL, version, getFilename(version));
|
||||
core.info(`Downloading ${downloadUrl}`);
|
||||
|
|
@ -126,10 +124,13 @@ function install(version) {
|
|||
});
|
||||
}
|
||||
exports.install = install;
|
||||
function getLatestVersion() {
|
||||
function getVersionMapping(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const _http = new http.HttpClient('dagger-for-github');
|
||||
const res = yield _http.get(`${s3URL}/latest_version`);
|
||||
const res = yield _http.get(`${s3URL}/versions/${version}`);
|
||||
if (res.message.statusCode != 200) {
|
||||
return version;
|
||||
}
|
||||
return yield res.readBody().then(body => {
|
||||
return body.trim();
|
||||
});
|
||||
|
|
@ -137,7 +138,7 @@ function getLatestVersion() {
|
|||
}
|
||||
const getFilename = (version) => {
|
||||
const platform = osPlat == 'win32' ? 'windows' : osPlat;
|
||||
const arch = osArch == 'x64' ? 'amd64' : 'i386';
|
||||
const arch = osArch == 'x64' ? 'amd64' : osArch;
|
||||
const ext = osPlat == 'win32' ? '.zip' : '.tar.gz';
|
||||
return util.format('dagger_v%s_%s_%s%s', version, platform, arch, ext);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@ const osPlat: string = os.platform();
|
|||
const osArch: string = os.arch();
|
||||
|
||||
export async function install(version: string): Promise<string> {
|
||||
if (version == 'latest') {
|
||||
version = await getLatestVersion();
|
||||
}
|
||||
version = await getVersionMapping(version);
|
||||
version = version.replace(/^v/, '');
|
||||
|
||||
const downloadUrl: string = util.format('%s/releases/%s/%s', s3URL, version, getFilename(version));
|
||||
|
|
@ -38,9 +36,13 @@ export async function install(version: string): Promise<string> {
|
|||
return path.join(cachePath, osPlat == 'win32' ? 'dagger.exe' : 'dagger');
|
||||
}
|
||||
|
||||
async function getLatestVersion(): Promise<string> {
|
||||
async function getVersionMapping(version: string): Promise<string> {
|
||||
const _http = new http.HttpClient('dagger-for-github');
|
||||
const res = await _http.get(`${s3URL}/latest_version`);
|
||||
const res = await _http.get(`${s3URL}/versions/${version}`);
|
||||
if (res.message.statusCode != 200) {
|
||||
return version;
|
||||
}
|
||||
|
||||
return await res.readBody().then(body => {
|
||||
return body.trim();
|
||||
});
|
||||
|
|
@ -48,7 +50,7 @@ async function getLatestVersion(): Promise<string> {
|
|||
|
||||
const getFilename = (version: string): string => {
|
||||
const platform: string = osPlat == 'win32' ? 'windows' : osPlat;
|
||||
const arch: string = osArch == 'x64' ? 'amd64' : 'i386';
|
||||
const arch: string = osArch == 'x64' ? 'amd64' : osArch;
|
||||
const ext: string = osPlat == 'win32' ? '.zip' : '.tar.gz';
|
||||
return util.format('dagger_v%s_%s_%s%s', version, platform, arch, ext);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue