mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-05-11 02:44:20 +00:00
Resolve conflicts
This commit is contained in:
parent
5de29c20f3
commit
95c236c0ce
6 changed files with 8643 additions and 1755 deletions
|
@ -5,7 +5,7 @@ import {
|
||||||
parseConfig,
|
parseConfig,
|
||||||
parseInputFiles,
|
parseInputFiles,
|
||||||
unmatchedPatterns,
|
unmatchedPatterns,
|
||||||
uploadUrl
|
uploadUrl,
|
||||||
} from "../src/util";
|
} from "../src/util";
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ describe("util", () => {
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -71,7 +71,7 @@ describe("util", () => {
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -91,7 +91,7 @@ describe("util", () => {
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -107,7 +107,7 @@ describe("util", () => {
|
||||||
// so we cover that in a test case here to ensure undefined values are actually
|
// so we cover that in a test case here to ensure undefined values are actually
|
||||||
// resolved as undefined and not empty strings
|
// resolved as undefined and not empty strings
|
||||||
INPUT_TARGET_COMMITISH: "",
|
INPUT_TARGET_COMMITISH: "",
|
||||||
INPUT_DISCUSSION_CATEGORY_NAME: ""
|
INPUT_DISCUSSION_CATEGORY_NAME: "",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
github_ref: "",
|
github_ref: "",
|
||||||
|
@ -124,7 +124,7 @@ describe("util", () => {
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -132,7 +132,7 @@ describe("util", () => {
|
||||||
it("parses basic config with commitish", () => {
|
it("parses basic config with commitish", () => {
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
parseConfig({
|
parseConfig({
|
||||||
INPUT_TARGET_COMMITISH: "affa18ef97bc9db20076945705aba8c516139abd"
|
INPUT_TARGET_COMMITISH: "affa18ef97bc9db20076945705aba8c516139abd",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
github_ref: "",
|
github_ref: "",
|
||||||
|
@ -149,14 +149,14 @@ describe("util", () => {
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
input_target_commitish: "affa18ef97bc9db20076945705aba8c516139abd",
|
input_target_commitish: "affa18ef97bc9db20076945705aba8c516139abd",
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it("supports discussion category names", () => {
|
it("supports discussion category names", () => {
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
parseConfig({
|
parseConfig({
|
||||||
INPUT_DISCUSSION_CATEGORY_NAME: "releases"
|
INPUT_DISCUSSION_CATEGORY_NAME: "releases",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
github_ref: "",
|
github_ref: "",
|
||||||
|
@ -173,7 +173,7 @@ describe("util", () => {
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: "releases",
|
input_discussion_category_name: "releases",
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -181,7 +181,7 @@ describe("util", () => {
|
||||||
it("supports generating release notes", () => {
|
it("supports generating release notes", () => {
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
parseConfig({
|
parseConfig({
|
||||||
INPUT_GENERATE_RELEASE_NOTES: "true"
|
INPUT_GENERATE_RELEASE_NOTES: "true",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
github_ref: "",
|
github_ref: "",
|
||||||
|
@ -198,7 +198,7 @@ describe("util", () => {
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: true
|
input_generate_release_notes: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -209,7 +209,7 @@ describe("util", () => {
|
||||||
INPUT_DRAFT: "false",
|
INPUT_DRAFT: "false",
|
||||||
INPUT_PRERELEASE: "true",
|
INPUT_PRERELEASE: "true",
|
||||||
GITHUB_TOKEN: "env-token",
|
GITHUB_TOKEN: "env-token",
|
||||||
INPUT_TOKEN: "input-token"
|
INPUT_TOKEN: "input-token",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
github_ref: "",
|
github_ref: "",
|
||||||
|
@ -226,7 +226,7 @@ describe("util", () => {
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -235,7 +235,7 @@ describe("util", () => {
|
||||||
parseConfig({
|
parseConfig({
|
||||||
INPUT_DRAFT: "false",
|
INPUT_DRAFT: "false",
|
||||||
INPUT_PRERELEASE: "true",
|
INPUT_PRERELEASE: "true",
|
||||||
INPUT_TOKEN: "input-token"
|
INPUT_TOKEN: "input-token",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
github_ref: "",
|
github_ref: "",
|
||||||
|
@ -252,7 +252,7 @@ describe("util", () => {
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -260,7 +260,7 @@ describe("util", () => {
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
parseConfig({
|
parseConfig({
|
||||||
INPUT_DRAFT: "false",
|
INPUT_DRAFT: "false",
|
||||||
INPUT_PRERELEASE: "true"
|
INPUT_PRERELEASE: "true",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
github_ref: "",
|
github_ref: "",
|
||||||
|
@ -277,14 +277,14 @@ describe("util", () => {
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it("parses basic config with append_body", () => {
|
it("parses basic config with append_body", () => {
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
parseConfig({
|
parseConfig({
|
||||||
INPUT_APPEND_BODY: "true"
|
INPUT_APPEND_BODY: "true",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
github_ref: "",
|
github_ref: "",
|
||||||
|
@ -301,7 +301,7 @@ describe("util", () => {
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
input_target_commitish: undefined,
|
input_target_commitish: undefined,
|
||||||
input_discussion_category_name: undefined,
|
input_discussion_category_name: undefined,
|
||||||
input_generate_release_notes: false
|
input_generate_release_notes: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
10310
package-lock.json
generated
10310
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -128,7 +128,7 @@ export const asset = (path: string): ReleaseAsset => {
|
||||||
name: basename(path),
|
name: basename(path),
|
||||||
mime: mimeOrDefault(path),
|
mime: mimeOrDefault(path),
|
||||||
size: statSync(path).size,
|
size: statSync(path).size,
|
||||||
data: readFileSync(path)
|
data: readFileSync(path),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ export const upload = async (
|
||||||
await github.rest.repos.deleteReleaseAsset({
|
await github.rest.repos.deleteReleaseAsset({
|
||||||
asset_id: currentAsset.id || 1,
|
asset_id: currentAsset.id || 1,
|
||||||
owner,
|
owner,
|
||||||
repo
|
repo,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(`⬆️ Uploading ${name}...`);
|
console.log(`⬆️ Uploading ${name}...`);
|
||||||
|
@ -163,10 +163,10 @@ export const upload = async (
|
||||||
headers: {
|
headers: {
|
||||||
"content-length": `${size}`,
|
"content-length": `${size}`,
|
||||||
"content-type": mime,
|
"content-type": mime,
|
||||||
authorization: `token ${config.github_token}`
|
authorization: `token ${config.github_token}`,
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body
|
body,
|
||||||
});
|
});
|
||||||
const json = await resp.json();
|
const json = await resp.json();
|
||||||
if (resp.status !== 201) {
|
if (resp.status !== 201) {
|
||||||
|
@ -204,9 +204,9 @@ export const release = async (
|
||||||
if (config.input_draft) {
|
if (config.input_draft) {
|
||||||
for await (const response of releaser.allReleases({
|
for await (const response of releaser.allReleases({
|
||||||
owner,
|
owner,
|
||||||
repo
|
repo,
|
||||||
})) {
|
})) {
|
||||||
let release = response.data.find(release => release.tag_name === tag);
|
let release = response.data.find((release) => release.tag_name === tag);
|
||||||
if (release) {
|
if (release) {
|
||||||
return release;
|
return release;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ export const release = async (
|
||||||
let existingRelease = await releaser.getReleaseByTag({
|
let existingRelease = await releaser.getReleaseByTag({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
tag
|
tag,
|
||||||
});
|
});
|
||||||
|
|
||||||
const release_id = existingRelease.data.id;
|
const release_id = existingRelease.data.id;
|
||||||
|
@ -267,7 +267,7 @@ export const release = async (
|
||||||
draft,
|
draft,
|
||||||
prerelease,
|
prerelease,
|
||||||
discussion_category_name,
|
discussion_category_name,
|
||||||
generate_release_notes
|
generate_release_notes,
|
||||||
});
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -296,7 +296,7 @@ export const release = async (
|
||||||
prerelease,
|
prerelease,
|
||||||
target_commitish,
|
target_commitish,
|
||||||
discussion_category_name,
|
discussion_category_name,
|
||||||
generate_release_notes
|
generate_release_notes,
|
||||||
});
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -304,9 +304,9 @@ export const release = async (
|
||||||
console.log(
|
console.log(
|
||||||
`⚠️ GitHub release failed with status: ${
|
`⚠️ GitHub release failed with status: ${
|
||||||
error.status
|
error.status
|
||||||
}\n${JSON.stringify(
|
}\n${JSON.stringify(error.response.data.errors)}\nretrying... (${
|
||||||
error.response.data.errors
|
maxRetries - 1
|
||||||
)}\nretrying... (${maxRetries - 1} retries remaining)`
|
} retries remaining)`
|
||||||
);
|
);
|
||||||
return release(config, releaser, maxRetries - 1);
|
return release(config, releaser, maxRetries - 1);
|
||||||
}
|
}
|
||||||
|
|
12
src/main.ts
12
src/main.ts
|
@ -3,7 +3,7 @@ import {
|
||||||
parseConfig,
|
parseConfig,
|
||||||
isTag,
|
isTag,
|
||||||
unmatchedPatterns,
|
unmatchedPatterns,
|
||||||
uploadUrl
|
uploadUrl,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
import { release, upload, GitHubReleaser } from "./github";
|
import { release, upload, GitHubReleaser } from "./github";
|
||||||
import { getOctokit } from "@actions/github";
|
import { getOctokit } from "@actions/github";
|
||||||
|
@ -24,7 +24,7 @@ async function run() {
|
||||||
}
|
}
|
||||||
if (config.input_files) {
|
if (config.input_files) {
|
||||||
const patterns = unmatchedPatterns(config.input_files);
|
const patterns = unmatchedPatterns(config.input_files);
|
||||||
patterns.forEach(pattern =>
|
patterns.forEach((pattern) =>
|
||||||
console.warn(`🤔 Pattern '${pattern}' does not match any files.`)
|
console.warn(`🤔 Pattern '${pattern}' does not match any files.`)
|
||||||
);
|
);
|
||||||
if (patterns.length > 0 && config.input_fail_on_unmatched_files) {
|
if (patterns.length > 0 && config.input_fail_on_unmatched_files) {
|
||||||
|
@ -55,8 +55,8 @@ async function run() {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Abuse detected for request ${options.method} ${options.url}`
|
`Abuse detected for request ${options.method} ${options.url}`
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
//);
|
//);
|
||||||
const rel = await release(config, new GitHubReleaser(gh));
|
const rel = await release(config, new GitHubReleaser(gh));
|
||||||
|
@ -67,7 +67,7 @@ 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,
|
||||||
|
@ -78,7 +78,7 @@ async function run() {
|
||||||
delete json.uploader;
|
delete json.uploader;
|
||||||
return json;
|
return json;
|
||||||
})
|
})
|
||||||
).catch(error => {
|
).catch((error) => {
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
setOutput("assets", assets);
|
setOutput("assets", assets);
|
||||||
|
|
10
src/util.ts
10
src/util.ts
|
@ -44,8 +44,8 @@ export const parseInputFiles = (files: string): string[] => {
|
||||||
(acc, line) =>
|
(acc, line) =>
|
||||||
acc
|
acc
|
||||||
.concat(line.split(","))
|
.concat(line.split(","))
|
||||||
.filter(pat => pat)
|
.filter((pat) => pat)
|
||||||
.map(pat => pat.trim()),
|
.map((pat) => pat.trim()),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -69,14 +69,14 @@ export const parseConfig = (env: Env): Config => {
|
||||||
input_discussion_category_name:
|
input_discussion_category_name:
|
||||||
env.INPUT_DISCUSSION_CATEGORY_NAME || undefined,
|
env.INPUT_DISCUSSION_CATEGORY_NAME || undefined,
|
||||||
input_generate_release_notes: env.INPUT_GENERATE_RELEASE_NOTES == "true",
|
input_generate_release_notes: env.INPUT_GENERATE_RELEASE_NOTES == "true",
|
||||||
input_append_body: env.INPUT_APPEND_BODY == "true"
|
input_append_body: env.INPUT_APPEND_BODY == "true",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const paths = (patterns: string[]): string[] => {
|
export const paths = (patterns: string[]): string[] => {
|
||||||
return patterns.reduce((acc: string[], pattern: string): string[] => {
|
return patterns.reduce((acc: string[], pattern: string): string[] => {
|
||||||
return acc.concat(
|
return acc.concat(
|
||||||
glob.sync(pattern).filter(path => statSync(path).isFile())
|
glob.sync(pattern).filter((path) => statSync(path).isFile())
|
||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
};
|
};
|
||||||
|
@ -84,7 +84,7 @@ export const paths = (patterns: string[]): string[] => {
|
||||||
export const unmatchedPatterns = (patterns: string[]): string[] => {
|
export const unmatchedPatterns = (patterns: string[]): string[] => {
|
||||||
return patterns.reduce((acc: string[], pattern: string): string[] => {
|
return patterns.reduce((acc: string[], pattern: string): string[] => {
|
||||||
return acc.concat(
|
return acc.concat(
|
||||||
glob.sync(pattern).filter(path => statSync(path).isFile()).length == 0
|
glob.sync(pattern).filter((path) => statSync(path).isFile()).length == 0
|
||||||
? [pattern]
|
? [pattern]
|
||||||
: []
|
: []
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue