Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
1e07f43987 | |||
0465cdad11 | |||
69a9b03fd9 | |||
a80139913a | |||
6034af24fb | |||
0b1e2e4582 | |||
a3f0173fb3 | |||
2d72d869af | |||
730b76a669 |
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,6 +1,19 @@
|
|||||||
|
## 0.1.14
|
||||||
|
|
||||||
|
- provides an new workflow input option `generate_release_notes` which when set to true will automatically generate release notes for you based on GitHub activity [#179](https://github.com/softprops/action-gh-release/pull/179). Please see the [GitHub docs for this feature](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) for more information
|
||||||
|
|
||||||
|
## 0.1.13
|
||||||
|
|
||||||
|
- fix issue with multiple runs concatenating release bodies [#145](https://github.com/softprops/action-gh-release/pull/145)
|
||||||
|
|
||||||
|
## 0.1.12
|
||||||
|
|
||||||
|
- fix bug leading to empty strings subsituted for inputs users don't provide breaking api calls [#144](https://github.com/softprops/action-gh-release/pull/144)
|
||||||
|
|
||||||
## 0.1.11
|
## 0.1.11
|
||||||
|
|
||||||
- better error message on release create failed [#143](https://github.com/softprops/action-gh-release/pull/143)
|
- better error message on release create failed [#143](https://github.com/softprops/action-gh-release/pull/143)
|
||||||
|
|
||||||
## 0.1.10
|
## 0.1.10
|
||||||
|
|
||||||
- fixed error message formatting for file uploads
|
- fixed error message formatting for file uploads
|
||||||
|
40
README.md
40
README.md
@ -165,20 +165,21 @@ jobs:
|
|||||||
|
|
||||||
The following are optional as `step.with` keys
|
The following are optional as `step.with` keys
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| -------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| -------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `body` | String | Text communicating notable changes in this release |
|
| `body` | String | Text communicating notable changes in this release |
|
||||||
| `body_path` | String | Path to load text communicating notable changes in this release |
|
| `body_path` | String | Path to load text communicating notable changes in this release |
|
||||||
| `draft` | Boolean | Indicator of whether or not this release is a draft |
|
| `draft` | Boolean | Indicator of whether or not this release is a draft |
|
||||||
| `prerelease` | Boolean | Indicator of whether or not is a prerelease |
|
| `prerelease` | Boolean | Indicator of whether or not is a prerelease |
|
||||||
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
|
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
|
||||||
| `name` | String | Name of the release. defaults to tag name |
|
| `name` | String | Name of the release. defaults to tag name |
|
||||||
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
|
| `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 |
|
| `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 |
|
| `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. |
|
| `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 }}` |
|
| `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 |
|
||||||
|
|
||||||
💡 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.
|
||||||
@ -208,4 +209,15 @@ The following `step.env` keys are allowed as a fallback but deprecated in favor
|
|||||||
|
|
||||||
> **⚠️ Note:** This action was previously implemented as a Docker container, limiting its use to GitHub Actions Linux virtual environments only. With recent releases, we now support cross platform usage. You'll need to remove the `docker://` prefix in these versions
|
> **⚠️ Note:** This action was previously implemented as a Docker container, limiting its use to GitHub Actions Linux virtual environments only. With recent releases, we now support cross platform usage. You'll need to remove the `docker://` prefix in these versions
|
||||||
|
|
||||||
|
### Permissions
|
||||||
|
|
||||||
|
This Action requires the following permissions on the GitHub integration token:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
```
|
||||||
|
|
||||||
|
[GitHub token permissions](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token) can be set for an individual job, workflow, or for Actions as a whole.
|
||||||
|
|
||||||
Doug Tangren (softprops) 2019
|
Doug Tangren (softprops) 2019
|
||||||
|
@ -11,7 +11,7 @@ import * as assert from "assert";
|
|||||||
|
|
||||||
describe("util", () => {
|
describe("util", () => {
|
||||||
describe("uploadUrl", () => {
|
describe("uploadUrl", () => {
|
||||||
it("stripts template", () => {
|
it("strips template", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
uploadUrl(
|
uploadUrl(
|
||||||
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}"
|
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}"
|
||||||
@ -50,7 +50,8 @@ describe("util", () => {
|
|||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
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
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -69,7 +70,8 @@ describe("util", () => {
|
|||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
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
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -88,28 +90,42 @@ describe("util", () => {
|
|||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
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
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("parseConfig", () => {
|
describe("parseConfig", () => {
|
||||||
it("parses basic config", () => {
|
it("parses basic config", () => {
|
||||||
assert.deepStrictEqual(parseConfig({}), {
|
assert.deepStrictEqual(
|
||||||
github_ref: "",
|
parseConfig({
|
||||||
github_repository: "",
|
// note: inputs declared in actions.yml, even when declared not required,
|
||||||
github_token: "",
|
// are still provided by the actions runtime env as empty strings instead of
|
||||||
input_body: undefined,
|
// the normal absent env value one would expect. this breaks things
|
||||||
input_body_path: undefined,
|
// as an empty string !== undefined in terms of what we pass to the api
|
||||||
input_draft: undefined,
|
// so we cover that in a test case here to ensure undefined values are actually
|
||||||
input_prerelease: undefined,
|
// resolved as undefined and not empty strings
|
||||||
input_files: [],
|
INPUT_TARGET_COMMITISH: "",
|
||||||
input_name: undefined,
|
INPUT_DISCUSSION_CATEGORY_NAME: ""
|
||||||
input_tag_name: undefined,
|
}),
|
||||||
input_fail_on_unmatched_files: false,
|
{
|
||||||
input_target_commitish: undefined,
|
github_ref: "",
|
||||||
input_discussion_category_name: undefined
|
github_repository: "",
|
||||||
});
|
github_token: "",
|
||||||
|
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
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("parses basic config with commitish", () => {
|
it("parses basic config with commitish", () => {
|
||||||
@ -130,7 +146,8 @@ describe("util", () => {
|
|||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
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
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -152,10 +169,36 @@ describe("util", () => {
|
|||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
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
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("supports generating release notes", () => {
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
parseConfig({
|
||||||
|
INPUT_GENERATE_RELEASE_NOTES: "true"
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
github_ref: "",
|
||||||
|
github_repository: "",
|
||||||
|
github_token: "",
|
||||||
|
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: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("prefers GITHUB_TOKEN over token input for backwards compatibility", () => {
|
it("prefers GITHUB_TOKEN over token input for backwards compatibility", () => {
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
parseConfig({
|
parseConfig({
|
||||||
@ -177,7 +220,8 @@ describe("util", () => {
|
|||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
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
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -201,7 +245,8 @@ describe("util", () => {
|
|||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
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
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -224,7 +269,8 @@ describe("util", () => {
|
|||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
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
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -40,6 +40,9 @@ inputs:
|
|||||||
discussion_category_name:
|
discussion_category_name:
|
||||||
description: "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. If there is already a discussion linked to the release, this parameter is ignored."
|
description: "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. If there is already a discussion linked to the release, this parameter is ignored."
|
||||||
required: false
|
required: false
|
||||||
|
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
|
||||||
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
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "0.1.8",
|
"version": "0.1.14",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "0.1.11",
|
"version": "0.1.14",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "GitHub Action for creating GitHub Releases",
|
"description": "GitHub Action for creating GitHub Releases",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
|
@ -44,6 +44,7 @@ export interface Releaser {
|
|||||||
prerelease: boolean | undefined;
|
prerelease: boolean | undefined;
|
||||||
target_commitish: string | undefined;
|
target_commitish: string | undefined;
|
||||||
discussion_category_name: string | undefined;
|
discussion_category_name: string | undefined;
|
||||||
|
generate_release_notes: boolean | undefined;
|
||||||
}): Promise<{ data: Release }>;
|
}): Promise<{ data: Release }>;
|
||||||
|
|
||||||
updateRelease(params: {
|
updateRelease(params: {
|
||||||
@ -57,6 +58,7 @@ export interface Releaser {
|
|||||||
draft: boolean | undefined;
|
draft: boolean | undefined;
|
||||||
prerelease: boolean | undefined;
|
prerelease: boolean | undefined;
|
||||||
discussion_category_name: string | undefined;
|
discussion_category_name: string | undefined;
|
||||||
|
generate_release_notes: boolean | undefined;
|
||||||
}): Promise<{ data: Release }>;
|
}): Promise<{ data: Release }>;
|
||||||
|
|
||||||
allReleases(params: {
|
allReleases(params: {
|
||||||
@ -89,6 +91,7 @@ export class GitHubReleaser implements Releaser {
|
|||||||
prerelease: boolean | undefined;
|
prerelease: boolean | undefined;
|
||||||
target_commitish: string | undefined;
|
target_commitish: string | undefined;
|
||||||
discussion_category_name: string | undefined;
|
discussion_category_name: string | undefined;
|
||||||
|
generate_release_notes: boolean | undefined;
|
||||||
}): Promise<{ data: Release }> {
|
}): Promise<{ data: Release }> {
|
||||||
return this.github.rest.repos.createRelease(params);
|
return this.github.rest.repos.createRelease(params);
|
||||||
}
|
}
|
||||||
@ -104,6 +107,7 @@ export class GitHubReleaser implements Releaser {
|
|||||||
draft: boolean | undefined;
|
draft: boolean | undefined;
|
||||||
prerelease: boolean | undefined;
|
prerelease: boolean | undefined;
|
||||||
discussion_category_name: string | undefined;
|
discussion_category_name: string | undefined;
|
||||||
|
generate_release_notes: boolean | undefined;
|
||||||
}): Promise<{ data: Release }> {
|
}): Promise<{ data: Release }> {
|
||||||
return this.github.rest.repos.updateRelease(params);
|
return this.github.rest.repos.updateRelease(params);
|
||||||
}
|
}
|
||||||
@ -124,7 +128,7 @@ export const asset = (path: string): ReleaseAsset => {
|
|||||||
name: basename(path),
|
name: basename(path),
|
||||||
mime: mimeOrDefault(path),
|
mime: mimeOrDefault(path),
|
||||||
size: lstatSync(path).size,
|
size: lstatSync(path).size,
|
||||||
data: readFileSync(path),
|
data: readFileSync(path)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -149,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}...`);
|
||||||
@ -159,15 +163,15 @@ 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) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to upload release asset ${name}. recieved status code ${
|
`Failed to upload release asset ${name}. received status code ${
|
||||||
resp.status
|
resp.status
|
||||||
}\n${json.message}\n${JSON.stringify(json.errors)}`
|
}\n${json.message}\n${JSON.stringify(json.errors)}`
|
||||||
);
|
);
|
||||||
@ -193,27 +197,26 @@ export const release = async (
|
|||||||
: "");
|
: "");
|
||||||
|
|
||||||
const discussion_category_name = config.input_discussion_category_name;
|
const discussion_category_name = config.input_discussion_category_name;
|
||||||
|
const generate_release_notes = config.input_generate_release_notes;
|
||||||
try {
|
try {
|
||||||
// you can't get a an existing draft by tag
|
// you can't get a an existing draft by tag
|
||||||
// so we must find one in the list of all releases
|
// so we must find one in the list of all releases
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(`fetching existing release for tag ${owner}/${repo}/${tag}`);
|
|
||||||
let existingRelease = await releaser.getReleaseByTag({
|
let existingRelease = await releaser.getReleaseByTag({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
tag,
|
tag
|
||||||
});
|
});
|
||||||
console.log(`found release ${existingRelease.data.id}`);
|
|
||||||
|
|
||||||
const release_id = existingRelease.data.id;
|
const release_id = existingRelease.data.id;
|
||||||
let target_commitish: string;
|
let target_commitish: string;
|
||||||
@ -231,12 +234,11 @@ export const release = async (
|
|||||||
|
|
||||||
const tag_name = tag;
|
const tag_name = tag;
|
||||||
const name = config.input_name || existingRelease.data.name || tag;
|
const name = config.input_name || existingRelease.data.name || tag;
|
||||||
|
// revisit: support a new body-concat-strategy input for accumulating
|
||||||
let body: string = "";
|
// body parts as a release gets updated. some users will likely want this while
|
||||||
if (existingRelease.data.body) body += existingRelease.data.body;
|
// others won't previously this was duplicating content for most which
|
||||||
let workflowBody = releaseBody(config);
|
// no one wants
|
||||||
if (existingRelease.data.body && workflowBody) body += "\n";
|
let body = releaseBody(config) || existingRelease.data.body || "";
|
||||||
if (workflowBody) body += workflowBody;
|
|
||||||
|
|
||||||
const draft =
|
const draft =
|
||||||
config.input_draft !== undefined
|
config.input_draft !== undefined
|
||||||
@ -247,21 +249,6 @@ export const release = async (
|
|||||||
? config.input_prerelease
|
? config.input_prerelease
|
||||||
: existingRelease.data.prerelease;
|
: existingRelease.data.prerelease;
|
||||||
|
|
||||||
console.log(
|
|
||||||
`attemping update of release_id ${release_id} tag_name ${tag_name} target_commitish ${target_commitish} discussion_category_name ${discussion_category_name}`
|
|
||||||
);
|
|
||||||
console.log({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
release_id,
|
|
||||||
tag_name,
|
|
||||||
target_commitish,
|
|
||||||
name,
|
|
||||||
body,
|
|
||||||
draft,
|
|
||||||
prerelease,
|
|
||||||
discussion_category_name,
|
|
||||||
});
|
|
||||||
const release = await releaser.updateRelease({
|
const release = await releaser.updateRelease({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@ -273,13 +260,11 @@ export const release = async (
|
|||||||
draft,
|
draft,
|
||||||
prerelease,
|
prerelease,
|
||||||
discussion_category_name,
|
discussion_category_name,
|
||||||
|
generate_release_notes
|
||||||
});
|
});
|
||||||
console.log(`updated release ${release_id}`);
|
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.status === 404) {
|
if (error.status === 404) {
|
||||||
console.log(`update failed with 404`);
|
|
||||||
console.log(JSON.stringify(error.response.data.errors));
|
|
||||||
const tag_name = tag;
|
const tag_name = tag;
|
||||||
const name = config.input_name || tag;
|
const name = config.input_name || tag;
|
||||||
const body = releaseBody(config);
|
const body = releaseBody(config);
|
||||||
@ -293,18 +278,6 @@ export const release = async (
|
|||||||
console.log(
|
console.log(
|
||||||
`👩🏭 Creating new GitHub release for tag ${tag_name}${commitMessage}...`
|
`👩🏭 Creating new GitHub release for tag ${tag_name}${commitMessage}...`
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
tag_name,
|
|
||||||
name,
|
|
||||||
body,
|
|
||||||
draft,
|
|
||||||
prerelease,
|
|
||||||
target_commitish,
|
|
||||||
discussion_category_name,
|
|
||||||
});
|
|
||||||
try {
|
try {
|
||||||
let release = await releaser.createRelease({
|
let release = await releaser.createRelease({
|
||||||
owner,
|
owner,
|
||||||
@ -316,6 +289,7 @@ export const release = async (
|
|||||||
prerelease,
|
prerelease,
|
||||||
target_commitish,
|
target_commitish,
|
||||||
discussion_category_name,
|
discussion_category_name,
|
||||||
|
generate_release_notes
|
||||||
});
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
10
src/util.ts
10
src/util.ts
@ -17,6 +17,7 @@ export interface Config {
|
|||||||
input_fail_on_unmatched_files?: boolean;
|
input_fail_on_unmatched_files?: boolean;
|
||||||
input_target_commitish?: string;
|
input_target_commitish?: string;
|
||||||
input_discussion_category_name?: string;
|
input_discussion_category_name?: string;
|
||||||
|
input_generate_release_notes?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const uploadUrl = (url: string): string => {
|
export const uploadUrl = (url: string): string => {
|
||||||
@ -42,8 +43,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()),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -66,13 +67,14 @@ 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"
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
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) => lstatSync(path).isFile())
|
glob.sync(pattern).filter(path => lstatSync(path).isFile())
|
||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
};
|
};
|
||||||
@ -80,7 +82,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) => lstatSync(path).isFile()).length == 0
|
glob.sync(pattern).filter(path => lstatSync(path).isFile()).length == 0
|
||||||
? [pattern]
|
? [pattern]
|
||||||
: []
|
: []
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user