add append_body option (#199)
This commit is contained in:
parent
8a65c81355
commit
fe9a9bd329
@ -180,6 +180,7 @@ The following are optional as `step.with` keys
|
|||||||
| `token` | String | Secret GitHub Personal Access Token. Defaults to `${{ github.token }}` |
|
| `token` | String | Secret GitHub Personal Access Token. Defaults to `${{ github.token }}` |
|
||||||
| `discussion_category_name` | String | If specified, a discussion of the specified category is created and linked to the release. The value must be a category that already exists in the repository. For more information, see ["Managing categories for discussions in your repository."](https://docs.github.com/en/discussions/managing-discussions-for-your-community/managing-categories-for-discussions-in-your-repository) |
|
| `discussion_category_name` | String | If specified, a discussion of the specified category is created and linked to the release. The value must be a category that already exists in the repository. For more information, see ["Managing categories for discussions in your repository."](https://docs.github.com/en/discussions/managing-discussions-for-your-community/managing-categories-for-discussions-in-your-repository) |
|
||||||
| `generate_release_notes` | Boolean | Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes. See the [GitHub docs for this feature](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) for more information |
|
| `generate_release_notes` | Boolean | Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes. See the [GitHub docs for this feature](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) for more information |
|
||||||
|
| `append_body` | Boolean | Append existed body instead of overrides |
|
||||||
|
|
||||||
💡 When providing a `body` and `body_path` at the same time, `body_path` will be
|
💡 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.
|
attempted first, then falling back on `body` if the path can not be read from.
|
||||||
@ -193,7 +194,7 @@ release will retain its original info.
|
|||||||
The following outputs can be accessed via `${{ steps.<step-id>.outputs }}` from this action
|
The following outputs can be accessed via `${{ steps.<step-id>.outputs }}` from this action
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------ | ------ | --------------------------------------- |
|
| ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `url` | String | Github.com URL for the release |
|
| `url` | String | Github.com URL for the release |
|
||||||
| `id` | String | Release ID |
|
| `id` | String | Release ID |
|
||||||
| `upload_url` | String | URL for uploading assets to the release |
|
| `upload_url` | String | URL for uploading assets to the release |
|
||||||
|
@ -113,6 +113,7 @@ describe("util", () => {
|
|||||||
github_ref: "",
|
github_ref: "",
|
||||||
github_repository: "",
|
github_repository: "",
|
||||||
github_token: "",
|
github_token: "",
|
||||||
|
input_append_body: false,
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
@ -137,6 +138,7 @@ describe("util", () => {
|
|||||||
github_ref: "",
|
github_ref: "",
|
||||||
github_repository: "",
|
github_repository: "",
|
||||||
github_token: "",
|
github_token: "",
|
||||||
|
input_append_body: false,
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
@ -160,6 +162,7 @@ describe("util", () => {
|
|||||||
github_ref: "",
|
github_ref: "",
|
||||||
github_repository: "",
|
github_repository: "",
|
||||||
github_token: "",
|
github_token: "",
|
||||||
|
input_append_body: false,
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
@ -184,6 +187,7 @@ describe("util", () => {
|
|||||||
github_ref: "",
|
github_ref: "",
|
||||||
github_repository: "",
|
github_repository: "",
|
||||||
github_token: "",
|
github_token: "",
|
||||||
|
input_append_body: false,
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
@ -211,6 +215,7 @@ describe("util", () => {
|
|||||||
github_ref: "",
|
github_ref: "",
|
||||||
github_repository: "",
|
github_repository: "",
|
||||||
github_token: "env-token",
|
github_token: "env-token",
|
||||||
|
input_append_body: false,
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
@ -236,6 +241,7 @@ describe("util", () => {
|
|||||||
github_ref: "",
|
github_ref: "",
|
||||||
github_repository: "",
|
github_repository: "",
|
||||||
github_token: "input-token",
|
github_token: "input-token",
|
||||||
|
input_append_body: false,
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
@ -260,6 +266,7 @@ describe("util", () => {
|
|||||||
github_ref: "",
|
github_ref: "",
|
||||||
github_repository: "",
|
github_repository: "",
|
||||||
github_token: "",
|
github_token: "",
|
||||||
|
input_append_body: false,
|
||||||
input_body: undefined,
|
input_body: undefined,
|
||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
@ -274,6 +281,30 @@ describe("util", () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it("parses basic config with append_body", () => {
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
parseConfig({
|
||||||
|
INPUT_APPEND_BODY: "true"
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
github_ref: "",
|
||||||
|
github_repository: "",
|
||||||
|
github_token: "",
|
||||||
|
input_append_body: true,
|
||||||
|
input_body: undefined,
|
||||||
|
input_body_path: undefined,
|
||||||
|
input_draft: undefined,
|
||||||
|
input_prerelease: undefined,
|
||||||
|
input_files: [],
|
||||||
|
input_name: undefined,
|
||||||
|
input_tag_name: undefined,
|
||||||
|
input_fail_on_unmatched_files: false,
|
||||||
|
input_target_commitish: undefined,
|
||||||
|
input_discussion_category_name: undefined,
|
||||||
|
input_generate_release_notes: false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe("isTag", () => {
|
describe("isTag", () => {
|
||||||
it("returns true for tags", async () => {
|
it("returns true for tags", async () => {
|
||||||
|
@ -43,6 +43,9 @@ inputs:
|
|||||||
generate_release_notes:
|
generate_release_notes:
|
||||||
description: "Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes."
|
description: "Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes."
|
||||||
required: false
|
required: false
|
||||||
|
append_body:
|
||||||
|
description: "Append existed body instead of overrites. Default is false."
|
||||||
|
required: false
|
||||||
env:
|
env:
|
||||||
"GITHUB_TOKEN": "As provided by Github Actions"
|
"GITHUB_TOKEN": "As provided by Github Actions"
|
||||||
outputs:
|
outputs:
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -238,7 +238,14 @@ export const release = async (
|
|||||||
// body parts as a release gets updated. some users will likely want this while
|
// body parts as a release gets updated. some users will likely want this while
|
||||||
// others won't previously this was duplicating content for most which
|
// others won't previously this was duplicating content for most which
|
||||||
// no one wants
|
// no one wants
|
||||||
let body = releaseBody(config) || existingRelease.data.body || "";
|
const workflowBody = releaseBody(config) || "";
|
||||||
|
const existingReleaseBody = existingRelease.data.body || "";
|
||||||
|
let body: string;
|
||||||
|
if (config.input_append_body && workflowBody && existingReleaseBody) {
|
||||||
|
body = existingReleaseBody + "\n" + workflowBody;
|
||||||
|
} else {
|
||||||
|
body = workflowBody || existingReleaseBody;
|
||||||
|
}
|
||||||
|
|
||||||
const draft =
|
const draft =
|
||||||
config.input_draft !== undefined
|
config.input_draft !== undefined
|
||||||
|
@ -18,6 +18,7 @@ export interface Config {
|
|||||||
input_target_commitish?: string;
|
input_target_commitish?: string;
|
||||||
input_discussion_category_name?: string;
|
input_discussion_category_name?: string;
|
||||||
input_generate_release_notes?: boolean;
|
input_generate_release_notes?: boolean;
|
||||||
|
input_append_body?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const uploadUrl = (url: string): string => {
|
export const uploadUrl = (url: string): string => {
|
||||||
@ -67,7 +68,8 @@ export const parseConfig = (env: Env): Config => {
|
|||||||
input_target_commitish: env.INPUT_TARGET_COMMITISH || undefined,
|
input_target_commitish: env.INPUT_TARGET_COMMITISH || undefined,
|
||||||
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"
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user