Retain original release info if the keys are not set (#109)
This commit is contained in:
parent
04c14f526b
commit
59b9126341
5 changed files with 57 additions and 12 deletions
|
@ -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. |
|
||||
| `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
|
||||
|
||||
|
|
|
@ -87,8 +87,8 @@ describe("util", () => {
|
|||
github_token: "",
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: false,
|
||||
input_prerelease: false,
|
||||
input_draft: undefined,
|
||||
input_prerelease: undefined,
|
||||
input_files: [],
|
||||
input_name: undefined,
|
||||
input_tag_name: undefined,
|
||||
|
@ -109,8 +109,8 @@ describe("util", () => {
|
|||
github_token: "",
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: false,
|
||||
input_prerelease: false,
|
||||
input_draft: undefined,
|
||||
input_prerelease: undefined,
|
||||
input_files: [],
|
||||
input_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", () => {
|
||||
it("returns true for tags", async () => {
|
||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -16,8 +16,11 @@ export interface Release {
|
|||
upload_url: string;
|
||||
html_url: string;
|
||||
tag_name: string;
|
||||
name: string;
|
||||
body: string;
|
||||
target_commitish: string;
|
||||
draft: boolean;
|
||||
prerelease: boolean;
|
||||
}
|
||||
|
||||
export interface Releaser {
|
||||
|
@ -187,11 +190,24 @@ export const release = async (
|
|||
} else {
|
||||
target_commitish = existingRelease.data.target_commitish;
|
||||
}
|
||||
|
||||
const tag_name = tag;
|
||||
const name = config.input_name || tag;
|
||||
const body = `${existingRelease.data.body}\n${releaseBody(config)}`;
|
||||
const draft = config.input_draft;
|
||||
const prerelease = config.input_prerelease;
|
||||
const name = config.input_name || existingRelease.data.name || tag;
|
||||
|
||||
let body: string = "";
|
||||
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({
|
||||
owner,
|
||||
|
|
|
@ -50,8 +50,10 @@ export const parseConfig = (env: Env): Config => {
|
|||
input_body: env.INPUT_BODY,
|
||||
input_body_path: env.INPUT_BODY_PATH,
|
||||
input_files: parseInputFiles(env.INPUT_FILES || ""),
|
||||
input_draft: env.INPUT_DRAFT === "true",
|
||||
input_prerelease: env.INPUT_PRERELEASE == "true",
|
||||
input_draft: env.INPUT_DRAFT ? env.INPUT_DRAFT === "true" : undefined,
|
||||
input_prerelease: env.INPUT_PRERELEASE
|
||||
? env.INPUT_PRERELEASE == "true"
|
||||
: undefined,
|
||||
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true",
|
||||
input_target_commitish: env.INPUT_TARGET_COMMITISH
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue