goreleaser-action/src/main.ts

34 lines
919 B
TypeScript
Raw Normal View History

2019-09-20 20:23:45 +00:00
import * as installer from './installer';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
2019-09-22 05:17:07 +00:00
export async function run(silent?: boolean) {
2019-09-20 20:23:45 +00:00
try {
const version = core.getInput('version') || 'latest';
const args = core.getInput('args');
const goreleaser = await installer.getGoReleaser(version);
2019-09-20 21:08:16 +00:00
let snapshot = '';
2019-09-22 05:17:07 +00:00
if (
!process.env.GITHUB_REF ||
!process.env.GITHUB_REF.startsWith('refs/tags/')
) {
2019-09-20 21:08:16 +00:00
console.log(`⚠️ No tag found. Snapshot forced`);
2019-09-20 21:11:26 +00:00
if (!args.includes('--snapshot')) {
snapshot = ' --snapshot';
}
2019-09-20 21:08:16 +00:00
} else {
2019-09-20 21:33:44 +00:00
console.log(`${process.env.GITHUB_REF!.split('/')[2]} tag found`);
2019-09-20 21:08:16 +00:00
}
2019-09-20 20:23:45 +00:00
console.log('🏃 Running GoReleaser...');
2019-09-22 05:17:07 +00:00
await exec.exec(`${goreleaser} ${args}${snapshot}`, undefined, {
silent: silent
});
2019-09-20 20:23:45 +00:00
} catch (error) {
core.setFailed(error.message);
}
}
run();