Add metadata output

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-09-01 22:22:37 +02:00
parent 98b5deaddd
commit a0a15756c1
10 changed files with 7893 additions and 66 deletions

View File

@@ -1,6 +1,22 @@
import fs from 'fs';
import path from 'path';
import * as semver from 'semver';
import * as exec from '@actions/exec';
import * as context from './context';
export async function getMetadataFile(): Promise<string> {
return path.join(context.tmpDir(), 'metadata-file').split(path.sep).join(path.posix.sep);
}
export async function getMetadata(): Promise<string | undefined> {
const metadataFile = await getMetadataFile();
if (!fs.existsSync(metadataFile)) {
return undefined;
}
return fs.readFileSync(metadataFile, {encoding: 'utf-8'});
}
export async function isAvailable(): Promise<Boolean> {
return await exec
.getExecOutput('docker', ['buildx'], {
@@ -36,3 +52,7 @@ export function parseVersion(stdout: string): string {
}
return matches[1];
}
export function satisfies(version: string, range: string): boolean {
return semver.satisfies(version, range) || /^[0-9a-f]{7}$/.exec(version) !== null;
}