releases: mutualize releases handling logic and move it to github class
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -119,7 +119,12 @@ describe('getDownloadVersion', () => {
|
|||||||
expect(version.key).toEqual('official');
|
expect(version.key).toEqual('official');
|
||||||
expect(version.version).toEqual('latest');
|
expect(version.version).toEqual('latest');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/buildx/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/buildx/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/buildx-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns official v0.10.1 download version', async () => {
|
it('returns official v0.10.1 download version', async () => {
|
||||||
@@ -127,7 +132,12 @@ describe('getDownloadVersion', () => {
|
|||||||
expect(version.key).toEqual('official');
|
expect(version.key).toEqual('official');
|
||||||
expect(version.version).toEqual('v0.10.1');
|
expect(version.version).toEqual('v0.10.1');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/buildx/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/buildx/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/buildx-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns cloud latest download version', async () => {
|
it('returns cloud latest download version', async () => {
|
||||||
@@ -135,7 +145,12 @@ describe('getDownloadVersion', () => {
|
|||||||
expect(version.key).toEqual('cloud');
|
expect(version.key).toEqual('cloud');
|
||||||
expect(version.version).toEqual('latest');
|
expect(version.version).toEqual('latest');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/buildx-lab-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns cloud v0.11.2-desktop.2 download version', async () => {
|
it('returns cloud v0.11.2-desktop.2 download version', async () => {
|
||||||
@@ -143,7 +158,12 @@ describe('getDownloadVersion', () => {
|
|||||||
expect(version.key).toEqual('cloud');
|
expect(version.key).toEqual('cloud');
|
||||||
expect(version.version).toEqual('v0.11.2-desktop.2');
|
expect(version.version).toEqual('v0.11.2-desktop.2');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/buildx-lab-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns cloud for lab version', async () => {
|
it('returns cloud for lab version', async () => {
|
||||||
@@ -151,7 +171,12 @@ describe('getDownloadVersion', () => {
|
|||||||
expect(version.key).toEqual('cloud');
|
expect(version.key).toEqual('cloud');
|
||||||
expect(version.version).toEqual('latest');
|
expect(version.version).toEqual('latest');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/buildx-desktop/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/buildx-lab-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('unknown repo', async () => {
|
it('unknown repo', async () => {
|
||||||
@@ -187,6 +212,6 @@ describe('getRelease', () => {
|
|||||||
|
|
||||||
it('unknown release', async () => {
|
it('unknown release', async () => {
|
||||||
const version = await Install.getDownloadVersion('foo');
|
const version = await Install.getDownloadVersion('foo');
|
||||||
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json'));
|
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Buildx release foo in releases JSON'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -99,28 +99,48 @@ describe('getDownloadVersion', () => {
|
|||||||
expect(version.key).toEqual('official');
|
expect(version.key).toEqual('official');
|
||||||
expect(version.version).toEqual('latest');
|
expect(version.version).toEqual('latest');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/compose/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/compose/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/compose-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('returns official v2.24.3 download version', async () => {
|
it('returns official v2.24.3 download version', async () => {
|
||||||
const version = await Install.getDownloadVersion('v2.24.3');
|
const version = await Install.getDownloadVersion('v2.24.3');
|
||||||
expect(version.key).toEqual('official');
|
expect(version.key).toEqual('official');
|
||||||
expect(version.version).toEqual('v2.24.3');
|
expect(version.version).toEqual('v2.24.3');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/compose/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/compose/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/compose-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('returns cloud latest download version', async () => {
|
it('returns cloud latest download version', async () => {
|
||||||
const version = await Install.getDownloadVersion('cloud:latest');
|
const version = await Install.getDownloadVersion('cloud:latest');
|
||||||
expect(version.key).toEqual('cloud');
|
expect(version.key).toEqual('cloud');
|
||||||
expect(version.version).toEqual('latest');
|
expect(version.version).toEqual('latest');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/compose-desktop/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/compose-desktop/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-lab-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/compose-lab-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('returns cloud v2.27.1-desktop.1 download version', async () => {
|
it('returns cloud v2.27.1-desktop.1 download version', async () => {
|
||||||
const version = await Install.getDownloadVersion('cloud:v2.27.1-desktop.1');
|
const version = await Install.getDownloadVersion('cloud:v2.27.1-desktop.1');
|
||||||
expect(version.key).toEqual('cloud');
|
expect(version.key).toEqual('cloud');
|
||||||
expect(version.version).toEqual('v2.27.1-desktop.1');
|
expect(version.version).toEqual('v2.27.1-desktop.1');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/docker/compose-desktop/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/docker/compose-desktop/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-lab-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/compose-lab-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('unknown repo', async () => {
|
it('unknown repo', async () => {
|
||||||
await expect(Install.getDownloadVersion('foo:bar')).rejects.toThrow(new Error('Cannot find compose version for foo:bar'));
|
await expect(Install.getDownloadVersion('foo:bar')).rejects.toThrow(new Error('Cannot find compose version for foo:bar'));
|
||||||
@@ -152,6 +172,6 @@ describe('getRelease', () => {
|
|||||||
});
|
});
|
||||||
it('unknown release', async () => {
|
it('unknown release', async () => {
|
||||||
const version = await Install.getDownloadVersion('foo');
|
const version = await Install.getDownloadVersion('foo');
|
||||||
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Compose release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-releases.json'));
|
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Compose release foo in releases JSON'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ import path from 'path';
|
|||||||
|
|
||||||
import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
||||||
import {Docker} from '../../src/docker/docker';
|
import {Docker} from '../../src/docker/docker';
|
||||||
import {Regctl} from '../../src/regclient/regctl';
|
|
||||||
import {Install as RegclientInstall} from '../../src/regclient/install';
|
import {Install as RegclientInstall} from '../../src/regclient/install';
|
||||||
import {Undock} from '../../src/undock/undock';
|
|
||||||
import {Install as UndockInstall} from '../../src/undock/install';
|
import {Install as UndockInstall} from '../../src/undock/install';
|
||||||
import {Exec} from '../../src/exec';
|
import {Exec} from '../../src/exec';
|
||||||
|
|
||||||
@@ -48,9 +46,7 @@ describe('root', () => {
|
|||||||
source: source,
|
source: source,
|
||||||
runDir: tmpDir(),
|
runDir: tmpDir(),
|
||||||
contextName: 'foo',
|
contextName: 'foo',
|
||||||
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
|
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`
|
||||||
regctl: new Regctl(),
|
|
||||||
undock: new Undock()
|
|
||||||
});
|
});
|
||||||
await expect(tryInstall(install)).resolves.not.toThrow();
|
await expect(tryInstall(install)).resolves.not.toThrow();
|
||||||
}, 30 * 60 * 1000);
|
}, 30 * 60 * 1000);
|
||||||
@@ -70,9 +66,7 @@ describe('rootless', () => {
|
|||||||
runDir: tmpDir(),
|
runDir: tmpDir(),
|
||||||
contextName: 'foo',
|
contextName: 'foo',
|
||||||
daemonConfig: `{"debug":true}`,
|
daemonConfig: `{"debug":true}`,
|
||||||
rootless: true,
|
rootless: true
|
||||||
regctl: new Regctl(),
|
|
||||||
undock: new Undock()
|
|
||||||
});
|
});
|
||||||
await expect(
|
await expect(
|
||||||
tryInstall(install, async () => {
|
tryInstall(install, async () => {
|
||||||
@@ -97,9 +91,7 @@ describe('tcp', () => {
|
|||||||
runDir: tmpDir(),
|
runDir: tmpDir(),
|
||||||
contextName: 'foo',
|
contextName: 'foo',
|
||||||
daemonConfig: `{"debug":true}`,
|
daemonConfig: `{"debug":true}`,
|
||||||
localTCPPort: 2378,
|
localTCPPort: 2378
|
||||||
regctl: new Regctl(),
|
|
||||||
undock: new Undock()
|
|
||||||
});
|
});
|
||||||
await expect(
|
await expect(
|
||||||
tryInstall(install, async () => {
|
tryInstall(install, async () => {
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ import * as rimraf from 'rimraf';
|
|||||||
import osm = require('os');
|
import osm = require('os');
|
||||||
|
|
||||||
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
||||||
import {Regctl} from '../../src/regclient/regctl';
|
|
||||||
import {Undock} from '../../src/undock/undock';
|
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-'));
|
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-'));
|
||||||
|
|
||||||
@@ -66,9 +64,7 @@ describe('download', () => {
|
|||||||
jest.spyOn(osm, 'arch').mockImplementation(() => 'x64');
|
jest.spyOn(osm, 'arch').mockImplementation(() => 'x64');
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
source: source,
|
source: source,
|
||||||
runDir: tmpDir,
|
runDir: tmpDir
|
||||||
regctl: new Regctl(),
|
|
||||||
undock: new Undock()
|
|
||||||
});
|
});
|
||||||
const toolPath = await install.download();
|
const toolPath = await install.download();
|
||||||
expect(fs.existsSync(toolPath)).toBe(true);
|
expect(fs.existsSync(toolPath)).toBe(true);
|
||||||
@@ -99,7 +95,7 @@ describe('getRelease', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('unknown release', async () => {
|
it('unknown release', async () => {
|
||||||
await expect(Install.getRelease('foo')).rejects.toThrow(new Error('Cannot find Docker release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json'));
|
await expect(Install.getRelease('foo')).rejects.toThrow(new Error('Cannot find Docker release foo in releases JSON'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals';
|
import {describe, expect, jest, it, beforeEach, afterEach, test} from '@jest/globals';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
@@ -43,6 +43,29 @@ describe('context', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('releases', () => {
|
||||||
|
// prettier-ignore
|
||||||
|
test.each([
|
||||||
|
['.github/buildx-lab-releases.json'],
|
||||||
|
['.github/buildx-releases.json'],
|
||||||
|
['.github/compose-lab-releases.json'],
|
||||||
|
['.github/compose-releases.json'],
|
||||||
|
['.github/docker-releases.json'],
|
||||||
|
['.github/regclient-releases.json'],
|
||||||
|
['.github/undock-releases.json'],
|
||||||
|
])('returns %p', async (path: string) => {
|
||||||
|
const github = new GitHub();
|
||||||
|
const releases = await github.releases('App', {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: path
|
||||||
|
});
|
||||||
|
expect(releases).toBeDefined();
|
||||||
|
expect(Object.keys(releases).length).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('serverURL', () => {
|
describe('serverURL', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
@@ -88,13 +88,23 @@ describe('getDownloadVersion', () => {
|
|||||||
const version = await Install.getDownloadVersion('latest');
|
const version = await Install.getDownloadVersion('latest');
|
||||||
expect(version.version).toEqual('latest');
|
expect(version.version).toEqual('latest');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/regclient/regclient/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/regclient/regclient/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/regclient-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/regclient-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('returns v0.8.1 download version', async () => {
|
it('returns v0.8.1 download version', async () => {
|
||||||
const version = await Install.getDownloadVersion('v0.8.1');
|
const version = await Install.getDownloadVersion('v0.8.1');
|
||||||
expect(version.version).toEqual('v0.8.1');
|
expect(version.version).toEqual('v0.8.1');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/regclient/regclient/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/regclient/regclient/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/regclient-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/regclient-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -115,6 +125,6 @@ describe('getRelease', () => {
|
|||||||
});
|
});
|
||||||
it('unknown release', async () => {
|
it('unknown release', async () => {
|
||||||
const version = await Install.getDownloadVersion('foo');
|
const version = await Install.getDownloadVersion('foo');
|
||||||
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find regclient release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/regclient-releases.json'));
|
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find regclient release foo in releases JSON'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -93,13 +93,23 @@ describe('getDownloadVersion', () => {
|
|||||||
const version = await Install.getDownloadVersion('latest');
|
const version = await Install.getDownloadVersion('latest');
|
||||||
expect(version.version).toEqual('latest');
|
expect(version.version).toEqual('latest');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/crazy-max/undock/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/crazy-max/undock/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/undock-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/undock-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('returns v0.6.0 download version', async () => {
|
it('returns v0.6.0 download version', async () => {
|
||||||
const version = await Install.getDownloadVersion('v0.6.0');
|
const version = await Install.getDownloadVersion('v0.6.0');
|
||||||
expect(version.version).toEqual('v0.6.0');
|
expect(version.version).toEqual('v0.6.0');
|
||||||
expect(version.downloadURL).toEqual('https://github.com/crazy-max/undock/releases/download/v%s/%s');
|
expect(version.downloadURL).toEqual('https://github.com/crazy-max/undock/releases/download/v%s/%s');
|
||||||
expect(version.releasesURL).toEqual('https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/undock-releases.json');
|
expect(version.contentOpts).toEqual({
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/undock-releases.json'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -120,6 +130,6 @@ describe('getRelease', () => {
|
|||||||
});
|
});
|
||||||
it('unknown release', async () => {
|
it('unknown release', async () => {
|
||||||
const version = await Install.getDownloadVersion('foo');
|
const version = await Install.getDownloadVersion('foo');
|
||||||
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Undock release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/undock-releases.json'));
|
await expect(Install.getRelease(version)).rejects.toThrow(new Error('Cannot find Undock release foo in releases JSON'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import fs from 'fs';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
@@ -29,6 +28,7 @@ import {Context} from '../context';
|
|||||||
import {Exec} from '../exec';
|
import {Exec} from '../exec';
|
||||||
import {Docker} from '../docker/docker';
|
import {Docker} from '../docker/docker';
|
||||||
import {Git} from '../git';
|
import {Git} from '../git';
|
||||||
|
import {GitHub} from '../github';
|
||||||
import {Util} from '../util';
|
import {Util} from '../util';
|
||||||
|
|
||||||
import {DownloadVersion} from '../types/buildx/buildx';
|
import {DownloadVersion} from '../types/buildx/buildx';
|
||||||
@@ -39,10 +39,10 @@ export interface InstallOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Install {
|
export class Install {
|
||||||
private readonly _standalone: boolean | undefined;
|
private readonly standalone: boolean | undefined;
|
||||||
|
|
||||||
constructor(opts?: InstallOpts) {
|
constructor(opts?: InstallOpts) {
|
||||||
this._standalone = opts?.standalone;
|
this.standalone = opts?.standalone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -205,7 +205,7 @@ export class Install {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async isStandalone(): Promise<boolean> {
|
private async isStandalone(): Promise<boolean> {
|
||||||
const standalone = this._standalone ?? !(await Docker.isAvailable());
|
const standalone = this.standalone ?? !(await Docker.isAvailable());
|
||||||
core.debug(`Install.isStandalone: ${standalone}`);
|
core.debug(`Install.isStandalone: ${standalone}`);
|
||||||
return standalone;
|
return standalone;
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,12 @@ export class Install {
|
|||||||
key: repoKey,
|
key: repoKey,
|
||||||
version: version,
|
version: version,
|
||||||
downloadURL: 'https://github.com/docker/buildx/releases/download/v%s/%s',
|
downloadURL: 'https://github.com/docker/buildx/releases/download/v%s/%s',
|
||||||
releasesURL: 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json'
|
contentOpts: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/buildx-releases.json'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'cloud': {
|
case 'cloud': {
|
||||||
@@ -293,7 +298,12 @@ export class Install {
|
|||||||
key: repoKey,
|
key: repoKey,
|
||||||
version: version,
|
version: version,
|
||||||
downloadURL: 'https://github.com/docker/buildx-desktop/releases/download/v%s/%s',
|
downloadURL: 'https://github.com/docker/buildx-desktop/releases/download/v%s/%s',
|
||||||
releasesURL: 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json'
|
contentOpts: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/buildx-lab-releases.json'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -303,16 +313,10 @@ export class Install {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
|
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
|
const github = new GitHub();
|
||||||
const resp: httpm.HttpClientResponse = await http.get(version.releasesURL);
|
const releases = await github.releases('Buildx', version.contentOpts);
|
||||||
const body = await resp.readBody();
|
|
||||||
const statusCode = resp.message.statusCode || 500;
|
|
||||||
if (statusCode >= 400) {
|
|
||||||
throw new Error(`Failed to get Buildx releases from ${version.releasesURL} with status code ${statusCode}: ${body}`);
|
|
||||||
}
|
|
||||||
const releases = <Record<string, GitHubRelease>>JSON.parse(body);
|
|
||||||
if (!releases[version.version]) {
|
if (!releases[version.version]) {
|
||||||
throw new Error(`Cannot find Buildx release ${version.version} in ${version.releasesURL}`);
|
throw new Error(`Cannot find Buildx release ${version.version} in releases JSON`);
|
||||||
}
|
}
|
||||||
return releases[version.version];
|
return releases[version.version];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,27 +18,27 @@ import fs from 'fs';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
|
|
||||||
import {Cache} from '../cache';
|
import {Cache} from '../cache';
|
||||||
import {Context} from '../context';
|
import {Context} from '../context';
|
||||||
|
import {Docker} from '../docker/docker';
|
||||||
|
import {GitHub} from '../github';
|
||||||
|
|
||||||
import {DownloadVersion} from '../types/compose/compose';
|
import {DownloadVersion} from '../types/compose/compose';
|
||||||
import {GitHubRelease} from '../types/github';
|
import {GitHubRelease} from '../types/github';
|
||||||
import {Docker} from '../docker/docker';
|
|
||||||
|
|
||||||
export interface InstallOpts {
|
export interface InstallOpts {
|
||||||
standalone?: boolean;
|
standalone?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Install {
|
export class Install {
|
||||||
private readonly _standalone: boolean | undefined;
|
private readonly standalone: boolean | undefined;
|
||||||
|
|
||||||
constructor(opts?: InstallOpts) {
|
constructor(opts?: InstallOpts) {
|
||||||
this._standalone = opts?.standalone;
|
this.standalone = opts?.standalone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -129,7 +129,7 @@ export class Install {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async isStandalone(): Promise<boolean> {
|
private async isStandalone(): Promise<boolean> {
|
||||||
const standalone = this._standalone ?? !(await Docker.isAvailable());
|
const standalone = this.standalone ?? !(await Docker.isAvailable());
|
||||||
core.debug(`Install.isStandalone: ${standalone}`);
|
core.debug(`Install.isStandalone: ${standalone}`);
|
||||||
return standalone;
|
return standalone;
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,12 @@ export class Install {
|
|||||||
key: repoKey,
|
key: repoKey,
|
||||||
version: version,
|
version: version,
|
||||||
downloadURL: 'https://github.com/docker/compose/releases/download/v%s/%s',
|
downloadURL: 'https://github.com/docker/compose/releases/download/v%s/%s',
|
||||||
releasesURL: 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-releases.json'
|
contentOpts: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/compose-releases.json'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'cloud': {
|
case 'cloud': {
|
||||||
@@ -191,7 +196,12 @@ export class Install {
|
|||||||
key: repoKey,
|
key: repoKey,
|
||||||
version: version,
|
version: version,
|
||||||
downloadURL: 'https://github.com/docker/compose-desktop/releases/download/v%s/%s',
|
downloadURL: 'https://github.com/docker/compose-desktop/releases/download/v%s/%s',
|
||||||
releasesURL: 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/compose-lab-releases.json'
|
contentOpts: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/compose-lab-releases.json'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -201,16 +211,10 @@ export class Install {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
|
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
|
const github = new GitHub();
|
||||||
const resp: httpm.HttpClientResponse = await http.get(version.releasesURL);
|
const releases = await github.releases('Compose', version.contentOpts);
|
||||||
const body = await resp.readBody();
|
|
||||||
const statusCode = resp.message.statusCode || 500;
|
|
||||||
if (statusCode >= 400) {
|
|
||||||
throw new Error(`Failed to get Compose releases from ${version.releasesURL} with status code ${statusCode}: ${body}`);
|
|
||||||
}
|
|
||||||
const releases = <Record<string, GitHubRelease>>JSON.parse(body);
|
|
||||||
if (!releases[version.version]) {
|
if (!releases[version.version]) {
|
||||||
throw new Error(`Cannot find Compose release ${version.version} in ${version.releasesURL}`);
|
throw new Error(`Cannot find Compose release ${version.version} in releases JSON`);
|
||||||
}
|
}
|
||||||
return releases[version.version];
|
return releases[version.version];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,16 +22,17 @@ import path from 'path';
|
|||||||
import retry from 'async-retry';
|
import retry from 'async-retry';
|
||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
|
|
||||||
import {Context} from '../context';
|
import {Context} from '../context';
|
||||||
import {Docker} from './docker';
|
import {Docker} from './docker';
|
||||||
|
import {Exec} from '../exec';
|
||||||
|
import {GitHub} from '../github';
|
||||||
import {Regctl} from '../regclient/regctl';
|
import {Regctl} from '../regclient/regctl';
|
||||||
import {Undock} from '../undock/undock';
|
import {Undock} from '../undock/undock';
|
||||||
import {Exec} from '../exec';
|
|
||||||
import {Util} from '../util';
|
import {Util} from '../util';
|
||||||
|
|
||||||
import {limaYamlData, dockerServiceLogsPs1, setupDockerWinPs1} from './assets';
|
import {limaYamlData, dockerServiceLogsPs1, setupDockerWinPs1} from './assets';
|
||||||
|
|
||||||
import {GitHubRelease} from '../types/github';
|
import {GitHubRelease} from '../types/github';
|
||||||
@@ -694,18 +695,16 @@ EOF`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async getRelease(version: string): Promise<GitHubRelease> {
|
public static async getRelease(version: string): Promise<GitHubRelease> {
|
||||||
const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json`;
|
const github = new GitHub();
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
|
const releases = await github.releases('Docker', {
|
||||||
const resp: httpm.HttpClientResponse = await http.get(url);
|
owner: 'docker',
|
||||||
const body = await resp.readBody();
|
repo: 'actions-toolkit',
|
||||||
const statusCode = resp.message.statusCode || 500;
|
ref: 'main',
|
||||||
if (statusCode >= 400) {
|
path: '.github/docker-releases.json'
|
||||||
throw new Error(`Failed to get Docker release ${version} from ${url} with status code ${statusCode}: ${body}`);
|
});
|
||||||
}
|
|
||||||
const releases = <Record<string, GitHubRelease>>JSON.parse(body);
|
|
||||||
if (!releases[version]) {
|
if (!releases[version]) {
|
||||||
if (!releases['v' + version]) {
|
if (!releases['v' + version]) {
|
||||||
throw new Error(`Cannot find Docker release ${version} in ${url}`);
|
throw new Error(`Cannot find Docker release ${version} in releases JSON`);
|
||||||
}
|
}
|
||||||
return releases['v' + version];
|
return releases['v' + version];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,14 @@ import {SummaryTableCell} from '@actions/core/lib/summary';
|
|||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
import {GitHub as Octokit} from '@actions/github/lib/utils';
|
import {GitHub as Octokit} from '@actions/github/lib/utils';
|
||||||
import {Context} from '@actions/github/lib/context';
|
import {Context} from '@actions/github/lib/context';
|
||||||
|
import * as httpm from '@actions/http-client';
|
||||||
import {TransferProgressEvent} from '@azure/core-http';
|
import {TransferProgressEvent} from '@azure/core-http';
|
||||||
import {BlobClient, BlobHTTPHeaders} from '@azure/storage-blob';
|
import {BlobClient, BlobHTTPHeaders} from '@azure/storage-blob';
|
||||||
import {jwtDecode, JwtPayload} from 'jwt-decode';
|
import {jwtDecode, JwtPayload} from 'jwt-decode';
|
||||||
|
|
||||||
import {Util} from './util';
|
import {Util} from './util';
|
||||||
|
|
||||||
import {BuildSummaryOpts, GitHubActionsRuntimeToken, GitHubActionsRuntimeTokenAC, GitHubRepo, UploadArtifactOpts, UploadArtifactResponse} from './types/github';
|
import {BuildSummaryOpts, GitHubActionsRuntimeToken, GitHubActionsRuntimeTokenAC, GitHubContentOpts, GitHubRelease, GitHubRepo, UploadArtifactOpts, UploadArtifactResponse} from './types/github';
|
||||||
|
|
||||||
export interface GitHubOpts {
|
export interface GitHubOpts {
|
||||||
token?: string;
|
token?: string;
|
||||||
@@ -54,6 +55,18 @@ export class GitHub {
|
|||||||
return this.octokit.rest.repos.get({...github.context.repo}).then(response => response.data as GitHubRepo);
|
return this.octokit.rest.repos.get({...github.context.repo}).then(response => response.data as GitHubRepo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async releases(name: string, opts: GitHubContentOpts): Promise<Record<string, GitHubRelease>> {
|
||||||
|
const url = `https://raw.githubusercontent.com/${opts.owner}/${opts.repo}/${opts.ref}/${opts.path}`;
|
||||||
|
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
|
||||||
|
const httpResp: httpm.HttpClientResponse = await http.get(url);
|
||||||
|
const dt = await httpResp.readBody();
|
||||||
|
const statusCode = httpResp.message.statusCode || 500;
|
||||||
|
if (statusCode >= 400) {
|
||||||
|
throw new Error(`Failed to get ${name} releases from ${url} with status code ${statusCode}: ${dt}`);
|
||||||
|
}
|
||||||
|
return <Record<string, GitHubRelease>>JSON.parse(dt);
|
||||||
|
}
|
||||||
|
|
||||||
static get context(): Context {
|
static get context(): Context {
|
||||||
return github.context;
|
return github.context;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ import fs from 'fs';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
|
|
||||||
import {Cache} from '../cache';
|
import {Cache} from '../cache';
|
||||||
import {Context} from '../context';
|
import {Context} from '../context';
|
||||||
|
import {GitHub} from '../github';
|
||||||
|
|
||||||
import {GitHubRelease} from '../types/github';
|
import {GitHubRelease} from '../types/github';
|
||||||
import {DownloadVersion} from '../types/regclient/regclient';
|
import {DownloadVersion} from '../types/regclient/regclient';
|
||||||
@@ -134,21 +134,20 @@ export class Install {
|
|||||||
return {
|
return {
|
||||||
version: v,
|
version: v,
|
||||||
downloadURL: 'https://github.com/regclient/regclient/releases/download/v%s/%s',
|
downloadURL: 'https://github.com/regclient/regclient/releases/download/v%s/%s',
|
||||||
releasesURL: 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/regclient-releases.json'
|
contentOpts: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/regclient-releases.json'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
|
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
|
const github = new GitHub();
|
||||||
const resp: httpm.HttpClientResponse = await http.get(version.releasesURL);
|
const releases = await github.releases('regclient', version.contentOpts);
|
||||||
const body = await resp.readBody();
|
|
||||||
const statusCode = resp.message.statusCode || 500;
|
|
||||||
if (statusCode >= 400) {
|
|
||||||
throw new Error(`Failed to get regclient releases from ${version.releasesURL} with status code ${statusCode}: ${body}`);
|
|
||||||
}
|
|
||||||
const releases = <Record<string, GitHubRelease>>JSON.parse(body);
|
|
||||||
if (!releases[version.version]) {
|
if (!releases[version.version]) {
|
||||||
throw new Error(`Cannot find regclient release ${version.version} in ${version.releasesURL}`);
|
throw new Error(`Cannot find regclient release ${version.version} in releases JSON`);
|
||||||
}
|
}
|
||||||
return releases[version.version];
|
return releases[version.version];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {GitHubContentOpts} from '../github';
|
||||||
|
|
||||||
export interface Cert {
|
export interface Cert {
|
||||||
cacert?: string;
|
cacert?: string;
|
||||||
cert?: string;
|
cert?: string;
|
||||||
@@ -24,7 +26,7 @@ export interface DownloadVersion {
|
|||||||
key: string;
|
key: string;
|
||||||
version: string;
|
version: string;
|
||||||
downloadURL: string;
|
downloadURL: string;
|
||||||
releasesURL: string;
|
contentOpts: GitHubContentOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LocalRefsOpts {
|
export interface LocalRefsOpts {
|
||||||
|
|||||||
@@ -14,9 +14,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {GitHubContentOpts} from '../github';
|
||||||
|
|
||||||
export interface DownloadVersion {
|
export interface DownloadVersion {
|
||||||
key: string;
|
key: string;
|
||||||
version: string;
|
version: string;
|
||||||
downloadURL: string;
|
downloadURL: string;
|
||||||
releasesURL: string;
|
contentOpts: GitHubContentOpts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ export interface GitHubRelease {
|
|||||||
assets: Array<string>;
|
assets: Array<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GitHubContentOpts {
|
||||||
|
owner: string;
|
||||||
|
repo: string;
|
||||||
|
ref?: string;
|
||||||
|
path: string;
|
||||||
|
}
|
||||||
|
|
||||||
export type GitHubRepo = OctoOpenApiTypes['schemas']['repository'];
|
export type GitHubRepo = OctoOpenApiTypes['schemas']['repository'];
|
||||||
|
|
||||||
export interface GitHubActionsRuntimeToken extends JwtPayload {
|
export interface GitHubActionsRuntimeToken extends JwtPayload {
|
||||||
|
|||||||
@@ -14,8 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {GitHubContentOpts} from '../github';
|
||||||
|
|
||||||
export interface DownloadVersion {
|
export interface DownloadVersion {
|
||||||
version: string;
|
version: string;
|
||||||
downloadURL: string;
|
downloadURL: string;
|
||||||
releasesURL: string;
|
contentOpts: GitHubContentOpts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {GitHubContentOpts} from '../github';
|
||||||
|
|
||||||
export interface DownloadVersion {
|
export interface DownloadVersion {
|
||||||
version: string;
|
version: string;
|
||||||
downloadURL: string;
|
downloadURL: string;
|
||||||
releasesURL: string;
|
contentOpts: GitHubContentOpts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ import fs from 'fs';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
|
|
||||||
import {Cache} from '../cache';
|
import {Cache} from '../cache';
|
||||||
import {Context} from '../context';
|
import {Context} from '../context';
|
||||||
|
import {GitHub} from '../github';
|
||||||
|
|
||||||
import {GitHubRelease} from '../types/github';
|
import {GitHubRelease} from '../types/github';
|
||||||
import {DownloadVersion} from '../types/undock/undock';
|
import {DownloadVersion} from '../types/undock/undock';
|
||||||
@@ -145,21 +145,20 @@ export class Install {
|
|||||||
return {
|
return {
|
||||||
version: v,
|
version: v,
|
||||||
downloadURL: 'https://github.com/crazy-max/undock/releases/download/v%s/%s',
|
downloadURL: 'https://github.com/crazy-max/undock/releases/download/v%s/%s',
|
||||||
releasesURL: 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/undock-releases.json'
|
contentOpts: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit',
|
||||||
|
ref: 'main',
|
||||||
|
path: '.github/undock-releases.json'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
|
public static async getRelease(version: DownloadVersion): Promise<GitHubRelease> {
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
|
const github = new GitHub();
|
||||||
const resp: httpm.HttpClientResponse = await http.get(version.releasesURL);
|
const releases = await github.releases('Undock', version.contentOpts);
|
||||||
const body = await resp.readBody();
|
|
||||||
const statusCode = resp.message.statusCode || 500;
|
|
||||||
if (statusCode >= 400) {
|
|
||||||
throw new Error(`Failed to get Undock releases from ${version.releasesURL} with status code ${statusCode}: ${body}`);
|
|
||||||
}
|
|
||||||
const releases = <Record<string, GitHubRelease>>JSON.parse(body);
|
|
||||||
if (!releases[version.version]) {
|
if (!releases[version.version]) {
|
||||||
throw new Error(`Cannot find Undock release ${version.version} in ${version.releasesURL}`);
|
throw new Error(`Cannot find Undock release ${version.version} in releases JSON`);
|
||||||
}
|
}
|
||||||
return releases[version.version];
|
return releases[version.version];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user