Compare commits

...

20 Commits

Author SHA1 Message Date
Tõnis Tiigi
6524bf65af
Merge pull request #390 from crazy-max/buildx-cloud-latest
make cloud prefix optional to download buildx if driver is cloud
2024-12-12 10:30:19 -08:00
CrazyMax
8d5e0747fc
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-12-12 15:39:12 +01:00
CrazyMax
7199e57b35
make cloud prefix optional to download buildx if driver is cloud
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-12-12 15:39:12 +01:00
CrazyMax
db63cee3de
Merge pull request #381 from docker/dependabot/github_actions/codecov/codecov-action-5
build(deps): bump codecov/codecov-action from 4 to 5
2024-12-12 15:07:22 +01:00
CrazyMax
043ebe137f
Merge pull request #389 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.48.0
build(deps): bump @docker/actions-toolkit from 0.39.0 to 0.48.0
2024-12-12 15:07:04 +01:00
CrazyMax
686da9073d
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-12-12 15:04:35 +01:00
CrazyMax
a3d74876b8
Merge pull request #382 from docker/dependabot/npm_and_yarn/cross-spawn-7.0.6
build(deps): bump cross-spawn from 7.0.3 to 7.0.6
2024-12-12 15:03:07 +01:00
dependabot[bot]
4dcdbcec48
build(deps): bump @docker/actions-toolkit from 0.39.0 to 0.48.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.39.0 to 0.48.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.39.0...v0.48.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-12 14:03:00 +00:00
CrazyMax
1a8ac74316
ci: fix deprecated input for codecov-action
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-12-12 15:02:42 +01:00
dependabot[bot]
e827ebe8ba
build(deps): bump cross-spawn from 7.0.3 to 7.0.6
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 23:00:07 +00:00
dependabot[bot]
adacc1474e
build(deps): bump codecov/codecov-action from 4 to 5
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-15 04:48:17 +00:00
CrazyMax
0f069ddc17
Merge pull request #372 from crazy-max/publish-immutable-action
ci: publish as immutable action workflow
2024-10-26 00:40:56 +02:00
CrazyMax
d036b3238c
ci: publish as immutable action workflow
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-10-25 13:22:55 +02:00
CrazyMax
460e45646d
Merge pull request #370 from docker/dependabot/npm_and_yarn/actions/core-1.11.1
build(deps): bump @actions/core from 1.10.1 to 1.11.1
2024-10-07 14:19:44 +02:00
CrazyMax
93aa1c807f
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-10-07 14:17:38 +02:00
CrazyMax
d391aad55c
remove uuid package and switch to crypto
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-10-07 14:16:41 +02:00
dependabot[bot]
e5b688ea46
build(deps): bump @actions/core from 1.10.1 to 1.11.1
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.10.1 to 1.11.1.
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-07 04:49:55 +00:00
CrazyMax
c47758b77c
Merge pull request #369 from crazy-max/revert-crypto
switch back to uuid package
2024-10-04 09:42:48 +02:00
CrazyMax
8fea382513
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-10-04 09:35:26 +02:00
CrazyMax
2874e980e8
switch back to uuid package
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-10-04 09:34:00 +02:00
10 changed files with 250 additions and 62 deletions

View File

@ -25,8 +25,9 @@ jobs:
- ""
- "latest"
- "v0.4.1"
- "cloud:latest"
- "cloud:v0.11.2-desktop.2"
- "lab:latest"
- "lab:v0.11.2-desktop.2"
steps:
-
name: Checkout

21
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: publish
on:
release:
types:
- published
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Publish
uses: actions/publish-immutable-action@v0.0.4

View File

