forked from mirrors/action-gh-release
refactor for cross platform use
This commit is contained in:
parent
090932e783
commit
18daf2c63f
15 changed files with 5626 additions and 23 deletions
27
src/main.ts
Normal file
27
src/main.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import * as fs from 'fs';
|
||||
import * as core from '@actions/core';
|
||||
import { GitHub } from '@actions/github';
|
||||
import { paths, parseConfig, isTag } from './util';
|
||||
import { release, upload } from './github';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const config = parseConfig(process.env);
|
||||
if (!isTag(config.github_ref)) {
|
||||
throw new Error(`⚠️ GitHub Releases requires a tag`);
|
||||
}
|
||||
// todo: validate github_ref is 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) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
Loading…
Add table
Add a link
Reference in a new issue