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}}
54 lines
2.6 KiB
JavaScript
54 lines
2.6 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const util_1 = require("./util");
|
|
const github_1 = require("./github");
|
|
const core_1 = require("@actions/core");
|
|
const github_2 = require("@actions/github");
|
|
const process_1 = require("process");
|
|
function run() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
const config = util_1.parseConfig(process_1.env);
|
|
if (!util_1.isTag(config.github_ref)) {
|
|
throw new Error(`⚠️ GitHub Releases requires a tag`);
|
|
}
|
|
github_2.GitHub.plugin(require("@octokit/plugin-throttling"));
|
|
const gh = new github_2.GitHub(config.github_token, {
|
|
onRateLimit: (retryAfter, options) => {
|
|
console.warn(`Request quota exhausted for request ${options.method} ${options.url}`);
|
|
if (options.request.retryCount === 0) {
|
|
// only retries once
|
|
console.log(`Retrying after ${retryAfter} seconds!`);
|
|
return true;
|
|
}
|
|
},
|
|
onAbuseLimit: (retryAfter, options) => {
|
|
// does not retry, only logs a warning
|
|
console.warn(`Abuse detected for request ${options.method} ${options.url}`);
|
|
}
|
|
});
|
|
let rel = yield github_1.release(config, new github_1.GitHubReleaser(gh));
|
|
if (config.input_files) {
|
|
util_1.paths(config.input_files).forEach((path) => __awaiter(this, void 0, void 0, function* () {
|
|
yield github_1.upload(gh, rel.upload_url, path);
|
|
}));
|
|
}
|
|
console.log(`🎉 Release ready at ${rel.html_url}`);
|
|
core_1.setOutput('url', rel.html_url);
|
|
}
|
|
catch (error) {
|
|
core_1.setFailed(error.message);
|
|
}
|
|
});
|
|
}
|
|
run();
|