forked from softprops/action-gh-release
/
main.ts
27 lines (25 loc) 路 832 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { paths, parseConfig, isTag } from "./util";
import { release, upload, GitHubReleaser } from "./github";
import { setFailed, setOutput } from "@actions/core";
import { GitHub } from "@actions/github";
import { env } from "process";
async function run() {
try {
const config = parseConfig(env);
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, new GitHubReleaser(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}`);
setOutput('url', rel.html_url);
} catch (error) {
setFailed(error.message);
}
}
run();