Add tag_name option (#39)

Allow setting tag name like actions/create-release.
This commit is contained in:
K.Takata authored and Doug Tangren committed 2020-01-09 01:06:19 -05:00
1 parent b7e450da2a
commit 9f4852ebe6
7 files changed
+18 -7

No files matched your search

+1
View File
@@ -180,6 +180,7 @@ The following are optional as `step.with` keys
| `prerelease`| Boolean | Indicator of whether or not is a prerelease | | `prerelease`| Boolean | Indicator of whether or not is a prerelease |
| `files` | String | Newline-delimited globs of paths to assets to upload for release| | `files` | String | Newline-delimited globs of paths to assets to upload for release|
| `name` | String | Name of the release. defaults to tag name | | `name` | String | Name of the release. defaults to tag name |
| `tag_name` | String | Name of a tag. defaults to github.GITHUB_REF |
💡When providing a `body` and `body_path` at the same time, `body_path` will be attempted first, then falling back on `body` if the path can not be read from. 💡When providing a `body` and `body_path` at the same time, `body_path` will be attempted first, then falling back on `body` if the path can not be read from.
+8 -4
View File
@@ -35,7 +35,8 @@ describe("util", () => {
input_draft: false, input_draft: false,
input_prerelease: false, input_prerelease: false,
input_files: [], input_files: [],
input_name: undefined input_name: undefined,
input_tag_name: undefined
}) })
); );
}); });
@@ -51,7 +52,8 @@ describe("util", () => {
input_draft: false, input_draft: false,
input_prerelease: false, input_prerelease: false,
input_files: [], input_files: [],
input_name: undefined input_name: undefined,
input_tag_name: undefined
}) })
); );
}); });
@@ -67,7 +69,8 @@ describe("util", () => {
input_draft: false, input_draft: false,
input_prerelease: false, input_prerelease: false,
input_files: [], input_files: [],
input_name: undefined input_name: undefined,
input_tag_name: undefined
}) })
); );
}); });
@@ -83,7 +86,8 @@ describe("util", () => {
input_draft: false, input_draft: false,
input_prerelease: false, input_prerelease: false,
input_files: [], input_files: [],
input_name: undefined input_name: undefined,
input_tag_name: undefined
}); });
}); });
}); });
+3
View File
@@ -12,6 +12,9 @@ inputs:
name: name:
description: 'Gives the release a custom name. Defaults to tag name' description: 'Gives the release a custom name. Defaults to tag name'
required: false required: false
tag_name:
description: 'Gives a tag name. Defaults to github.GITHUB_REF'
required: false
draft: draft:
description: 'Creates a draft release. Defaults to false' description: 'Creates a draft release. Defaults to false'
required: false required: false
+1 -1
View File
@@ -1 +1 @@
module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var i=r[t]={i:t,l:false,exports:{}};e[t].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}({0:function(e,t,r){const i=r(529);const n=[r(372),r(19),r(190),r(148),r(248),r(586),r(430),r(850)];e.exports=i.plugin(n)},2:function(e,t,r){"use strict";const i=r(87);const n=r(118);const s=r(494);const o=(e,t)=>{if(!e&&t){throw new Error("You can't specify a `release` without specifying `platform`")}e=e||i.platform();let r;if(e==="darwin"){if(!t&&i.platform()==="darwin"){t=i.release()}const e=t?Number(t.split(".")[0])>15?"macOS":"OS X":"macOS";r=t?n(t).name:"";return e+(r?" "+r:"")}if(e==="linux"){if(!t&&i.platform()==="linux"){t=i.release()}r=t?t.replace(/^(\d+\.\d+).*/,"$1"):"";return"Linux"+(r?" "+r:"")}if(e==="win32"){if(!t&&i.platform()==="win32"){t=i.release()}r=t?s(t):"";return"Windows"+(r?" "+r:"")}return e};e.exports=o},8:function(e,t,r){e.exports=iterator;const i=r(301);function iterator(e,t){const r=t.headers;let n=e.request.endpoint(t).url;return{[Symbol.asyncIterator]:()=>({next(){if(!n){return Promise.resolve({done:true})}return e.request({url:n,headers:r}).then(t=>{i(e,n,t);n=((t.headers.link||"").match(/<([^>]+)>;\s*rel="next"/)||[])[1];return{value:t}})}})}}},9:function(e,t,r){var i=r(49);var n=function(){};var s=function(e){return e.setHeader&&typeof e.abort==="function"};var o=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3};var a=function(e,t,r){if(typeof t==="function")return a(e,null,t);if(!t)t={};r=i(r||n);var p=e._writableState;var u=e._readableState;var c=t.readable||t.readable!==false&&e.readable;var l=t.writable||t.writable!==false&&e.writable;var d=function(){if(!e.writable)h()};var h=function(){l=false;if(!c)r.call(e)};var m=function(){c=false;if(!l)r.call(e)};var g=function(t){r.call(e,t?new Error("exited with error code: "+t):null)};var f=function(t){r.call(e,t)};var y=function(){if(c&&!(u&&u.ended))return r.call(e,new Error("premature close"));if(l&&!(p&&p.ended))return r.call(e,new Error("premature close"))};var v=function(){e.req.on("finish",h)};if(s(e)){e.on("complete",h);e.on("abort",y);if(e.req)v();else e.on("request",v)}else if(l&&!p){e.on("end",d);e.on("close",d)}if(o(e))e.on("exit",g);e.on("end",m);e.on("finish",h);if(t.error!==false)e.on("error",f);e.on("close",y);return function(){e.removeListener("complete",h);e.removeListener("abort",y);e.removeListener("request",v);if(e.req)e.req.removeListener("finish",h);e.removeListener("end",d);e.removeListener("close",d);e.removeListener("finish",h);e.removeListener("exit",g);e.removeListener("end",m);e.removeListener("error",f);e.removeListener("close",y)}};e.exports=a},11:function(e){e.exports=wrappy;function wrappy(e,t){if(e&&t)return wrappy(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach(function(t){wrapper[t]=e[t]});return wrapper;function wrapper(){var t=new Array(arguments.length);for(var r=0;r<t.length;r++){t[r]=arguments[r]}var i=e.apply(this,t);var n=t[t.length-1];if(typeof i==="function"&&i!==n){Object.keys(n).forEach(function(e){i[e]=n[e]})}return i}}},18:function(){eval("require")("encoding")},19:function(e,t,r){e.exports=authenticationPlugin;const{Deprecation:i}=r(692);const n=r(49);const s=n((e,t)=>e.warn(t));const o=r(533);const a=r(471);const p=r(349);function authenticationPlugin(e,t){if(t.auth){e.authenticate=(()=>{s(e.log,new i('[@octokit/rest] octokit.authenticate() is deprecated and has no effect when "auth" option is set on Octokit constructor'))});return}const r={octokit:e,auth:false};e.authenticate=o.bind(null,r);e.hook.before("request",a.bind(null,r));e.hook.error("request",p.bind(null,r))}},20:function(e,t,r){"use strict";const i=r(129);const n=r(568);const s=r(881);function spawn(e,t,r){const o=n(e,t,r);const a=i.spawn(o.command,o.args,o.options);s.hookChildProcess(a,o);return a}function spawnSync(e,t,r){const o=n(e,t,r);const a=i.spawnSync(o.command,o.args,o.options);a.error=a.error||s.verifyENOENTSync(a.status,o);return a}e.exports=spawn;e.exports.spawn=spawn;e.exports.sync=spawnSync;e.exports._parse=n;e.exports._enoent=s},39:function(e){"use strict";e.exports=(e=>{e=e||{};const t=e.env||process.env;const r=e.platform||process.platform;if(r!=="win32"){return"PATH"}return Object.keys(t).find(e=>e.toUpperCase()==="PATH")||"Path"})},47:function(e,t,r){e.exports=factory;const i=r(797);const n=r(855);function factory(e){const t=i.bind(null,e||[]);t.plugin=n.bind(null,e||[]);return t}},49:function(e,t,r){var i=r(11);e.exports=i(once);e.exports.strict=i(onceStrict);once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:true});Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurablLine truncated module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var i=r[t]={i:t,l:false,exports:{}};e[t].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}({0:function(e,t,r){const i=r(529);const n=[r(372),r(19),r(190),r(148),r(248),r(586),r(430),r(850)];e.exports=i.plugin(n)},2:function(e,t,r){"use strict";const i=r(87);const n=r(118);const s=r(494);const o=(e,t)=>{if(!e&&t){throw new Error("You can't specify a `release` without specifying `platform`")}e=e||i.platform();let r;if(e==="darwin"){if(!t&&i.platform()==="darwin"){t=i.release()}const e=t?Number(t.split(".")[0])>15?"macOS":"OS X":"macOS";r=t?n(t).name:"";return e+(r?" "+r:"")}if(e==="linux"){if(!t&&i.platform()==="linux"){t=i.release()}r=t?t.replace(/^(\d+\.\d+).*/,"$1"):"";return"Linux"+(r?" "+r:"")}if(e==="win32"){if(!t&&i.platform()==="win32"){t=i.release()}r=t?s(t):"";return"Windows"+(r?" "+r:"")}return e};e.exports=o},8:function(e,t,r){e.exports=iterator;const i=r(301);function iterator(e,t){const r=t.headers;let n=e.request.endpoint(t).url;return{[Symbol.asyncIterator]:()=>({next(){if(!n){return Promise.resolve({done:true})}return e.request({url:n,headers:r}).then(t=>{i(e,n,t);n=((t.headers.link||"").match(/<([^>]+)>;\s*rel="next"/)||[])[1];return{value:t}})}})}}},9:function(e,t,r){var i=r(49);var n=function(){};var s=function(e){return e.setHeader&&typeof e.abort==="function"};var o=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3};var a=function(e,t,r){if(typeof t==="function")return a(e,null,t);if(!t)t={};r=i(r||n);var p=e._writableState;var u=e._readableState;var c=t.readable||t.readable!==false&&e.readable;var l=t.writable||t.writable!==false&&e.writable;var d=function(){if(!e.writable)h()};var h=function(){l=false;if(!c)r.call(e)};var m=function(){c=false;if(!l)r.call(e)};var g=function(t){r.call(e,t?new Error("exited with error code: "+t):null)};var f=function(t){r.call(e,t)};var y=function(){if(c&&!(u&&u.ended))return r.call(e,new Error("premature close"));if(l&&!(p&&p.ended))return r.call(e,new Error("premature close"))};var v=function(){e.req.on("finish",h)};if(s(e)){e.on("complete",h);e.on("abort",y);if(e.req)v();else e.on("request",v)}else if(l&&!p){e.on("end",d);e.on("close",d)}if(o(e))e.on("exit",g);e.on("end",m);e.on("finish",h);if(t.error!==false)e.on("error",f);e.on("close",y);return function(){e.removeListener("complete",h);e.removeListener("abort",y);e.removeListener("request",v);if(e.req)e.req.removeListener("finish",h);e.removeListener("end",d);e.removeListener("close",d);e.removeListener("finish",h);e.removeListener("exit",g);e.removeListener("end",m);e.removeListener("error",f);e.removeListener("close",y)}};e.exports=a},11:function(e){e.exports=wrappy;function wrappy(e,t){if(e&&t)return wrappy(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach(function(t){wrapper[t]=e[t]});return wrapper;function wrapper(){var t=new Array(arguments.length);for(var r=0;r<t.length;r++){t[r]=arguments[r]}var i=e.apply(this,t);var n=t[t.length-1];if(typeof i==="function"&&i!==n){Object.keys(n).forEach(function(e){i[e]=n[e]})}return i}}},18:function(){eval("require")("encoding")},19:function(e,t,r){e.exports=authenticationPlugin;const{Deprecation:i}=r(692);const n=r(49);const s=n((e,t)=>e.warn(t));const o=r(533);const a=r(471);const p=r(349);function authenticationPlugin(e,t){if(t.auth){e.authenticate=(()=>{s(e.log,new i('[@octokit/rest] octokit.authenticate() is deprecated and has no effect when "auth" option is set on Octokit constructor'))});return}const r={octokit:e,auth:false};e.authenticate=o.bind(null,r);e.hook.before("request",a.bind(null,r));e.hook.error("request",p.bind(null,r))}},20:function(e,t,r){"use strict";const i=r(129);const n=r(568);const s=r(881);function spawn(e,t,r){const o=n(e,t,r);const a=i.spawn(o.command,o.args,o.options);s.hookChildProcess(a,o);return a}function spawnSync(e,t,r){const o=n(e,t,r);const a=i.spawnSync(o.command,o.args,o.options);a.error=a.error||s.verifyENOENTSync(a.status,o);return a}e.exports=spawn;e.exports.spawn=spawn;e.exports.sync=spawnSync;e.exports._parse=n;e.exports._enoent=s},39:function(e){"use strict";e.exports=(e=>{e=e||{};const t=e.env||process.env;const r=e.platform||process.platform;if(r!=="win32"){return"PATH"}return Object.keys(t).find(e=>e.toUpperCase()==="PATH")||"Path"})},47:function(e,t,r){e.exports=factory;const i=r(797);const n=r(855);function factory(e){const t=i.bind(null,e||[]);t.plugin=n.bind(null,e||[]);return t}},49:function(e,t,r){var i=r(11);e.exports=i(once);e.exports.strict=i(onceStrict);once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:true});Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurablLine truncated
+2 -1
View File
@@ -142,7 +142,8 @@ export const release = async (
releaser: Releaser releaser: Releaser
): Promise<Release> => { ): Promise<Release> => {
const [owner, repo] = config.github_repository.split("/"); const [owner, repo] = config.github_repository.split("/");
const tag = config.github_ref.replace("refs/tags/", ""); const tag =
config.input_tag_name || config.github_ref.replace("refs/tags/", "");
try { try {
// you can't get a an existing draft by tag // you can't get a an existing draft by tag
// so we must find one in the list of all releases // so we must find one in the list of all releases
+1 -1
View File
@@ -7,7 +7,7 @@ import { env } from "process";
async function run() { async function run() {
try { try {
const config = parseConfig(env); const config = parseConfig(env);
if (!isTag(config.github_ref)) { if (!config.input_tag_name && !isTag(config.github_ref)) {
throw new Error(`⚠️ GitHub Releases requires a tag`); throw new Error(`⚠️ GitHub Releases requires a tag`);
} }
GitHub.plugin(require("@octokit/plugin-throttling")); GitHub.plugin(require("@octokit/plugin-throttling"));
+2
View File
@@ -7,6 +7,7 @@ export interface Config {
github_repository: string; github_repository: string;
// user provided // user provided
input_name?: string; input_name?: string;
input_tag_name?: string;
input_body?: string; input_body?: string;
input_body_path?: string; input_body_path?: string;
input_files?: string[]; input_files?: string[];
@@ -41,6 +42,7 @@ export const parseConfig = (env: Env): Config => {
github_ref: env.GITHUB_REF || "", github_ref: env.GITHUB_REF || "",
github_repository: env.GITHUB_REPOSITORY || "", github_repository: env.GITHUB_REPOSITORY || "",
input_name: env.INPUT_NAME, input_name: env.INPUT_NAME,
input_tag_name: env.INPUT_TAG_NAME,
input_body: env.INPUT_BODY, input_body: env.INPUT_BODY,
input_body_path: env.INPUT_BODY_PATH, input_body_path: env.INPUT_BODY_PATH,
input_files: parseInputFiles(env.INPUT_FILES || ""), input_files: parseInputFiles(env.INPUT_FILES || ""),