forked from mirrors/action-gh-release
This will allow subsequent actions to get access to the HTML URL for the release created with this. Handy for composing multiple actions together that are related to the release. In my case I wanted to get the URL into a slack message posted to the team when a release is published. The output can be referenced by using the `steps.release.ouput.url` in the workflow yaml: - name: Release id: release uses: softprops/action-gh-release@v1 with: name: "My Release" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Slack uses: csexton/slack-message-action@v1 with: message: New release posted at ${{ steps.release.outputs.url}}
27 lines
832 B
TypeScript
27 lines
832 B
TypeScript
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();
|