mirror of
https://github.com/softprops/action-gh-release
synced 2026-10-03 10:11:31 +00:00
Retain original release info if the keys are not set (#109)
This commit is contained in:
1 parent
04c14f526b
commit
59b9126341
5 files changed
+57
-12
No files matched your search
@@ -175,7 +175,12 @@ The following are optional as `step.with` keys
|
|||||||
| `target_commitish` | String | Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. |
|
| `target_commitish` | String | Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. |
|
||||||
| `token` | String | Secret GitHub Personal Access Token. Defaults to `${{ github.token }}` |
|
| `token` | String | Secret GitHub Personal Access Token. Defaults to `${{ github.token }}` |
|
||||||
|
|
||||||
💡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.
|
||||||
|
|
||||||
|
💡 When the release info keys (such as `name`, `body`, `draft`, `prerelease`, etc.)
|
||||||
|
are not explicitly set and there is already an existing release for the tag, the
|
||||||
|
release will retain its original info.
|
||||||
|
|
||||||
#### outputs
|
#### outputs
|
||||||
|
|
||||||
|
|||||||
+26
-4
@@ -87,8 +87,8 @@ describe("util", () => {
|
|||||||
github_token: "",
|
github_token: "",
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: undefined,
|
||||||
input_prerelease: false,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@@ -109,8 +109,8 @@ describe("util", () => {
|
|||||||
github_token: "",
|
github_token: "",
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: undefined,
|
||||||
input_prerelease: false,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@@ -119,6 +119,28 @@ describe("util", () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it("parses basic config with draft and prerelease", () => {
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
parseConfig({
|
||||||
|
INPUT_DRAFT: "false",
|
||||||
|
INPUT_PRERELEASE: "true"
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
github_ref: "",
|
||||||
|
github_repository: "",
|
||||||
|
github_token: "",
|
||||||
|
input_body: undefined,
|
||||||
|
input_body_path: undefined,
|
||||||
|
input_draft: false,
|
||||||
|
input_prerelease: true,
|
||||||
|
input_files: [],
|
||||||
|
input_name: undefined,
|
||||||
|
input_tag_name: undefined,
|
||||||
|
input_fail_on_unmatched_files: false,
|
||||||
|
input_target_commitish: undefined
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe("isTag", () => {
|
describe("isTag", () => {
|
||||||
it("returns true for tags", async () => {
|
it("returns true for tags", async () => {
|
||||||
|
|||||||
Vendored
+1
-1
@@ -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
|
||||||
+20
-4
@@ -16,8 +16,11 @@ export interface Release {
|
|||||||
upload_url: string;
|
upload_url: string;
|
||||||
html_url: string;
|
html_url: string;
|
||||||
tag_name: string;
|
tag_name: string;
|
||||||
|
name: string;
|
||||||
body: string;
|
body: string;
|
||||||
target_commitish: string;
|
target_commitish: string;
|
||||||
|
draft: boolean;
|
||||||
|
prerelease: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Releaser {
|
export interface Releaser {
|
||||||
@@ -187,11 +190,24 @@ export const release = async (
|
|||||||
} else {
|
} else {
|
||||||
target_commitish = existingRelease.data.target_commitish;
|
target_commitish = existingRelease.data.target_commitish;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tag_name = tag;
|
const tag_name = tag;
|
||||||
const name = config.input_name || tag;
|
const name = config.input_name || existingRelease.data.name || tag;
|
||||||
const body = `${existingRelease.data.body}\n${releaseBody(config)}`;
|
|
||||||
const draft = config.input_draft;
|
let body: string = "";
|
||||||
const prerelease = config.input_prerelease;
|
if (existingRelease.data.body) body += existingRelease.data.body;
|
||||||
|
let workflowBody = releaseBody(config);
|
||||||
|
if (existingRelease.data.body && workflowBody) body += "\n";
|
||||||
|
if (workflowBody) body += workflowBody;
|
||||||
|
|
||||||
|
const draft =
|
||||||
|
config.input_draft !== undefined
|
||||||
|
? config.input_draft
|
||||||
|
: existingRelease.data.draft;
|
||||||
|
const prerelease =
|
||||||
|
config.input_prerelease !== undefined
|
||||||
|
? config.input_prerelease
|
||||||
|
: existingRelease.data.prerelease;
|
||||||
|
|
||||||
const release = await releaser.updateRelease({
|
const release = await releaser.updateRelease({
|
||||||
owner,
|
owner,
|
||||||
|
|||||||
+4
-2
@@ -50,8 +50,10 @@ export const parseConfig = (env: Env): Config => {
|
|||||||
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 || ""),
|
||||||
input_draft: env.INPUT_DRAFT === "true",
|
input_draft: env.INPUT_DRAFT ? env.INPUT_DRAFT === "true" : undefined,
|
||||||
input_prerelease: env.INPUT_PRERELEASE == "true",
|
input_prerelease: env.INPUT_PRERELEASE
|
||||||
|
? env.INPUT_PRERELEASE == "true"
|
||||||
|
: undefined,
|
||||||
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true",
|
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true",
|
||||||
input_target_commitish: env.INPUT_TARGET_COMMITISH
|
input_target_commitish: env.INPUT_TARGET_COMMITISH
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user