feat: add artifacts and metadata outputs (#327)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2022-02-27 20:01:51 +01:00
committed by GitHub
parent affd781166
commit c127c9be61
9 changed files with 8176 additions and 132 deletions
+31
View File
@@ -1,4 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import yargs from 'yargs';
import * as context from './context';
import * as git from './git';
import * as goreleaser from './goreleaser';
@@ -30,6 +32,18 @@ async function run(): Promise<void> {
const tag = await git.getTag();
const isTagDirty = await git.isTagDirty(tag);
let yamlfile: string | unknown;
const argv = yargs.parse(inputs.args);
if (argv.config) {
yamlfile = argv.config;
} else {
['.goreleaser.yaml', '.goreleaser.yml', 'goreleaser.yaml', 'goreleaser.yml'].forEach(f => {
if (fs.existsSync(f)) {
yamlfile = f;
}
});
}
let snapshot = '';
if (inputs.args.split(' ').indexOf('release') > -1) {
if (isTagDirty) {
@@ -49,6 +63,23 @@ async function run(): Promise<void> {
[key: string]: string;
}
});
if (typeof yamlfile === 'string') {
const artifacts = await goreleaser.getArtifacts(await goreleaser.getDistPath(yamlfile));
if (artifacts) {
await core.group(`Artifacts output`, async () => {
core.info(artifacts);
context.setOutput('artifacts', artifacts);
});
}
const metadata = await goreleaser.getMetadata(await goreleaser.getDistPath(yamlfile));
if (metadata) {
await core.group(`Metadata output`, async () => {
core.info(metadata);
context.setOutput('metadata', metadata);
});
}
}
} catch (error) {
core.setFailed(error.message);
}