add append_body option (#199)
This commit is contained in:
parent
8a65c81355
commit
fe9a9bd329
13
README.md
13
README.md
@ -176,10 +176,11 @@ The following are optional as `step.with` keys
|
||||
| `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 |
|
||||
| `repository` | String | Name of a target repository in `<owner>/<repo>` format. Defaults to GITHUB_REPOSITORY env variable |
|
||||
| `target_commitish` | String | Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Defaults to repository default branch. |
|
||||
| `target_commitish` | String | Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Defaults to repository default branch. |
|
||||
| `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) |
|
||||
| `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
|
||||
attempted first, then falling back on `body` if the path can not be read from.
|
||||
@ -192,11 +193,11 @@ release will retain its original info.
|
||||
|
||||
The following outputs can be accessed via `${{ steps.<step-id>.outputs }}` from this action
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | ------ | --------------------------------------- |
|
||||
| `url` | String | Github.com URL for the release |
|
||||
| `id` | String | Release ID |
|
||||
| `upload_url` | String | URL for uploading assets to the release |
|
||||
| Name | Type | Description |
|
||||
| ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `url` | String | Github.com URL for the release |
|
||||
| `id` | String | Release ID |
|
||||
| `upload_url` | String | URL for uploading assets to the release |
|
||||
| `assets` | String | JSON array containing information about each uploaded asset, in the format given [here](https://docs.github.com/en/rest/reference/repos#upload-a-release-asset--code-samples) (minus the `uploader` field) |
|
||||
|
||||
As an example, you can use `${{ fromJSON(steps.<step-id>.outputs.assets)[0].browser_download_url }}` to get the download URL of the first asset.
|
||||
|
@ -113,6 +113,7 @@ describe("util", () => {
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "",
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: undefined,
|
||||
@ -137,6 +138,7 @@ describe("util", () => {
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "",
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: undefined,
|
||||
@ -160,6 +162,7 @@ describe("util", () => {
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "",
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: undefined,
|
||||
@ -184,6 +187,7 @@ describe("util", () => {
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "",
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: undefined,
|
||||
@ -211,6 +215,7 @@ describe("util", () => {
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "env-token",
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: false,
|
||||
@ -236,6 +241,7 @@ describe("util", () => {
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "input-token",
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: false,
|
||||
@ -260,6 +266,7 @@ describe("util", () => {
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "",
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
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", () => {
|
||||
it("returns true for tags", async () => {
|
||||
|
@ -43,6 +43,9 @@ inputs:
|
||||
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."
|
||||
required: false
|
||||
append_body:
|
||||
description: "Append existed body instead of overrites. Default is false."
|
||||
required: false
|
||||
env:
|
||||
"GITHUB_TOKEN": "As provided by Github Actions"
|
||||
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
|
||||
// others won't previously this was duplicating content for most which
|
||||
// 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 =
|
||||
config.input_draft !== undefined
|
||||
|
@ -18,6 +18,7 @@ export interface Config {
|
||||
input_target_commitish?: string;
|
||||
input_discussion_category_name?: string;
|
||||
input_generate_release_notes?: boolean;
|
||||
input_append_body?: boolean;
|
||||
}
|
||||
|
||||
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_discussion_category_name:
|
||||
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