@docker/actions-toolkit 0.1.0-beta.9 → 0.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/lib/buildkit/buildkit.d.ts +4 -7
- package/lib/buildkit/buildkit.js +20 -38
- package/lib/buildkit/buildkit.js.map +1 -1
- package/lib/buildkit/config.d.ts +0 -3
- package/lib/buildkit/config.js +2 -4
- package/lib/buildkit/config.js.map +1 -1
- package/lib/buildx/bake.d.ts +29 -0
- package/lib/buildx/bake.js +74 -0
- package/lib/buildx/bake.js.map +1 -0
- package/lib/buildx/builder.d.ts +2 -4
- package/lib/buildx/builder.js +30 -14
- package/lib/buildx/builder.js.map +1 -1
- package/lib/buildx/buildx.d.ts +7 -10
- package/lib/buildx/buildx.js +47 -36
- package/lib/buildx/buildx.js.map +1 -1
- package/lib/buildx/inputs.d.ts +10 -13
- package/lib/buildx/inputs.js +24 -27
- package/lib/buildx/inputs.js.map +1 -1
- package/lib/buildx/install.d.ts +6 -8
- package/lib/buildx/install.js +61 -54
- package/lib/buildx/install.js.map +1 -1
- package/lib/context.d.ts +6 -7
- package/lib/context.js +18 -13
- package/lib/context.js.map +1 -1
- package/lib/docker/assets.d.ts +23 -0
- package/lib/docker/assets.js +339 -0
- package/lib/docker/assets.js.map +1 -0
- package/lib/{docker.d.ts → docker/docker.d.ts} +4 -3
- package/lib/{docker.js → docker/docker.js} +33 -39
- package/lib/docker/docker.js.map +1 -0
- package/lib/docker/install.d.ts +46 -0
- package/lib/docker/install.js +393 -0
- package/lib/docker/install.js.map +1 -0
- package/lib/exec.d.ts +20 -0
- package/lib/exec.js +68 -0
- package/lib/exec.js.map +1 -0
- package/lib/git.d.ts +10 -1
- package/lib/git.js +76 -34
- package/lib/git.js.map +1 -1
- package/lib/github.js +3 -5
- package/lib/github.js.map +1 -1
- package/lib/index.d.ts +24 -0
- package/lib/index.js +80 -0
- package/lib/index.js.map +1 -0
- package/lib/toolkit.d.ts +0 -2
- package/lib/toolkit.js +4 -6
- package/lib/toolkit.js.map +1 -1
- package/lib/types/bake.d.ts +42 -0
- package/lib/types/bake.js +18 -0
- package/lib/types/bake.js.map +1 -0
- package/lib/types/builder.d.ts +4 -9
- package/lib/types/git.d.ts +17 -0
- package/lib/types/git.js +18 -0
- package/lib/types/git.js.map +1 -0
- package/lib/util.d.ts +5 -0
- package/lib/util.js +30 -0
- package/lib/util.js.map +1 -1
- package/package.json +10 -5
- package/lib/docker.js.map +0 -1
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023 actions-toolkit authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.Install = void 0;
|
|
54
|
+
const child_process = __importStar(require("child_process"));
|
|
55
|
+
const fs_1 = __importDefault(require("fs"));
|
|
56
|
+
const os_1 = __importDefault(require("os"));
|
|
57
|
+
const path_1 = __importDefault(require("path"));
|
|
58
|
+
const async_retry_1 = __importDefault(require("async-retry"));
|
|
59
|
+
const handlebars = __importStar(require("handlebars"));
|
|
60
|
+
const util = __importStar(require("util"));
|
|
61
|
+
const core = __importStar(require("@actions/core"));
|
|
62
|
+
const httpm = __importStar(require("@actions/http-client"));
|
|
63
|
+
const io = __importStar(require("@actions/io"));
|
|
64
|
+
const tc = __importStar(require("@actions/tool-cache"));
|
|
65
|
+
const context_1 = require("../context");
|
|
66
|
+
const exec_1 = require("../exec");
|
|
67
|
+
const util_1 = require("../util");
|
|
68
|
+
const assets_1 = require("./assets");
|
|
69
|
+
class Install {
|
|
70
|
+
constructor(opts) {
|
|
71
|
+
this.runDir = opts.runDir;
|
|
72
|
+
this.version = opts.version || 'latest';
|
|
73
|
+
this.channel = opts.channel || 'stable';
|
|
74
|
+
this.contextName = opts.contextName || 'setup-docker-action';
|
|
75
|
+
}
|
|
76
|
+
get toolDir() {
|
|
77
|
+
return this._toolDir || context_1.Context.tmpDir();
|
|
78
|
+
}
|
|
79
|
+
download() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const release = yield Install.getRelease(this.version);
|
|
82
|
+
this._version = release.tag_name.replace(/^v+|v+$/g, '');
|
|
83
|
+
core.debug(`docker.Install.download version: ${this._version}`);
|
|
84
|
+
const downloadURL = this.downloadURL(this._version, this.channel);
|
|
85
|
+
core.info(`Downloading ${downloadURL}`);
|
|
86
|
+
const downloadPath = yield tc.downloadTool(downloadURL);
|
|
87
|
+
core.debug(`docker.Install.download downloadPath: ${downloadPath}`);
|
|
88
|
+
let extractFolder;
|
|
89
|
+
if (os_1.default.platform() == 'win32') {
|
|
90
|
+
extractFolder = yield tc.extractZip(downloadPath);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
extractFolder = yield tc.extractTar(downloadPath);
|
|
94
|
+
}
|
|
95
|
+
if (util_1.Util.isDirectory(path_1.default.join(extractFolder, 'docker'))) {
|
|
96
|
+
extractFolder = path_1.default.join(extractFolder, 'docker');
|
|
97
|
+
}
|
|
98
|
+
core.debug(`docker.Install.download extractFolder: ${extractFolder}`);
|
|
99
|
+
core.info('Fixing perms');
|
|
100
|
+
fs_1.default.readdir(path_1.default.join(extractFolder), function (err, files) {
|
|
101
|
+
if (err) {
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
105
|
+
files.forEach(function (file, index) {
|
|
106
|
+
fs_1.default.chmodSync(path_1.default.join(extractFolder, file), '0755');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
const tooldir = yield tc.cacheDir(extractFolder, `docker-${this.channel}`, this._version.replace(/(0+)([1-9]+)/, '$2'));
|
|
110
|
+
core.addPath(tooldir);
|
|
111
|
+
core.info('Added Docker to PATH');
|
|
112
|
+
this._toolDir = tooldir;
|
|
113
|
+
return tooldir;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
install() {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
if (!this.toolDir) {
|
|
119
|
+
throw new Error('toolDir must be set. Run download first.');
|
|
120
|
+
}
|
|
121
|
+
if (!this.runDir) {
|
|
122
|
+
throw new Error('runDir must be set');
|
|
123
|
+
}
|
|
124
|
+
switch (os_1.default.platform()) {
|
|
125
|
+
case 'darwin': {
|
|
126
|
+
yield this.installDarwin();
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case 'linux': {
|
|
130
|
+
yield this.installLinux();
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case 'win32': {
|
|
134
|
+
yield this.installWindows();
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
default: {
|
|
138
|
+
throw new Error(`Unsupported platform: ${os_1.default.platform()}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
installDarwin() {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const colimaDir = path_1.default.join(os_1.default.homedir(), '.colima', 'default'); // TODO: create a custom colima profile to avoid overlap with other actions
|
|
146
|
+
yield io.mkdirP(colimaDir);
|
|
147
|
+
const dockerHost = `unix://${colimaDir}/docker.sock`;
|
|
148
|
+
if (!(yield Install.colimaInstalled())) {
|
|
149
|
+
yield core.group('Installing colima', () => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
yield exec_1.Exec.exec('brew', ['install', 'colima']);
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
yield core.group('Creating colima config', () => __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const colimaCfg = handlebars.compile(assets_1.colimaYamlData)({
|
|
155
|
+
hostArch: Install.platformArch(),
|
|
156
|
+
dockerVersion: this._version,
|
|
157
|
+
dockerChannel: this.channel
|
|
158
|
+
});
|
|
159
|
+
core.info(`Writing colima config to ${path_1.default.join(colimaDir, 'colima.yaml')}`);
|
|
160
|
+
fs_1.default.writeFileSync(path_1.default.join(colimaDir, 'colima.yaml'), colimaCfg);
|
|
161
|
+
core.info(colimaCfg);
|
|
162
|
+
}));
|
|
163
|
+
// colima is already started on the runner so env var added in download
|
|
164
|
+
// method is not expanded to the running process.
|
|
165
|
+
const envs = Object.assign({}, process.env, {
|
|
166
|
+
PATH: `${this.toolDir}:${process.env.PATH}`
|
|
167
|
+
});
|
|
168
|
+
yield core.group('Starting colima', () => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
yield exec_1.Exec.exec('colima', ['start', '--very-verbose'], { env: envs });
|
|
170
|
+
}));
|
|
171
|
+
yield core.group('Create Docker context', () => __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
yield exec_1.Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
|
173
|
+
yield exec_1.Exec.exec('docker', ['context', 'use', this.contextName]);
|
|
174
|
+
}));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
installLinux() {
|
|
178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
const dockerHost = `unix://${path_1.default.join(this.runDir, 'docker.sock')}`;
|
|
180
|
+
yield io.mkdirP(this.runDir);
|
|
181
|
+
yield core.group('Start Docker daemon', () => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const bashPath = yield io.which('bash', true);
|
|
183
|
+
const proc = yield child_process.spawn(`sudo -E ${bashPath} ${(0, assets_1.setupDockerLinuxSh)()}`, [], {
|
|
184
|
+
detached: true,
|
|
185
|
+
shell: true,
|
|
186
|
+
stdio: ['ignore', process.stdout, process.stderr],
|
|
187
|
+
env: Object.assign({}, process.env, {
|
|
188
|
+
TOOLDIR: this.toolDir,
|
|
189
|
+
RUNDIR: this.runDir,
|
|
190
|
+
DOCKER_HOST: dockerHost
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
proc.unref();
|
|
194
|
+
yield (0, async_retry_1.default)((bail) => __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
yield exec_1.Exec.getExecOutput(`docker version`, undefined, {
|
|
196
|
+
ignoreReturnCode: true,
|
|
197
|
+
silent: true,
|
|
198
|
+
env: Object.assign({}, process.env, {
|
|
199
|
+
DOCKER_HOST: dockerHost
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
.then(res => {
|
|
203
|
+
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
204
|
+
bail(new Error(res.stderr));
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
return res.exitCode == 0;
|
|
208
|
+
})
|
|
209
|
+
.catch(error => {
|
|
210
|
+
bail(error);
|
|
211
|
+
return false;
|
|
212
|
+
});
|
|
213
|
+
}), {
|
|
214
|
+
retries: 5
|
|
215
|
+
});
|
|
216
|
+
core.info(`Docker daemon started started successfully`);
|
|
217
|
+
}));
|
|
218
|
+
yield core.group('Create Docker context', () => __awaiter(this, void 0, void 0, function* () {
|
|
219
|
+
yield exec_1.Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
|
220
|
+
yield exec_1.Exec.exec('docker', ['context', 'use', this.contextName]);
|
|
221
|
+
}));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
installWindows() {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
const dockerHost = 'npipe:////./pipe/setup_docker_action';
|
|
227
|
+
yield core.group('Install Docker daemon service', () => __awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
const setupCmd = yield util_1.Util.powershellCommand((0, assets_1.setupDockerWinPs1)(), {
|
|
229
|
+
ToolDir: this.toolDir,
|
|
230
|
+
RunDir: this.runDir,
|
|
231
|
+
DockerHost: dockerHost
|
|
232
|
+
});
|
|
233
|
+
yield exec_1.Exec.exec(setupCmd.command, setupCmd.args);
|
|
234
|
+
const logCmd = yield util_1.Util.powershellCommand((0, assets_1.dockerServiceLogsPs1)());
|
|
235
|
+
yield exec_1.Exec.exec(logCmd.command, logCmd.args);
|
|
236
|
+
}));
|
|
237
|
+
yield core.group('Create Docker context', () => __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
yield exec_1.Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
|
239
|
+
yield exec_1.Exec.exec('docker', ['context', 'use', this.contextName]);
|
|
240
|
+
}));
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
tearDown() {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
if (!this.runDir) {
|
|
246
|
+
throw new Error('runDir must be set');
|
|
247
|
+
}
|
|
248
|
+
switch (os_1.default.platform()) {
|
|
249
|
+
case 'darwin': {
|
|
250
|
+
yield this.tearDownDarwin();
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
case 'linux': {
|
|
254
|
+
yield this.tearDownLinux();
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case 'win32': {
|
|
258
|
+
yield this.tearDownWindows();
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
default: {
|
|
262
|
+
throw new Error(`Unsupported platform: ${os_1.default.platform()}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
tearDownDarwin() {
|
|
268
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
+
yield core.group('Docker daemon logs', () => __awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
yield exec_1.Exec.exec('colima', ['exec', '--', 'cat', '/var/log/docker.log']);
|
|
271
|
+
}));
|
|
272
|
+
yield core.group('Stopping colima', () => __awaiter(this, void 0, void 0, function* () {
|
|
273
|
+
yield exec_1.Exec.exec('colima', ['stop', '--very-verbose']);
|
|
274
|
+
}));
|
|
275
|
+
yield core.group('Removing Docker context', () => __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
yield exec_1.Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
|
|
277
|
+
}));
|
|
278
|
+
yield core.group(`Cleaning up runDir`, () => __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
yield exec_1.Exec.exec('sudo', ['rm', '-rf', this.runDir]);
|
|
280
|
+
}));
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
tearDownLinux() {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
yield core.group('Docker daemon logs', () => __awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
core.info(fs_1.default.readFileSync(path_1.default.join(this.runDir, 'dockerd.log'), { encoding: 'utf8' }));
|
|
287
|
+
}));
|
|
288
|
+
yield core.group('Stopping Docker daemon', () => __awaiter(this, void 0, void 0, function* () {
|
|
289
|
+
yield exec_1.Exec.exec('sudo', ['kill', fs_1.default.readFileSync(path_1.default.join(this.runDir, 'docker.pid')).toString().trim()]);
|
|
290
|
+
}));
|
|
291
|
+
yield core.group('Removing Docker context', () => __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
yield exec_1.Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
|
|
293
|
+
}));
|
|
294
|
+
yield core.group(`Cleaning up runDir`, () => __awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
yield exec_1.Exec.exec('sudo', ['rm', '-rf', this.runDir]);
|
|
296
|
+
}));
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
tearDownWindows() {
|
|
300
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
+
yield core.group('Docker daemon logs', () => __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
const logCmd = yield util_1.Util.powershellCommand((0, assets_1.dockerServiceLogsPs1)());
|
|
303
|
+
yield exec_1.Exec.exec(logCmd.command, logCmd.args);
|
|
304
|
+
}));
|
|
305
|
+
yield core.group('Removing Docker context', () => __awaiter(this, void 0, void 0, function* () {
|
|
306
|
+
yield exec_1.Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
|
|
307
|
+
}));
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
downloadURL(version, channel) {
|
|
311
|
+
const platformOS = Install.platformOS();
|
|
312
|
+
const platformArch = Install.platformArch();
|
|
313
|
+
const ext = platformOS === 'win' ? '.zip' : '.tgz';
|
|
314
|
+
return util.format('https://download.docker.com/%s/static/%s/%s/docker-%s%s', platformOS, channel, platformArch, version, ext);
|
|
315
|
+
}
|
|
316
|
+
static platformOS() {
|
|
317
|
+
switch (os_1.default.platform()) {
|
|
318
|
+
case 'darwin': {
|
|
319
|
+
return 'mac';
|
|
320
|
+
}
|
|
321
|
+
case 'linux': {
|
|
322
|
+
return 'linux';
|
|
323
|
+
}
|
|
324
|
+
case 'win32': {
|
|
325
|
+
return 'win';
|
|
326
|
+
}
|
|
327
|
+
default: {
|
|
328
|
+
return os_1.default.platform();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
static platformArch() {
|
|
333
|
+
switch (os_1.default.arch()) {
|
|
334
|
+
case 'x64': {
|
|
335
|
+
return 'x86_64';
|
|
336
|
+
}
|
|
337
|
+
case 'ppc64': {
|
|
338
|
+
return 'ppc64le';
|
|
339
|
+
}
|
|
340
|
+
case 'arm': {
|
|
341
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
342
|
+
const arm_version = process.config.variables.arm_version;
|
|
343
|
+
switch (arm_version) {
|
|
344
|
+
case 6: {
|
|
345
|
+
return 'armel';
|
|
346
|
+
}
|
|
347
|
+
case 7: {
|
|
348
|
+
return 'armhf';
|
|
349
|
+
}
|
|
350
|
+
default: {
|
|
351
|
+
return `v${arm_version}`;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
default: {
|
|
356
|
+
return os_1.default.arch();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
static colimaInstalled() {
|
|
361
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
362
|
+
return yield io
|
|
363
|
+
.which('colima', true)
|
|
364
|
+
.then(res => {
|
|
365
|
+
core.debug(`docker.Install.colimaAvailable ok: ${res}`);
|
|
366
|
+
return true;
|
|
367
|
+
})
|
|
368
|
+
.catch(error => {
|
|
369
|
+
core.debug(`docker.Install.colimaAvailable error: ${error}`);
|
|
370
|
+
return false;
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
static getRelease(version) {
|
|
375
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
376
|
+
const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json`;
|
|
377
|
+
const http = new httpm.HttpClient('docker-actions-toolkit');
|
|
378
|
+
const resp = yield http.get(url);
|
|
379
|
+
const body = yield resp.readBody();
|
|
380
|
+
const statusCode = resp.message.statusCode || 500;
|
|
381
|
+
if (statusCode >= 400) {
|
|
382
|
+
throw new Error(`Failed to get Docker release ${version} from ${url} with status code ${statusCode}: ${body}`);
|
|
383
|
+
}
|
|
384
|
+
const releases = JSON.parse(body);
|
|
385
|
+
if (!releases[version]) {
|
|
386
|
+
throw new Error(`Cannot find Docker release ${version} in ${url}`);
|
|
387
|
+
}
|
|
388
|
+
return releases[version];
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
exports.Install = Install;
|
|
393
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/docker/install.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6DAA+C;AAC/C,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,8DAAgC;AAChC,uDAAyC;AACzC,2CAA6B;AAC7B,oDAAsC;AACtC,4DAA8C;AAC9C,gDAAkC;AAClC,wDAA0C;AAE1C,wCAAmC;AACnC,kCAA6B;AAC7B,kCAA6B;AAC7B,qCAAqG;AAUrG,MAAa,OAAO;IAQlB,YAAY,IAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,qBAAqB,CAAC;IAC/D,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,IAAI,iBAAO,CAAC,MAAM,EAAE,CAAC;IAC3C,CAAC;IAEY,QAAQ;;YACnB,MAAM,OAAO,GAAkB,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACzD,IAAI,CAAC,KAAK,CAAC,oCAAoC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEhE,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAClE,IAA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AC,CAAC;aAChH;YACD,MAAM,QAAQ,GAAkC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,OAAO,GAAG,EAAE,CAAC,CAAC;aACpE;YACD,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;KAAA;CACF;AAxVD,0BAwVC"}
|
package/lib/exec.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 actions-toolkit authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ExecOptions, ExecOutput } from '@actions/exec';
|
|
17
|
+
export declare class Exec {
|
|
18
|
+
static exec(commandLine: string, args?: string[], options?: ExecOptions): Promise<number>;
|
|
19
|
+
static getExecOutput(commandLine: string, args?: string[], options?: ExecOptions): Promise<ExecOutput>;
|
|
20
|
+
}
|
package/lib/exec.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023 actions-toolkit authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.Exec = void 0;
|
|
51
|
+
const core = __importStar(require("@actions/core"));
|
|
52
|
+
const exec = __importStar(require("@actions/exec"));
|
|
53
|
+
class Exec {
|
|
54
|
+
static exec(commandLine, args, options) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
core.debug(`Exec.exec: ${commandLine} ${args === null || args === void 0 ? void 0 : args.join(' ')}`);
|
|
57
|
+
return exec.exec(commandLine, args, options);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
static getExecOutput(commandLine, args, options) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
core.debug(`Exec.getExecOutput: ${commandLine} ${args === null || args === void 0 ? void 0 : args.join(' ')}`);
|
|
63
|
+
return exec.getExecOutput(commandLine, args, options);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Exec = Exec;
|
|
68
|
+
//# sourceMappingURL=exec.js.map
|
package/lib/exec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,oDAAsC;AAGtC,MAAa,IAAI;IACR,MAAM,CAAO,IAAI,CAAC,WAAmB,EAAE,IAAe,EAAE,OAAqB;;YAClF,IAAI,CAAC,KAAK,CAAC,cAAc,WAAW,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;KAAA;IAEM,MAAM,CAAO,aAAa,CAAC,WAAmB,EAAE,IAAe,EAAE,OAAqB;;YAC3F,IAAI,CAAC,KAAK,CAAC,uBAAuB,WAAW,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpE,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;KAAA;CACF;AAVD,oBAUC"}
|
package/lib/git.d.ts
CHANGED
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { Context as GitContext } from './types/git';
|
|
16
17
|
export declare class Git {
|
|
17
|
-
static
|
|
18
|
+
static context(): Promise<GitContext>;
|
|
19
|
+
static isInsideWorkTree(): Promise<boolean>;
|
|
20
|
+
static remoteSha(repo: string, ref: string): Promise<string>;
|
|
21
|
+
static remoteURL(): Promise<string>;
|
|
22
|
+
static ref(): Promise<string>;
|
|
23
|
+
static fullCommit(): Promise<string>;
|
|
24
|
+
static shortCommit(): Promise<string>;
|
|
25
|
+
static tag(): Promise<string>;
|
|
26
|
+
private static exec;
|
|
18
27
|
}
|
package/lib/git.js
CHANGED
|
@@ -14,29 +14,6 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -48,20 +25,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
48
25
|
};
|
|
49
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
27
|
exports.Git = void 0;
|
|
51
|
-
const
|
|
28
|
+
const exec_1 = require("./exec");
|
|
29
|
+
const context_1 = require("@actions/github/lib/context");
|
|
52
30
|
class Git {
|
|
53
|
-
static
|
|
31
|
+
static context() {
|
|
54
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
33
|
+
const ctx = new context_1.Context();
|
|
34
|
+
ctx.ref = yield Git.ref();
|
|
35
|
+
ctx.sha = yield Git.fullCommit();
|
|
36
|
+
return ctx;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
static isInsideWorkTree() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return yield Git.exec(['rev-parse', '--is-inside-work-tree'])
|
|
42
|
+
.then(out => {
|
|
43
|
+
return out === 'true';
|
|
59
44
|
})
|
|
60
|
-
.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
45
|
+
.catch(() => {
|
|
46
|
+
return false;
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
static remoteSha(repo, ref) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
return yield Git.exec(['ls-remote', repo, ref]).then(out => {
|
|
53
|
+
const [rsha] = out.split(/[\s\t]/);
|
|
65
54
|
if (rsha.length == 0) {
|
|
66
55
|
throw new Error(`Cannot find remote ref for ${repo}#${ref}`);
|
|
67
56
|
}
|
|
@@ -69,6 +58,59 @@ class Git {
|
|
|
69
58
|
});
|
|
70
59
|
});
|
|
71
60
|
}
|
|
61
|
+
static remoteURL() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return yield Git.exec(['remote', 'get-url', 'origin']).then(rurl => {
|
|
64
|
+
if (rurl.length == 0) {
|
|
65
|
+
return Git.exec(['remote', 'get-url', 'upstream']).then(rurl => {
|
|
66
|
+
if (rurl.length == 0) {
|
|
67
|
+
throw new Error(`Cannot find remote URL for origin or upstream`);
|
|
68
|
+
}
|
|
69
|
+
return rurl;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return rurl;
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
static ref() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
return yield Git.exec(['symbolic-ref', 'HEAD']);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
static fullCommit() {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
return yield Git.exec(['show', '--format=%H', 'HEAD', '--quiet', '--']);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
static shortCommit() {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
return yield Git.exec(['show', '--format=%h', 'HEAD', '--quiet', '--']);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
static tag() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
return yield Git.exec(['tag', '--points-at', 'HEAD', '--sort', '-version:creatordate']).then(tags => {
|
|
94
|
+
if (tags.length == 0) {
|
|
95
|
+
return Git.exec(['describe', '--tags', '--abbrev=0']);
|
|
96
|
+
}
|
|
97
|
+
return tags.split('\n')[0];
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
static exec(args = []) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
return yield exec_1.Exec.getExecOutput(`git`, args, {
|
|
104
|
+
ignoreReturnCode: true,
|
|
105
|
+
silent: true
|
|
106
|
+
}).then(res => {
|
|
107
|
+
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
108
|
+
throw new Error(res.stderr);
|
|
109
|
+
}
|
|
110
|
+
return res.stdout.trim();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
72
114
|
}
|
|
73
115
|
exports.Git = Git;
|
|
74
116
|
//# sourceMappingURL=git.js.map
|