@ -28,7 +28,7 @@ jobs:
targets: test
-
name: Upload coverage
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage/clover.xml
files: ./coverage/clover.xml
token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -25,7 +25,12 @@ jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
return tmpName;
});
jest.spyOn(crypto, 'randomUUID').mockReturnValue('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
jest.mock('crypto', () => {
return {
...(jest.requireActual('crypto') as object),
randomUUID: jest.fn(() => '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d')
};
});
jest.spyOn(Docker, 'context').mockImplementation((): Promise<string> => {
return Promise.resolve('default');
@ -318,6 +323,140 @@ describe('getAppendArgs', () => {
);
});
describe('getVersion', () => {
beforeEach(() => {
process.env = Object.keys(process.env).reduce((object, key) => {
if (!key.startsWith('INPUT_')) {
object[key] = process.env[key];
}
return object;
}, {});
});
// prettier-ignore
test.each([
[
0,
new Map<string, string>([
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true'],
]),
''
],
[
1,
new Map<string, string>([
['version', 'latest'],
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true']
]),
'latest'
],
[
2,
new Map<string, string>([
['version', 'edge'],
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true']
]),
'edge'
],
[
3,
new Map<string, string>([
['version', 'v0.19.2'],
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true']
]),
'v0.19.2'
],
[
4,
new Map<string, string>([
['version', 'latest'],
['driver', 'cloud'],
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true']
]),
'cloud:latest'
],
[
5,
new Map<string, string>([
['version', 'edge'],
['driver', 'cloud'],
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true']
]),
'cloud:edge'
],
[
6,
new Map<string, string>([
['driver', 'cloud'],
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true'],
]),
'cloud:latest'
],
[
7,
new Map<string, string>([
['version', 'cloud:v0.11.2-desktop.2'],
['driver', 'cloud'],
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true'],
]),
'cloud:v0.11.2-desktop.2'
],
[
8,
new Map<string, string>([
['version', 'cloud:v0.11.2-desktop.2'],
// defaults
['install', 'false'],
['use', 'true'],
['cache-binary', 'true'],
['cleanup', 'true'],
]),
'cloud:v0.11.2-desktop.2'
],
])(
'[%d] given %p as inputs, returns version %p',
async (num: number, inputs: Map<string, string>, expected: string) => {
inputs.forEach((value: string, name: string) => {
setInput(name, value);
});
const inp = await context.getInputs();
expect(context.getVersion(inp)).toEqual(expected);
}
);
});
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
function getInputName(name: string): string {
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;

28
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -25,13 +25,14 @@
"license": "Apache-2.0",
"packageManager": "yarn@3.6.3",
"dependencies": {
"@actions/core": "^1.10.1",
"@docker/actions-toolkit": "^0.39.0",
"@actions/core": "^1.11.1",
"@docker/actions-toolkit": "^0.48.0",
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.12.12",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"@vercel/ncc": "^0.38.1",

View File

@ -1,3 +1,4 @@
import * as crypto from 'crypto';
import * as core from '@actions/core';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
@ -115,3 +116,17 @@ export async function getInspectArgs(inputs: Inputs, toolkit: Toolkit): Promise<
function driverSupportsBuildkitdFlags(driver: string): boolean {
return driver == '' || driver == 'docker-container' || driver == 'docker' || driver == 'kubernetes';
}
export function getVersion(inputs: Inputs): string {
const version = inputs.version;
if (inputs.driver === 'cloud') {
if (!version || version === 'latest') {
return 'cloud:latest';
}
if (version.startsWith('cloud:') || version.startsWith('lab:')) {
return version;
}
return `cloud:${version}`;
}
return version;
}

View File

@ -1,3 +1,4 @@
import * as crypto from 'crypto';
import * as fs from 'fs';
import * as yaml from 'js-yaml';
import * as core from '@actions/core';
@ -21,6 +22,7 @@ actionsToolkit.run(
async () => {
const inputs: context.Inputs = await context.getInputs();
stateHelper.setCleanup(inputs.cleanup);
const version = context.getVersion(inputs);
const toolkit = new Toolkit();
const standalone = await toolkit.buildx.isStandalone();
@ -36,16 +38,16 @@ actionsToolkit.run(
});
let toolPath;
if (Util.isValidRef(inputs.version)) {
if (Util.isValidRef(version)) {
if (standalone) {
throw new Error(`Cannot build from source without the Docker CLI`);
}
await core.group(`Build buildx from source`, async () => {
toolPath = await toolkit.buildxInstall.build(inputs.version, !inputs.cacheBinary);
toolPath = await toolkit.buildxInstall.build(version, !inputs.cacheBinary);
});
} else if (!(await toolkit.buildx.isAvailable()) || inputs.version) {
} else if (!(await toolkit.buildx.isAvailable()) || version) {
await core.group(`Download buildx from GitHub Releases`, async () => {
toolPath = await toolkit.buildxInstall.download(inputs.version || 'latest', !inputs.cacheBinary);
toolPath = await toolkit.buildxInstall.download(version || 'latest', !inputs.cacheBinary);
});
}
if (toolPath) {

View File

@ -12,9 +12,9 @@ __metadata:
languageName: node
linkType: hard
"@actions/artifact@npm:^2.1.9":
version: 2.1.10
resolution: "@actions/artifact@npm:2.1.10"
"@actions/artifact@npm:^2.1.11":
version: 2.1.11
resolution: "@actions/artifact@npm:2.1.11"
dependencies:
"@actions/core": ^1.10.0
"@actions/github": ^5.1.1
@ -26,19 +26,18 @@ __metadata:
"@octokit/request-error": ^5.0.0
"@protobuf-ts/plugin": ^2.2.3-alpha.1
archiver: ^7.0.1
crypto: ^1.0.1
jwt-decode: ^3.1.2
twirp-ts: ^2.5.0
unzip-stream: ^0.3.1
checksum: dfe4cb49da913e7706b884ff2dac629671f298febb1e54b2800659e4e78651c47032548ee5e18f164e31894b4aca4320201a97a7cd4240d0fbf7d203a6955b29
checksum: dbdafaad11cc573768a00f6b8a7f5109f587eb9461564ae8f15ea8fd1d6a719041df45a92ec204a43a8a1e7ce2c21d8e4229543579b89a3ca8ea30dedddf2fc9
languageName: node
linkType: hard
"@actions/cache@npm:^3.2.4":
version: 3.2.4
resolution: "@actions/cache@npm:3.2.4"
"@actions/cache@npm:^3.3.0":
version: 3.3.0
resolution: "@actions/cache@npm:3.3.0"
dependencies:
"@actions/core": ^1.10.0
"@actions/core": ^1.11.1
"@actions/exec": ^1.0.1
"@actions/glob": ^0.1.0
"@actions/http-client": ^2.1.1
@ -47,12 +46,11 @@ __metadata:
"@azure/ms-rest-js": ^2.6.0
"@azure/storage-blob": ^12.13.0
semver: ^6.3.1
uuid: ^3.3.3
checksum: 5bf5f7541bea4906b553440a9ffee5699e11dfb729365c6cb0bbd37e147a1a0993369fdad16bfa3e2b01ec7fa57dac66276278bfd4a389009246a75ea953e61d
checksum: f0761b1491b7706a80b44d68ed52eb48c04653fc939525a7c7b606e9d9251c40c7e4ac20846ab92ac32db6869e1a6f0f574bd6b7fec1ab9378c8e199c5acc9c9
languageName: node
linkType: hard
"@actions/core@npm:^1.10.0, @actions/core@npm:^1.10.1, @actions/core@npm:^1.2.6":
"@actions/core@npm:^1.10.0, @actions/core@npm:^1.2.6":
version: 1.10.1
resolution: "@actions/core@npm:1.10.1"
dependencies:
@ -62,6 +60,16 @@ __metadata:
languageName: node
linkType: hard
"@actions/core@npm:^1.11.1":
version: 1.11.1
resolution: "@actions/core@npm:1.11.1"
dependencies:
"@actions/exec": ^1.1.1
"@actions/http-client": ^2.0.1
checksum: 9ac7a3e0b478bfefd862dcb4ddaa1d8c3f9076bb1931d3d280918d1749e7783480c6a009c1b009c8bf5093e2d77d9f4e023d70416145bf246f0071736d4ef839
languageName: node
linkType: hard
"@actions/exec@npm:^1.0.0, @actions/exec@npm:^1.0.1, @actions/exec@npm:^1.1.1":
version: 1.1.1
resolution: "@actions/exec@npm:1.1.1"
@ -1081,13 +1089,13 @@ __metadata:
languageName: node
linkType: hard
"@docker/actions-toolkit@npm:^0.39.0":
version: 0.39.0
resolution: "@docker/actions-toolkit@npm:0.39.0"
"@docker/actions-toolkit@npm:^0.48.0":
version: 0.48.0
resolution: "@docker/actions-toolkit@npm:0.48.0"
dependencies:
"@actions/artifact": ^2.1.9
"@actions/cache": ^3.2.4
"@actions/core": ^1.10.1
"@actions/artifact": ^2.1.11
"@actions/cache": ^3.3.0
"@actions/core": ^1.11.1
"@actions/exec": ^1.1.1
"@actions/github": ^6.0.0
"@actions/http-client": ^2.2.3
@ -1097,7 +1105,7 @@ __metadata:
"@octokit/core": ^5.1.0
"@octokit/plugin-rest-endpoint-methods": ^10.4.0
async-retry: ^1.3.3
csv-parse: ^5.5.6
csv-parse: ^5.6.0
gunzip-maybe: ^1.4.2
handlebars: ^4.7.8
he: ^1.2.0
@ -1106,7 +1114,7 @@ __metadata:
semver: ^7.6.3
tar-stream: ^3.1.7
tmp: ^0.2.3
checksum: 9dafe3c3e02f6f78c8da4cfb8bc726ae5eef9b6a2fedfca5d75ee6d6c559745c12aa16587dd595360f76be91803235dc66e0852e595ef7a582506fa0d4402983
checksum: 273eefbb19fd9e098d889cdaa2fbe0ff5a9b0d12d2f941dc4b6914240ee78d2d63db4fa0c39850585e9db1d69d2553ec9d3b935627d0fe1d8ab2ad2f3a84c0a5
languageName: node
linkType: hard
@ -2134,6 +2142,13 @@ __metadata:
languageName: node
linkType: hard
"@types/uuid@npm:^10.0.0":
version: 10.0.0
resolution: "@types/uuid@npm:10.0.0"
checksum: e3958f8b0fe551c86c14431f5940c3470127293280830684154b91dc7eb3514aeb79fe3216968833cf79d4d1c67f580f054b5be2cd562bebf4f728913e73e944
languageName: node
linkType: hard
"@types/yargs-parser@npm:*":
version: 20.2.0
resolution: "@types/yargs-parser@npm:20.2.0"
@ -3048,27 +3063,20 @@ __metadata:
linkType: hard
"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3":
version: 7.0.3
resolution: "cross-spawn@npm:7.0.3"
version: 7.0.6
resolution: "cross-spawn@npm:7.0.6"
dependencies:
path-key: ^3.1.0
shebang-command: ^2.0.0
which: ^2.0.1
checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52
checksum: 8d306efacaf6f3f60e0224c287664093fa9185680b2d195852ba9a863f85d02dcc737094c6e512175f8ee0161f9b87c73c6826034c2422e39de7d6569cf4503b
languageName: node
linkType: hard
"crypto@npm:^1.0.1":
version: 1.0.1
resolution: "crypto@npm:1.0.1"
checksum: 087fe3165bd94c333a49e6ed66a0193911f63eac38a24f379b3001a5fe260a59c413646e53a0f67875ba13902b2686d81dc703cb2c147a4ec727dcdc04e5645e
languageName: node
linkType: hard
"csv-parse@npm:^5.5.6":
version: 5.5.6
resolution: "csv-parse@npm:5.5.6"
checksum: ee06f97f674487dc1d001b360de8ea510a41b9d971abf43bcf9c3be22c83a3634df0d3ebfbe52fd49d145077066be7ff9f25de3fc6b71aefb973099b04147a25
"csv-parse@npm:^5.6.0":
version: 5.6.0
resolution: "csv-parse@npm:5.6.0"
checksum: 173e176bdaf212bab37d0f6d39a06d039d24a1c0ee40b9f1023ebf8b36095934807deeb493c0fb58592b39b0682ccd0be5c9e8d2b137c08807e7031595ea7a51
languageName: node
linkType: hard
@ -3170,10 +3178,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "docker-setup-buildx@workspace:."
dependencies:
"@actions/core": ^1.10.1
"@docker/actions-toolkit": ^0.39.0
"@actions/core": ^1.11.1
"@docker/actions-toolkit": ^0.48.0
"@types/js-yaml": ^4.0.9
"@types/node": ^20.12.12
"@types/uuid": ^10.0.0
"@typescript-eslint/eslint-plugin": ^7.9.0
"@typescript-eslint/parser": ^7.9.0
"@vercel/ncc": ^0.38.1
@ -6671,7 +6680,7 @@ __metadata:
languageName: node
linkType: hard
"uuid@npm:^3.3.2, uuid@npm:^3.3.3":
"uuid@npm:^3.3.2":
version: 3.4.0
resolution: "uuid@npm:3.4.0"
bin: