mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-05-10 10:44:19 +00:00
Merge 40ca4763d5
into 975c1b265e
This commit is contained in:
commit
34ae880148
7 changed files with 52 additions and 19 deletions
|
@ -174,6 +174,7 @@ The following are optional as `step.with` keys
|
||||||
| `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 |
|
||||||
|
| `overwrite_files` | Boolean | Indicator of whether files should be overwritten when they already exist. Defaults to true |
|
||||||
| `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 |
|
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing |
|
||||||
|
|
|
@ -47,6 +47,7 @@ describe("util", () => {
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
|
@ -67,6 +68,7 @@ describe("util", () => {
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
|
@ -87,6 +89,7 @@ describe("util", () => {
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
|
@ -119,6 +122,7 @@ describe("util", () => {
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
|
@ -144,6 +148,7 @@ describe("util", () => {
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
|
@ -168,6 +173,7 @@ describe("util", () => {
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
|
@ -193,6 +199,7 @@ describe("util", () => {
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
|
@ -221,6 +228,7 @@ describe("util", () => {
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: true,
|
input_prerelease: true,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
|
@ -247,6 +255,7 @@ describe("util", () => {
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: true,
|
input_prerelease: true,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
|
@ -272,6 +281,7 @@ describe("util", () => {
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: true,
|
input_prerelease: true,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
|
@ -296,6 +306,7 @@ describe("util", () => {
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_overwrite_files: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
|
|
|
@ -24,6 +24,10 @@ 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
|
||||||
|
overwrite_files:
|
||||||
|
description: "Overwrite existing files with the same name. Defaults to false"
|
||||||
|
required: false
|
||||||
|
default: 'true'
|
||||||
fail_on_unmatched_files:
|
fail_on_unmatched_files:
|
||||||
description: "Fails if any of the `files` globs match nothing. Defaults to false"
|
description: "Fails if any of the `files` globs match nothing. Defaults to false"
|
||||||
required: false
|
required: false
|
||||||
|
|
4
dist/index.js
vendored
4
dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -149,6 +149,12 @@ export const upload = async (
|
||||||
({ name: currentName }) => currentName == name
|
({ name: currentName }) => currentName == name
|
||||||
);
|
);
|
||||||
if (currentAsset) {
|
if (currentAsset) {
|
||||||
|
if (config.input_overwrite_files === false) {
|
||||||
|
console.log(
|
||||||
|
`Asset ${name} already exists and overwrite_files is false...`
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
console.log(`♻️ Deleting previously uploaded asset ${name}...`);
|
console.log(`♻️ Deleting previously uploaded asset ${name}...`);
|
||||||
await github.rest.repos.deleteReleaseAsset({
|
await github.rest.repos.deleteReleaseAsset({
|
||||||
asset_id: currentAsset.id || 1,
|
asset_id: currentAsset.id || 1,
|
||||||
|
@ -156,6 +162,7 @@ export const upload = async (
|
||||||
repo,
|
repo,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
console.log(`⬆️ Uploading ${name}...`);
|
console.log(`⬆️ Uploading ${name}...`);
|
||||||
const endpoint = new URL(url);
|
const endpoint = new URL(url);
|
||||||
endpoint.searchParams.append("name", name);
|
endpoint.searchParams.append("name", name);
|
||||||
|
|
|
@ -67,7 +67,8 @@ async function run() {
|
||||||
}
|
}
|
||||||
const currentAssets = rel.assets;
|
const currentAssets = rel.assets;
|
||||||
const assets = await Promise.all(
|
const assets = await Promise.all(
|
||||||
files.map(async (path) => {
|
files
|
||||||
|
.map(async (path) => {
|
||||||
const json = await upload(
|
const json = await upload(
|
||||||
config,
|
config,
|
||||||
gh,
|
gh,
|
||||||
|
@ -75,9 +76,14 @@ async function run() {
|
||||||
path,
|
path,
|
||||||
currentAssets
|
currentAssets
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (json) {
|
||||||
delete json.uploader;
|
delete json.uploader;
|
||||||
|
}
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
})
|
})
|
||||||
|
.filter((json) => json !== null)
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,7 @@ export interface Config {
|
||||||
input_body?: string;
|
input_body?: string;
|
||||||
input_body_path?: string;
|
input_body_path?: string;
|
||||||
input_files?: string[];
|
input_files?: string[];
|
||||||
|
input_overwrite_files?: boolean;
|
||||||
input_draft?: boolean;
|
input_draft?: boolean;
|
||||||
input_prerelease?: boolean;
|
input_prerelease?: boolean;
|
||||||
input_fail_on_unmatched_files?: boolean;
|
input_fail_on_unmatched_files?: boolean;
|
||||||
|
@ -60,6 +61,9 @@ 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_overwrite_files: env.INPUT_OVERWRITE_FILES
|
||||||
|
? env.INPUT_OVERWRITE_FILES == "true"
|
||||||
|
: undefined,
|
||||||
input_draft: env.INPUT_DRAFT ? env.INPUT_DRAFT === "true" : undefined,
|
input_draft: env.INPUT_DRAFT ? env.INPUT_DRAFT === "true" : undefined,
|
||||||
input_prerelease: env.INPUT_PRERELEASE
|
input_prerelease: env.INPUT_PRERELEASE
|
||||||
? env.INPUT_PRERELEASE == "true"
|
? env.INPUT_PRERELEASE == "true"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue