mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-15 14:03:51 +08:00
Handle git sha version of buildx
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
128f05c85a
commit
94827201d1
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"printWidth": 120,
|
"printWidth": 240,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"useTabs": false,
|
"useTabs": false,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
|
@ -128,9 +128,20 @@ describe('parseVersion', () => {
|
|||||||
test.each([
|
test.each([
|
||||||
['github.com/docker/buildx 0.4.1+azure bda4882a65349ca359216b135896bddc1d92461c', '0.4.1'],
|
['github.com/docker/buildx 0.4.1+azure bda4882a65349ca359216b135896bddc1d92461c', '0.4.1'],
|
||||||
['github.com/docker/buildx v0.4.1 bda4882a65349ca359216b135896bddc1d92461c', '0.4.1'],
|
['github.com/docker/buildx v0.4.1 bda4882a65349ca359216b135896bddc1d92461c', '0.4.1'],
|
||||||
['github.com/docker/buildx v0.4.2 fb7b670b764764dc4716df3eba07ffdae4cc47b2', '0.4.2']
|
['github.com/docker/buildx v0.4.2 fb7b670b764764dc4716df3eba07ffdae4cc47b2', '0.4.2'],
|
||||||
|
['github.com/docker/buildx f117971 f11797113e5a9b86bd976329c5dbb8a8bfdfadfa', 'f117971']
|
||||||
])('given %p', async (stdout, expected) => {
|
])('given %p', async (stdout, expected) => {
|
||||||
expect(await buildx.parseVersion(stdout)).toEqual(expected);
|
expect(buildx.parseVersion(stdout)).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('satisfies', () => {
|
||||||
|
test.each([
|
||||||
|
['0.4.1', '>=0.3.2', true],
|
||||||
|
['bda4882a65349ca359216b135896bddc1d92461c', '>0.1.0', false],
|
||||||
|
['f117971', '>0.6.0', true]
|
||||||
|
])('given %p', async (version, range, expected) => {
|
||||||
|
expect(buildx.satisfies(version, range)).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -142,13 +153,7 @@ describe('getSecret', () => {
|
|||||||
['aaaaaaaa', false, '', '', true],
|
['aaaaaaaa', false, '', '', true],
|
||||||
['aaaaaaaa=', false, '', '', true],
|
['aaaaaaaa=', false, '', '', true],
|
||||||
['=bbbbbbb', false, '', '', true],
|
['=bbbbbbb', false, '', '', true],
|
||||||
[
|
[`foo=${path.join(__dirname, 'fixtures', 'secret.txt').split(path.sep).join(path.posix.sep)}`, true, 'foo', 'bar', false],
|
||||||
`foo=${path.join(__dirname, 'fixtures', 'secret.txt').split(path.sep).join(path.posix.sep)}`,
|
|
||||||
true,
|
|
||||||
'foo',
|
|
||||||
'bar',
|
|
||||||
false
|
|
||||||
],
|
|
||||||
[`notfound=secret`, true, '', '', true]
|
[`notfound=secret`, true, '', '', true]
|
||||||
])('given %p key and %p secret', async (kvp, file, exKey, exValue, invalid) => {
|
])('given %p key and %p secret', async (kvp, file, exKey, exValue, invalid) => {
|
||||||
try {
|
try {
|
||||||
|
@ -565,13 +565,7 @@ FOO=bar`
|
|||||||
);
|
);
|
||||||
const res = await context.getInputList('secrets', true);
|
const res = await context.getInputList('secrets', true);
|
||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual([
|
expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']);
|
||||||
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
|
||||||
'MYSECRET=aaaaaaaa',
|
|
||||||
'bbbbbbb',
|
|
||||||
'ccccccccc',
|
|
||||||
'FOO=bar'
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('large multiline values', async () => {
|
it('large multiline values', async () => {
|
||||||
|
3
codecov.yml
Normal file
3
codecov.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
comment: false
|
||||||
|
github_checks:
|
||||||
|
annotations: false
|
16
dist/index.js
generated
vendored
16
dist/index.js
generated
vendored
@ -38,7 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.parseVersion = exports.getVersion = exports.isAvailable = exports.hasGitAuthToken = exports.isLocalOrTarExporter = exports.getSecret = exports.getSecretFile = exports.getSecretString = exports.getImageID = exports.getImageIDFile = void 0;
|
exports.satisfies = exports.parseVersion = exports.getVersion = exports.isAvailable = exports.hasGitAuthToken = exports.isLocalOrTarExporter = exports.getSecret = exports.getSecretFile = exports.getSecretString = exports.getImageID = exports.getImageIDFile = void 0;
|
||||||
const sync_1 = __importDefault(__nccwpck_require__(8750));
|
const sync_1 = __importDefault(__nccwpck_require__(8750));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(5747));
|
const fs_1 = __importDefault(__nccwpck_require__(5747));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(5622));
|
const path_1 = __importDefault(__nccwpck_require__(5622));
|
||||||
@ -158,15 +158,17 @@ function getVersion() {
|
|||||||
}
|
}
|
||||||
exports.getVersion = getVersion;
|
exports.getVersion = getVersion;
|
||||||
function parseVersion(stdout) {
|
function parseVersion(stdout) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
const matches = /\sv?([0-9a-f]{7}|[0-9.]+)/.exec(stdout);
|
||||||
const matches = /\sv?([0-9.]+)/.exec(stdout);
|
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
throw new Error(`Cannot parse buildx version`);
|
throw new Error(`Cannot parse buildx version`);
|
||||||
}
|
}
|
||||||
return semver.clean(matches[1]);
|
return matches[1];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
exports.parseVersion = parseVersion;
|
exports.parseVersion = parseVersion;
|
||||||
|
function satisfies(version, range) {
|
||||||
|
return semver.satisfies(version, range) || /^[0-9a-f]{7}$/.exec(version) !== null;
|
||||||
|
}
|
||||||
|
exports.satisfies = satisfies;
|
||||||
//# sourceMappingURL=buildx.js.map
|
//# sourceMappingURL=buildx.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -213,7 +215,6 @@ const sync_1 = __importDefault(__nccwpck_require__(8750));
|
|||||||
const fs = __importStar(__nccwpck_require__(5747));
|
const fs = __importStar(__nccwpck_require__(5747));
|
||||||
const os = __importStar(__nccwpck_require__(2087));
|
const os = __importStar(__nccwpck_require__(2087));
|
||||||
const path = __importStar(__nccwpck_require__(5622));
|
const path = __importStar(__nccwpck_require__(5622));
|
||||||
const semver = __importStar(__nccwpck_require__(1383));
|
|
||||||
const tmp = __importStar(__nccwpck_require__(8517));
|
const tmp = __importStar(__nccwpck_require__(8517));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const command_1 = __nccwpck_require__(5241);
|
const command_1 = __nccwpck_require__(5241);
|
||||||
@ -307,8 +308,7 @@ function getBuildArgs(inputs, defaultContext, buildxVersion) {
|
|||||||
yield exports.asyncForEach(inputs.outputs, (output) => __awaiter(this, void 0, void 0, function* () {
|
yield exports.asyncForEach(inputs.outputs, (output) => __awaiter(this, void 0, void 0, function* () {
|
||||||
args.push('--output', output);
|
args.push('--output', output);
|
||||||
}));
|
}));
|
||||||
if (!buildx.isLocalOrTarExporter(inputs.outputs) &&
|
if (!buildx.isLocalOrTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || buildx.satisfies(buildxVersion, '>=0.4.2'))) {
|
||||||
(inputs.platforms.length == 0 || semver.satisfies(buildxVersion, '>=0.4.2'))) {
|
|
||||||
args.push('--iidfile', yield buildx.getImageIDFile());
|
args.push('--iidfile', yield buildx.getImageIDFile());
|
||||||
}
|
}
|
||||||
yield exports.asyncForEach(inputs.cacheFrom, (cacheFrom) => __awaiter(this, void 0, void 0, function* () {
|
yield exports.asyncForEach(inputs.cacheFrom, (cacheFrom) => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
@ -107,10 +107,14 @@ export async function getVersion(): Promise<string> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function parseVersion(stdout: string): Promise<string> {
|
export function parseVersion(stdout: string): string {
|
||||||
const matches = /\sv?([0-9.]+)/.exec(stdout);
|
const matches = /\sv?([0-9a-f]{7}|[0-9.]+)/.exec(stdout);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
throw new Error(`Cannot parse buildx version`);
|
throw new Error(`Cannot parse buildx version`);
|
||||||
}
|
}
|
||||||
return semver.clean(matches[1]);
|
return matches[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function satisfies(version: string, range: string): boolean {
|
||||||
|
return semver.satisfies(version, range) || /^[0-9a-f]{7}$/.exec(version) !== null;
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,7 @@ export function defaultContext(): string {
|
|||||||
if (github.context.sha && !ref.startsWith(`refs/pull/`)) {
|
if (github.context.sha && !ref.startsWith(`refs/pull/`)) {
|
||||||
ref = github.context.sha;
|
ref = github.context.sha;
|
||||||
}
|
}
|
||||||
_defaultContext = `${process.env.GITHUB_SERVER_URL || 'https://github.com'}/${github.context.repo.owner}/${
|
_defaultContext = `${process.env.GITHUB_SERVER_URL || 'https://github.com'}/${github.context.repo.owner}/${github.context.repo.repo}.git#${ref}`;
|
||||||
github.context.repo.repo
|
|
||||||
}.git#${ref}`;
|
|
||||||
}
|
}
|
||||||
return _defaultContext;
|
return _defaultContext;
|
||||||
}
|
}
|
||||||
@ -121,10 +119,7 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
|
|||||||
await asyncForEach(inputs.outputs, async output => {
|
await asyncForEach(inputs.outputs, async output => {
|
||||||
args.push('--output', output);
|
args.push('--output', output);
|
||||||
});
|
});
|
||||||
if (
|
if (!buildx.isLocalOrTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || buildx.satisfies(buildxVersion, '>=0.4.2'))) {
|
||||||
!buildx.isLocalOrTarExporter(inputs.outputs) &&
|
|
||||||
(inputs.platforms.length == 0 || semver.satisfies(buildxVersion, '>=0.4.2'))
|
|
||||||
) {
|
|
||||||
args.push('--iidfile', await buildx.getImageIDFile());
|
args.push('--iidfile', await buildx.getImageIDFile());
|
||||||
}
|
}
|
||||||
await asyncForEach(inputs.cacheFrom, async cacheFrom => {
|
await asyncForEach(inputs.cacheFrom, async cacheFrom => {
|
||||||
|
Loading…
Reference in New Issue
Block a user