2019-09-09 18:42:19 +09:00
|
|
|
|
2019-09-09 17:10:07 +09:00
|
|
|
import { paths, parseConfig, isTag } from './util';
|
|
|
|
import { release, upload } from './github';
|
2019-09-09 18:42:19 +09:00
|
|
|
import { setFailed } from '@actions/core';
|
|
|
|
import { GitHub } from '@actions/github';
|
2019-09-09 20:16:58 +09:00
|
|
|
import { env } from 'process';
|
2019-09-09 17:10:07 +09:00
|
|
|
|
|
|
|
async function run() {
|
|
|
|
try {
|
2019-09-09 20:16:58 +09:00
|
|
|
const config = parseConfig(env);
|
2019-09-09 17:10:07 +09:00
|
|
|
if (!isTag(config.github_ref)) {
|
|
|
|
throw new Error(`⚠️ GitHub Releases requires a tag`);
|
|
|
|
}
|
|
|
|
const gh = new GitHub(config.github_token);
|
|
|
|
let rel = await release(config, gh);
|
|
|
|
if (config.input_files) {
|
|
|
|
paths(config.input_files).forEach(async (path) => {
|
|
|
|
await upload(gh, rel.upload_url, path)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
console.log(`🎉 Release ready at ${rel.html_url}`)
|
|
|
|
} catch (error) {
|
2019-09-09 20:36:51 +09:00
|
|
|
console.log(`Error: ${error}`);
|
2019-09-09 18:14:17 +09:00
|
|
|
setFailed(error.message);
|
2019-09-09 17:10:07 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|