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-26 12:17:18 +00:00
|
|
|
import * as fs from 'fs';
|
2019-09-20 20:23:45 +00:00
|
|
|
|
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');
|
2019-09-26 12:17:18 +00:00
|
|
|
const key = core.getInput('key');
|
2019-09-20 20:23:45 +00:00
|
|
|
const goreleaser = await installer.getGoReleaser(version);
|
|
|
|
|
2019-09-20 21:08:16 +00:00
|
|
|
let snapshot = '';
|
2019-11-11 23:05:29 +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-26 12:17:18 +00:00
|
|
|
if (key) {
|
|
|
|
console.log('🔑 Importing signing key...');
|
|
|
|
let path = `${process.env.HOME}/key.asc`;
|
2019-09-28 18:50:20 +00:00
|
|
|
fs.writeFileSync(path, key, {mode: 0o600});
|
2019-09-26 12:17:18 +00:00
|
|
|
await exec.exec('gpg', ['--import', path], {
|
|
|
|
silent: silent
|
2019-09-28 18:50:20 +00:00
|
|
|
});
|
2019-09-26 12:17:18 +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();
|