Resolve conflicts

This commit is contained in:
koplo199 2022-11-07 17:08:11 +01:00
parent 5de29c20f3
commit 95c236c0ce
No known key found for this signature in database
GPG key ID: FBB75767FC87A78A
6 changed files with 8643 additions and 1755 deletions

View file

@ -5,7 +5,7 @@ import {
parseConfig,
parseInputFiles,
unmatchedPatterns,
uploadUrl
uploadUrl,
} from "../src/util";
import * as assert from "assert";
@ -51,7 +51,7 @@ describe("util", () => {
input_tag_name: undefined,
input_target_commitish: 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_target_commitish: 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_target_commitish: 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
// resolved as undefined and not empty strings
INPUT_TARGET_COMMITISH: "",
INPUT_DISCUSSION_CATEGORY_NAME: ""
INPUT_DISCUSSION_CATEGORY_NAME: "",
}),
{
github_ref: "",
@ -124,7 +124,7 @@ describe("util", () => {
input_fail_on_unmatched_files: false,
input_target_commitish: 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", () => {
assert.deepStrictEqual(
parseConfig({
INPUT_TARGET_COMMITISH: "affa18ef97bc9db20076945705aba8c516139abd"
INPUT_TARGET_COMMITISH: "affa18ef97bc9db20076945705aba8c516139abd",
}),
{
github_ref: "",
@ -149,14 +149,14 @@ describe("util", () => {
input_fail_on_unmatched_files: false,
input_target_commitish: "affa18ef97bc9db20076945705aba8c516139abd",
input_discussion_category_name: undefined,
input_generate_release_notes: false
input_generate_release_notes: false,
}
);
});
it("supports discussion category names", () => {
assert.deepStrictEqual(
parseConfig({
INPUT_DISCUSSION_CATEGORY_NAME: "releases"
INPUT_DISCUSSION_CATEGORY_NAME: "releases",
}),
{
github_ref: "",
@ -173,7 +173,7 @@ describe("util", () => {
input_fail_on_unmatched_files: false,
input_target_commitish: undefined,
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", () => {
assert.deepStrictEqual(
parseConfig({
INPUT_GENERATE_RELEASE_NOTES: "true"
INPUT_GENERATE_RELEASE_NOTES: "true",
}),
{
github_ref: "",
@ -198,7 +198,7 @@ describe("util", () => {
input_fail_on_unmatched_files: false,
input_target_commitish: 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_PRERELEASE: "true",
GITHUB_TOKEN: "env-token",
INPUT_TOKEN: "input-token"
INPUT_TOKEN: "input-token",
}),
{
github_ref: "",
@ -226,7 +226,7 @@ describe("util", () => {
input_fail_on_unmatched_files: false,
input_target_commitish: undefined,
input_discussion_category_name: undefined,
input_generate_release_notes: false
input_generate_release_notes: false,
}
);
});
@ -235,7 +235,7 @@ describe("util", () => {
parseConfig({
INPUT_DRAFT: "false",
INPUT_PRERELEASE: "true",
INPUT_TOKEN: "input-token"
INPUT_TOKEN: "input-token",
}),
{
github_ref: "",
@ -252,7 +252,7 @@ describe("util", () => {
input_fail_on_unmatched_files: false,
input_target_commitish: undefined,
input_discussion_category_name: undefined,
input_generate_release_notes: false
input_generate_release_notes: false,
}
);
});
@ -260,7 +260,7 @@ describe("util", () => {
assert.deepStrictEqual(
parseConfig({
INPUT_DRAFT: "false",
INPUT_PRERELEASE: "true"
INPUT_PRERELEASE: "true",
}),
{
github_ref: "",
@ -277,14 +277,14 @@ describe("util", () => {
input_fail_on_unmatched_files: false,
input_target_commitish: undefined,
input_discussion_category_name: undefined,
input_generate_release_notes: false
input_generate_release_notes: false,
}
);
});
it("parses basic config with append_body", () => {
assert.deepStrictEqual(
parseConfig({
INPUT_APPEND_BODY: "true"
INPUT_APPEND_BODY: "true",
}),
{
github_ref: "",
@ -301,7 +301,7 @@ describe("util", () => {
input_fail_on_unmatched_files: false,
input_target_commitish: undefined,
input_discussion_category_name: undefined,
input_generate_release_notes: false
input_generate_release_notes: false,
}
);
});

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

10310
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -128,7 +128,7 @@ export const asset = (path: string): ReleaseAsset => {
name: basename(path),
mime: mimeOrDefault(path),
size: statSync(path).size,
data: readFileSync(path)
data: readFileSync(path),
};
};
@ -153,7 +153,7 @@ export const upload = async (
await github.rest.repos.deleteReleaseAsset({
asset_id: currentAsset.id || 1,
owner,
repo
repo,
});
}
console.log(`⬆️ Uploading ${name}...`);
@ -163,10 +163,10 @@ export const upload = async (
headers: {
"content-length": `${size}`,
"content-type": mime,
authorization: `token ${config.github_token}`
authorization: `token ${config.github_token}`,
},
method: "POST",
body
body,
});
const json = await resp.json();
if (resp.status !== 201) {
@ -204,9 +204,9 @@ export const release = async (
if (config.input_draft) {
for await (const response of releaser.allReleases({
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) {
return release;
}
@ -215,7 +215,7 @@ export const release = async (
let existingRelease = await releaser.getReleaseByTag({
owner,
repo,
tag
tag,
});
const release_id = existingRelease.data.id;
@ -267,7 +267,7 @@ export const release = async (
draft,
prerelease,
discussion_category_name,
generate_release_notes
generate_release_notes,
});
return release.data;
} catch (error) {
@ -296,7 +296,7 @@ export const release = async (
prerelease,
target_commitish,
discussion_category_name,
generate_release_notes
generate_release_notes,
});
return release.data;
} catch (error) {
@ -304,9 +304,9 @@ export const release = async (
console.log(
`⚠️ GitHub release failed with status: ${
error.status
}\n${JSON.stringify(
error.response.data.errors
)}\nretrying... (${maxRetries - 1} retries remaining)`
}\n${JSON.stringify(error.response.data.errors)}\nretrying... (${
maxRetries - 1
} retries remaining)`
);
return release(config, releaser, maxRetries - 1);
}

View file

@ -3,7 +3,7 @@ import {
parseConfig,
isTag,
unmatchedPatterns,
uploadUrl
uploadUrl,
} from "./util";
import { release, upload, GitHubReleaser } from "./github";
import { getOctokit } from "@actions/github";
@ -24,7 +24,7 @@ async function run() {
}
if (config.input_files) {
const patterns = unmatchedPatterns(config.input_files);
patterns.forEach(pattern =>
patterns.forEach((pattern) =>
console.warn(`🤔 Pattern '${pattern}' does not match any files.`)
);
if (patterns.length > 0 && config.input_fail_on_unmatched_files) {
@ -55,8 +55,8 @@ async function run() {
console.warn(
`Abuse detected for request ${options.method} ${options.url}`
);
}
}
},
},
});
//);
const rel = await release(config, new GitHubReleaser(gh));
@ -67,7 +67,7 @@ async function run() {
}
const currentAssets = rel.assets;
const assets = await Promise.all(
files.map(async path => {
files.map(async (path) => {
const json = await upload(
config,
gh,
@ -78,7 +78,7 @@ async function run() {
delete json.uploader;
return json;
})
).catch(error => {
).catch((error) => {
throw error;
});
setOutput("assets", assets);

View file

@ -44,8 +44,8 @@ export const parseInputFiles = (files: string): string[] => {
(acc, line) =>
acc
.concat(line.split(","))
.filter(pat => pat)
.map(pat => pat.trim()),
.filter((pat) => pat)
.map((pat) => pat.trim()),
[]
);
};
@ -69,14 +69,14 @@ export const parseConfig = (env: Env): Config => {
input_discussion_category_name:
env.INPUT_DISCUSSION_CATEGORY_NAME || undefined,
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[] => {
return patterns.reduce((acc: string[], pattern: string): string[] => {
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[] => {
return patterns.reduce((acc: string[], pattern: string): string[] => {
return acc.concat(
glob.sync(pattern).filter(path => statSync(path).isFile()).length == 0
glob.sync(pattern).filter((path) => statSync(path).isFile()).length == 0
? [pattern]
: []
);