mirror of
https://github.com/softprops/action-gh-release.git
synced 2026-10-31 02:42:27 +01:00
Add 'fail_on_unmatched_files' input (#55)
This commit is contained in:
1 parent
9439581056
commit
4fb86a77e0
6 files changed
+54
-17
No files matched your search
@@ -172,15 +172,16 @@ jobs:
|
|||||||
|
|
||||||
The following are optional as `step.with` keys
|
The following are optional as `step.with` keys
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|-------------|---------|-----------------------------------------------------------------|
|
|---------------------------|---------|-----------------------------------------------------------------------|
|
||||||
| `body` | String | Text communicating notable changes in this release |
|
| `body` | String | Text communicating notable changes in this release |
|
||||||
| `body_path` | String | Path to load text communicating notable changes in this release |
|
| `body_path` | String | Path to load text communicating notable changes in this release |
|
||||||
| `draft` | Boolean | Indicator of whether or not this release is a draft |
|
| `draft` | Boolean | Indicator of whether or not this release is a draft |
|
||||||
| `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.ref` |
|
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
|
||||||
|
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing|
|
||||||
|
|
||||||
💡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.
|
||||||
|
|
||||||
|
|||||||
+17
-5
@@ -3,7 +3,8 @@ import {
|
|||||||
isTag,
|
isTag,
|
||||||
paths,
|
paths,
|
||||||
parseConfig,
|
parseConfig,
|
||||||
parseInputFiles
|
parseInputFiles,
|
||||||
|
unmatchedPatterns
|
||||||
} from "../src/util";
|
} from "../src/util";
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
|
||||||
@@ -87,7 +88,8 @@ describe("util", () => {
|
|||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined
|
input_tag_name: undefined,
|
||||||
|
input_fail_on_unmatched_files: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -102,9 +104,19 @@ describe("util", () => {
|
|||||||
|
|
||||||
describe("paths", () => {
|
describe("paths", () => {
|
||||||
it("resolves files given a set of paths", async () => {
|
it("resolves files given a set of paths", async () => {
|
||||||
assert.deepStrictEqual(paths(["tests/data/**/*"]), [
|
assert.deepStrictEqual(
|
||||||
"tests/data/foo/bar.txt"
|
paths(["tests/data/**/*", "tests/data/does/not/exist/*"]),
|
||||||
]);
|
["tests/data/foo/bar.txt"]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("unmatchedPatterns", () => {
|
||||||
|
it("returns the patterns that don't match any files", async () => {
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
unmatchedPatterns(["tests/data/**/*", "tests/data/does/not/exist/*"]),
|
||||||
|
["tests/data/does/not/exist/*"]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -24,6 +24,9 @@ inputs:
|
|||||||
files:
|
files:
|
||||||
description: 'Newline-delimited list of path globs for asset files to upload'
|
description: 'Newline-delimited list of path globs for asset files to upload'
|
||||||
required: false
|
required: false
|
||||||
|
fail_on_unmatched_files:
|
||||||
|
description: 'Fails if any of the `files` globs match nothing. Defaults to false'
|
||||||
|
required: false
|
||||||
env:
|
env:
|
||||||
'GITHUB_TOKEN': 'As provided by Github Actions'
|
'GITHUB_TOKEN': 'As provided by Github Actions'
|
||||||
outputs:
|
outputs:
|
||||||
|
|||||||
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
|
||||||
+10
-1
@@ -1,4 +1,4 @@
|
|||||||
import { paths, parseConfig, isTag } from "./util";
|
import { paths, parseConfig, isTag, unmatchedPatterns } from "./util";
|
||||||
import { release, upload, GitHubReleaser } from "./github";
|
import { release, upload, GitHubReleaser } from "./github";
|
||||||
import { setFailed, setOutput } from "@actions/core";
|
import { setFailed, setOutput } from "@actions/core";
|
||||||
import { GitHub } from "@actions/github";
|
import { GitHub } from "@actions/github";
|
||||||
@@ -10,6 +10,15 @@ async function run() {
|
|||||||
if (!config.input_tag_name && !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`);
|
||||||
}
|
}
|
||||||
|
if (config.input_files) {
|
||||||
|
const patterns = unmatchedPatterns(config.input_files);
|
||||||
|
patterns.forEach(pattern =>
|
||||||
|
console.warn(`🤔 Pattern '${pattern}' does not match any files.`)
|
||||||
|
);
|
||||||
|
if (patterns.length > 0 && config.input_fail_on_unmatched_files) {
|
||||||
|
throw new Error(`⚠️ There were unmatched files`);
|
||||||
|
}
|
||||||
|
}
|
||||||
GitHub.plugin([
|
GitHub.plugin([
|
||||||
require("@octokit/plugin-throttling"),
|
require("@octokit/plugin-throttling"),
|
||||||
require("@octokit/plugin-retry")
|
require("@octokit/plugin-retry")
|
||||||
|
|||||||
+13
-1
@@ -13,6 +13,7 @@ export interface Config {
|
|||||||
input_files?: string[];
|
input_files?: string[];
|
||||||
input_draft?: boolean;
|
input_draft?: boolean;
|
||||||
input_prerelease?: boolean;
|
input_prerelease?: boolean;
|
||||||
|
input_fail_on_unmatched_files?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const releaseBody = (config: Config): string | undefined => {
|
export const releaseBody = (config: Config): string | undefined => {
|
||||||
@@ -47,7 +48,8 @@ export const parseConfig = (env: Env): Config => {
|
|||||||
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 === "true",
|
||||||
input_prerelease: env.INPUT_PRERELEASE == "true"
|
input_prerelease: env.INPUT_PRERELEASE == "true",
|
||||||
|
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true"
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,6 +61,16 @@ export const paths = (patterns: string[]): string[] => {
|
|||||||
}, []);
|
}, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const unmatchedPatterns = (patterns: string[]): string[] => {
|
||||||
|
return patterns.reduce((acc: string[], pattern: string): string[] => {
|
||||||
|
return acc.concat(
|
||||||
|
glob.sync(pattern).filter(path => lstatSync(path).isFile()).length == 0
|
||||||
|
? [pattern]
|
||||||
|
: []
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
};
|
||||||
|
|
||||||
export const isTag = (ref: string): boolean => {
|
export const isTag = (ref: string): boolean => {
|
||||||
return ref.startsWith("refs/tags/");
|
return ref.startsWith("refs/tags/");
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user