Compare commits

...

47 Commits

Author SHA1 Message Date
ee106b7545 Merge branch 'master' of https://github.com/softprops/action-gh-release into dependabot/npm_and_yarn/multi-3e562954ba 2024-07-18 16:37:03 -04:00
20adb4259c refactor: write jest config in ts (#485)
* refactor: write jest config in ts

Signed-off-by: Rui Chen <rui@chenrui.dev>

* chore: exclude jest.config.ts in tsconfig

Signed-off-by: Rui Chen <rui@chenrui.dev>

* chore: run build

Signed-off-by: Rui Chen <rui@chenrui.dev>

---------

Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-07-18 16:35:10 -04:00
c3ffbd78af chore: update mime import
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-07-18 16:13:42 -04:00
9172d9bd34 Bump mime and @types/mime
Bumps [mime](https://github.com/broofa/mime) and [@types/mime](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mime). These dependencies needed to be updated together.

Updates `mime` from 3.0.0 to 4.0.4
- [Changelog](https://github.com/broofa/mime/blob/main/CHANGELOG.md)
- [Commits](https://github.com/broofa/mime/compare/v3.0.0...v4.0.4)

Updates `@types/mime` from 3.0.4 to 4.0.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mime)

---
updated-dependencies:
- dependency-name: mime
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: "@types/mime"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-18 20:09:15 +00:00
f808f15ba8 chore(deps): bump glob from 10.4.2 to 11.0.0 (#477)
Bumps [glob](https://github.com/isaacs/node-glob) from 10.4.2 to 11.0.0.
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v10.4.2...v11.0.0)

---
updated-dependencies:
- dependency-name: glob
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-18 16:08:36 -04:00
6145241049 chore(deps): bump @octokit/plugin-throttling from 9.3.0 to 9.3.1 (#484)
Bumps [@octokit/plugin-throttling](https://github.com/octokit/plugin-throttling.js) from 9.3.0 to 9.3.1.
- [Release notes](https://github.com/octokit/plugin-throttling.js/releases)
- [Commits](https://github.com/octokit/plugin-throttling.js/compare/v9.3.0...v9.3.1)

---
updated-dependencies:
- dependency-name: "@octokit/plugin-throttling"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-18 16:06:27 -04:00
4ac522d0bd chore(deps): bump @types/node from 20.14.9 to 20.14.11 (#483)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.14.9 to 20.14.11.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-18 16:06:21 -04:00
25849b1326 chore(deps): bump prettier from 2.8.0 to 3.3.3 (#480)
* Bump prettier from 2.8.0 to 3.3.3

Bumps [prettier](https://github.com/prettier/prettier) from 2.8.0 to 3.3.3.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.0...3.3.3)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* run fmt

Signed-off-by: Rui Chen <rui@chenrui.dev>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Rui Chen <rui@chenrui.dev>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rui Chen <rui@chenrui.dev>
2024-07-18 16:05:39 -04:00
62060560e3 chore: update dependabot commit msg
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-07-18 16:05:11 -04:00
39aadf190d chore: run frizbee actions .github/workflows/
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-07-17 16:37:53 -04:00
6f3ab65323 chore: update dist file
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-07-17 16:02:09 -04:00
cdef11965e chore: replace nvmrc with tool-versions and update workflow
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-07-17 16:01:38 -04:00
48b853e7ea docs: add toc
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-07-17 15:52:35 -04:00
82b4a28696 docs: update changelog for 2.0.7 rel
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-07-17 15:51:10 -04:00
fb2d03176f Fix missing update release body (#365)
* Update json5 deps

* Remove quote around env var `GITHUB_TOKEN`

* Factorize search by draft & tag

* Correct `_release` undefined when creating a new release

* Cleanup package-lock
2024-07-17 14:14:48 -04:00
08d85b1534 docs: document that existing releases are updated (#474) 2024-07-16 18:08:58 -04:00
a636f98a4d Bump ts-jest from 29.1.5 to 29.2.2
Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 29.1.5 to 29.2.2.
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v29.1.5...v29.2.2)

---
updated-dependencies:
- dependency-name: ts-jest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-16 18:08:11 -04:00
288696be39 Bump typescript from 5.5.2 to 5.5.3
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.5.2 to 5.5.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.5.2...v5.5.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-03 00:51:53 -04:00
6de5d7916c Bump @types/node from 20.14.8 to 20.14.9
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.14.8 to 20.14.9.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-03 00:51:43 -04:00
a485adba73 Bump @types/node from 20.14.6 to 20.14.8
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.14.6 to 20.14.8.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-26 18:23:48 -04:00
26f874e54a Bump typescript from 4.9.5 to 5.5.2
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.9.5 to 5.5.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.9.5...v5.5.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-26 18:23:42 -04:00
810bfa2cd5 chore: add .github/release.yml
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-19 19:39:31 -04:00
019fc2114d Bump @octokit/plugin-retry from 4.0.3 to 7.1.1 (#443)
Bumps [@octokit/plugin-retry](https://github.com/octokit/plugin-retry.js) from 4.0.3 to 7.1.1.
- [Release notes](https://github.com/octokit/plugin-retry.js/releases)
- [Commits](https://github.com/octokit/plugin-retry.js/compare/v4.0.3...v7.1.1)

---
updated-dependencies:
- dependency-name: "@octokit/plugin-retry"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-19 17:21:30 -04:00
a74c6b72af update changelog
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-19 17:02:53 -04:00
b909f761f0 update dist/index.js
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-19 17:02:08 -04:00
e49d08fa32 chore(deps): bump glob from 8.0.3 to 10.4.2
closes #464

Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-19 16:57:12 -04:00
f12ad255e1 chore(deps): bump @octokit/plugin-throttling from 4.3.2 to 9.3.0
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-19 16:54:35 -04:00
7039a825a7 chore: release 2.0.6
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-19 16:52:27 -04:00
f9c2b6ca37 chore: update deps and run build
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-19 16:52:01 -04:00
73738a6293 chore(deps): bump node dep and @types/node
closes #463

Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-19 16:48:57 -04:00
a500a35279 Bump ts-jest from 29.0.3 to 29.1.4 (#459)
Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 29.0.3 to 29.1.4.
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v29.0.3...v29.1.4)

---
updated-dependencies:
- dependency-name: ts-jest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-19 16:46:05 -04:00
69320dbe05 update changelog 2024-05-07 09:26:47 -04:00
9771ccf55f update changelog rebuild dist 2024-05-07 09:23:27 -04:00
0a76e4214a Fix: error handling (#449)
- refactored the big `if/else` to exit early
- added error handling for different errors while creating a release
2024-05-07 09:21:14 -04:00
3989e4b325 document impl detail 2024-05-06 09:44:36 -04:00
72e945e627 update changelog 2024-05-06 09:38:04 -04:00
40bf9ec7aa fmt and build 2024-05-06 09:36:20 -04:00
998623f0c3 fix: support space in file name (#446)
* support space in file name

* Update github.ts
2024-05-06 09:35:11 -04:00
0979303f02 Fix failure (#447)
* Fix(temp): console.log

* broken dist
2024-05-06 09:27:30 -04:00
9b795e5782 Update README.md (#432)
Fix deprecated env mention in External Release Notes
2024-04-07 13:11:38 -04:00
9d7c94cfd0 build 2024-03-12 12:26:09 -04:00
6ffed59e55 followup to #417 (#425)
* followup to #417

* update changelog
2024-03-12 12:22:52 -04:00
1ce812a7bd package script for updating git tag 2024-03-11 09:46:18 -04:00
3198ee18f8 prep release 2024-03-11 09:44:32 -04:00
7ee8e06381 declare an update docs for make_latest input (#419) 2024-03-11 09:42:25 -04:00
d99959edae prep release 2024-03-10 00:57:11 -05:00
0e39c679e8 make pattern error opt in (#417)
* make pattern error opt in

* changelog link
2024-03-10 00:56:17 -05:00
18 changed files with 1821 additions and 4433 deletions

View File

@ -1,14 +1,18 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: npm - package-ecosystem: npm
directory: "/" directory: "/"
schedule: schedule:
interval: weekly interval: weekly
ignore: ignore:
- dependency-name: node-fetch - dependency-name: node-fetch
versions: versions:
- ">=3.0.0" - ">=3.0.0"
- package-ecosystem: github-actions commit-message:
directory: "/" prefix: "chore(deps)"
schedule: - package-ecosystem: github-actions
interval: weekly directory: "/"
schedule:
interval: weekly
commit-message:
prefix: "chore(deps)"

22
.github/release.yml vendored Normal file
View File

@ -0,0 +1,22 @@
changelog:
exclude:
labels:
- ignore-for-release
- github-actions
authors:
- octocat
- renovate[bot]
categories:
- title: Breaking Changes 🛠
labels:
- breaking-change
- title: Exciting New Features 🎉
labels:
- enhancement
- feature
- title: Bug fixes 🐛
labels:
- bug
- title: Other Changes 🔄
labels:
- "*"

View File

@ -1,14 +1,20 @@
name: Main name: main
on: [pull_request, push] on:
push:
pull_request:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-24.04
steps: steps:
# https://github.com/actions/checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Checkout
uses: actions/checkout@v4 - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version-file: ".tool-versions"
cache: "npm"
- name: Install - name: Install
run: npm ci run: npm ci
- name: Build - name: Build

1
.nvmrc
View File

@ -1 +0,0 @@
20.11.1

1
.tool-versions Normal file
View File

@ -0,0 +1 @@
nodejs 20.15.1

View File

@ -1,4 +1,39 @@
## 2.0.2 (unreleased) ## 2.0.7
### Bug fixes 🐛
* Fix missing update release body by @FirelightFlagboy in https://github.com/softprops/action-gh-release/pull/365
### Other Changes 🔄
* Bump @octokit/plugin-retry from 4.0.3 to 7.1.1 by @dependabot in https://github.com/softprops/action-gh-release/pull/443
* Bump typescript from 4.9.5 to 5.5.2 by @dependabot in https://github.com/softprops/action-gh-release/pull/467
* Bump @types/node from 20.14.6 to 20.14.8 by @dependabot in https://github.com/softprops/action-gh-release/pull/469
* Bump @types/node from 20.14.8 to 20.14.9 by @dependabot in https://github.com/softprops/action-gh-release/pull/473
* Bump typescript from 5.5.2 to 5.5.3 by @dependabot in https://github.com/softprops/action-gh-release/pull/472
* Bump ts-jest from 29.1.5 to 29.2.2 by @dependabot in https://github.com/softprops/action-gh-release/pull/479
* docs: document that existing releases are updated by @jvanbruegge in https://github.com/softprops/action-gh-release/pull/474
## 2.0.6
- maintenance release with updated dependencies
## 2.0.5
- Factor in file names with spaces when upserting files [#446](https://github.com/softprops/action-gh-release/pull/446) via [@MystiPanda](https://github.com/MystiPanda)
- Improvements to error handling [#449](https://github.com/softprops/action-gh-release/pull/449) via [@till](https://github.com/till)
## 2.0.4
- Minor follow up to [#417](https://github.com/softprops/action-gh-release/pull/417). [#425](https://github.com/softprops/action-gh-release/pull/425)
## 2.0.3
- Declare `make_latest` as an input field in `action.yml` [#419](https://github.com/softprops/action-gh-release/pull/419)
## 2.0.2
- Revisit approach to [#384](https://github.com/softprops/action-gh-release/pull/384) making unresolved pattern failures opt-in [#417](https://github.com/softprops/action-gh-release/pull/417)
## 2.0.1 ## 2.0.1

View File

@ -21,6 +21,16 @@
<br /> <br />
- [🤸 Usage](#-usage)
- [🚥 Limit releases to pushes to tags](#-limit-releases-to-pushes-to-tags)
- [⬆️ Uploading release assets](#-uploading-release-assets)
- [📝 External release notes](#-external-release-notes)
- [💅 Customizing](#-customizing)
- [inputs](#inputs)
- [outputs](#outputs)
- [environment variables](#environment-variables)
- [Permissions](#permissions)
## 🤸 Usage ## 🤸 Usage
### 🚥 Limit releases to pushes to tags ### 🚥 Limit releases to pushes to tags
@ -75,6 +85,7 @@ GitHub release and all are optional.
A common case for GitHub releases is to upload your binary after its been validated and packaged. A common case for GitHub releases is to upload your binary after its been validated and packaged.
Use the `with.files` input to declare a newline-delimited list of glob expressions matching the files Use the `with.files` input to declare a newline-delimited list of glob expressions matching the files
you wish to upload to GitHub releases. If you'd like you can just list the files by name directly. you wish to upload to GitHub releases. If you'd like you can just list the files by name directly.
If a tag already has a GitHub release, the existing release will be updated with the release assets.
Below is an example of uploading a single asset named `Release.txt` Below is an example of uploading a single asset named `Release.txt`
@ -154,11 +165,10 @@ jobs:
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
with: with:
body_path: ${{ github.workspace }}-CHANGELOG.txt body_path: ${{ github.workspace }}-CHANGELOG.txt
repository: my_gh_org/my_gh_repo
# note you'll typically need to create a personal access token # note you'll typically need to create a personal access token
# with permissions to create releases in the other repo # with permissions to create releases in the other repo
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
env:
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
``` ```
### 💅 Customizing ### 💅 Customizing
@ -183,7 +193,7 @@ The following are optional as `step.with` keys
| `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 to existing body instead of overwriting it | | `append_body` | Boolean | Append to existing body instead of overwriting it |
| `make_latest` | Boolean | Whether to mark the release as latest or not. | | `make_latest` | String | Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Can be `true`, `false`, or `legacy`. Uses GitHub api defaults if not provided |
💡 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.
@ -196,11 +206,11 @@ 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 |
| `assets` | String | JSON array containing information about each uploaded asset, in the format given [here](https://docs.github.com/en/rest/releases/assets#get-a-release-asset) (minus the `uploader` field) | | `assets` | String | JSON array containing information about each uploaded asset, in the format given [here](https://docs.github.com/en/rest/releases/assets#get-a-release-asset) (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. 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.

View File

@ -14,9 +14,9 @@ describe("util", () => {
it("strips 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}",
), ),
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets" "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets",
); );
}); });
}); });
@ -30,7 +30,7 @@ describe("util", () => {
it("parses newline and comma-delimited (and then some)", () => { it("parses newline and comma-delimited (and then some)", () => {
assert.deepStrictEqual( assert.deepStrictEqual(
parseInputFiles("foo,bar\nbaz,boom,\n\ndoom,loom "), parseInputFiles("foo,bar\nbaz,boom,\n\ndoom,loom "),
["foo", "bar", "baz", "boom", "doom", "loom"] ["foo", "bar", "baz", "boom", "doom", "loom"],
); );
}); });
}); });
@ -53,7 +53,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
}) }),
); );
}); });
it("uses input body path", () => { it("uses input body path", () => {
@ -74,7 +74,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
}) }),
); );
}); });
it("defaults to body path when both body and body path are provided", () => { it("defaults to body path when both body and body path are provided", () => {
@ -95,7 +95,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
}) }),
); );
}); });
}); });
@ -129,7 +129,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
@ -155,7 +155,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
it("supports discussion category names", () => { it("supports discussion category names", () => {
@ -180,7 +180,7 @@ describe("util", () => {
input_discussion_category_name: "releases", input_discussion_category_name: "releases",
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
@ -206,7 +206,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: true, input_generate_release_notes: true,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
@ -235,7 +235,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
it("uses input token as the source of GITHUB_TOKEN by default", () => { it("uses input token as the source of GITHUB_TOKEN by default", () => {
@ -262,7 +262,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
it("parses basic config with draft and prerelease", () => { it("parses basic config with draft and prerelease", () => {
@ -288,7 +288,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
it("parses basic config where make_latest is passed", () => { it("parses basic config where make_latest is passed", () => {
@ -313,7 +313,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: "false", input_make_latest: "false",
} },
); );
}); });
it("parses basic config with append_body", () => { it("parses basic config with append_body", () => {
@ -338,7 +338,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
}); });
@ -355,7 +355,7 @@ describe("util", () => {
it("resolves files given a set of paths", async () => { it("resolves files given a set of paths", async () => {
assert.deepStrictEqual( assert.deepStrictEqual(
paths(["tests/data/**/*", "tests/data/does/not/exist/*"]), paths(["tests/data/**/*", "tests/data/does/not/exist/*"]),
["tests/data/foo/bar.txt"] ["tests/data/foo/bar.txt"],
); );
}); });
}); });
@ -364,7 +364,7 @@ describe("util", () => {
it("returns the patterns that don't match any files", async () => { it("returns the patterns that don't match any files", async () => {
assert.deepStrictEqual( assert.deepStrictEqual(
unmatchedPatterns(["tests/data/**/*", "tests/data/does/not/exist/*"]), unmatchedPatterns(["tests/data/**/*", "tests/data/does/not/exist/*"]),
["tests/data/does/not/exist/*"] ["tests/data/does/not/exist/*"],
); );
}); });
}); });

View File

@ -46,8 +46,11 @@ inputs:
append_body: append_body:
description: "Append to existing body instead of overwriting it. Default is false." description: "Append to existing body instead of overwriting it. Default is false."
required: false required: false
make_latest:
description: "Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Can be `true`, `false`, or `legacy`. Uses GitHub api default if not provided"
required: false
env: env:
"GITHUB_TOKEN": "As provided by Github Actions" GITHUB_TOKEN: "As provided by Github Actions"
outputs: outputs:
url: url:
description: "URL to the Release HTML Page" description: "URL to the Release HTML Page"

6
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,11 +0,0 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

16
jest.config.ts Normal file
View File

@ -0,0 +1,16 @@
import type { JestConfigWithTsJest } from 'ts-jest';
const config: JestConfigWithTsJest = {
preset: 'ts-jest/presets/default-esm',
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest',
},
verbose: true,
};
export default config;

5798
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,16 @@
{ {
"name": "action-gh-release", "name": "action-gh-release",
"version": "0.1.15", "version": "2.0.6",
"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",
"scripts": { "scripts": {
"build": "ncc build src/main.ts --minify", "build": "ncc build src/main.ts --minify",
"build-debug": "ncc build src/main.ts --v8-cache --source-map",
"test": "jest", "test": "jest",
"fmt": "prettier --write \"src/**/*.ts\" \"__tests__/**/*.ts\"", "fmt": "prettier --write \"src/**/*.ts\" \"__tests__/**/*.ts\"",
"fmtcheck": "prettier --check \"src/**/*.ts\" \"__tests__/**/*.ts\"" "fmtcheck": "prettier --check \"src/**/*.ts\" \"__tests__/**/*.ts\"",
"updatetag": "git tag -d v2 && git push origin :v2 && git tag -a v2 -m '' && git push origin v2"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -21,22 +23,23 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.0",
"@actions/github": "^5.1.1", "@actions/github": "^5.1.1",
"@octokit/plugin-retry": "^4.0.3", "@octokit/plugin-retry": "^7.1.1",
"@octokit/plugin-throttling": "^4.3.2", "@octokit/plugin-throttling": "^9.3.1",
"glob": "^8.0.3", "glob": "^11.0.0",
"mime": "^3.0.0" "mime": "^4.0.4"
}, },
"devDependencies": { "devDependencies": {
"@types/glob": "^8.0.0", "@types/glob": "^8.1.0",
"@types/jest": "^29.2.3", "@types/jest": "^29.5.12",
"@types/mime": "^3.0.1", "@types/mime": "^4.0.0",
"@types/node": "^18.11.9", "@types/node": "^20.14.11",
"@vercel/ncc": "^0.34.0", "@vercel/ncc": "^0.38.1",
"jest": "^29.3.1", "jest": "^29.3.1",
"jest-circus": "^29.3.1", "jest-circus": "^29.3.1",
"prettier": "2.8.0", "prettier": "3.3.3",
"ts-jest": "^29.0.3", "ts-jest": "^29.2.3",
"typescript": "^4.9.3", "ts-node": "^10.9.2",
"typescript": "^5.5.3",
"typescript-formatter": "^7.2.2" "typescript-formatter": "^7.2.2"
} }
} }

View File

@ -1,7 +1,7 @@
import { GitHub } from "@actions/github/lib/utils"; import { GitHub } from "@actions/github/lib/utils";
import { Config, isTag, releaseBody } from "./util"; import { Config, isTag, releaseBody } from "./util";
import { statSync, readFileSync } from "fs"; import { statSync, readFileSync } from "fs";
import { getType } from "mime"; import mime from "mime";
import { basename } from "path"; import { basename } from "path";
type GitHub = InstanceType<typeof GitHub>; type GitHub = InstanceType<typeof GitHub>;
@ -121,7 +121,7 @@ export class GitHubReleaser implements Releaser {
}): AsyncIterableIterator<{ data: Release[] }> { }): AsyncIterableIterator<{ data: Release[] }> {
const updatedParams = { per_page: 100, ...params }; const updatedParams = { per_page: 100, ...params };
return this.github.paginate.iterator( return this.github.paginate.iterator(
this.github.rest.repos.listReleases.endpoint.merge(updatedParams) this.github.rest.repos.listReleases.endpoint.merge(updatedParams),
); );
} }
} }
@ -136,7 +136,7 @@ export const asset = (path: string): ReleaseAsset => {
}; };
export const mimeOrDefault = (path: string): string => { export const mimeOrDefault = (path: string): string => {
return getType(path) || "application/octet-stream"; return mime.getType(path) || "application/octet-stream";
}; };
export const upload = async ( export const upload = async (
@ -144,12 +144,15 @@ export const upload = async (
github: GitHub, github: GitHub,
url: string, url: string,
path: string, path: string,
currentAssets: Array<{ id: number; name: string }> currentAssets: Array<{ id: number; name: string }>,
): Promise<any> => { ): Promise<any> => {
const [owner, repo] = config.github_repository.split("/"); const [owner, repo] = config.github_repository.split("/");
const { name, size, mime, data: body } = asset(path); const { name, size, mime, data: body } = asset(path);
const currentAsset = currentAssets.find( const currentAsset = currentAssets.find(
({ name: currentName }) => currentName == name // note: GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "List release assets" endpoint lists the renamed filenames.
// due to this renaming we need to be mindful when we compare the file name we're uploading with a name github may already have rewritten for logical comparison
// see https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset
({ name: currentName }) => currentName == name.replace(" ", "."),
); );
if (currentAsset) { if (currentAsset) {
console.log(`♻️ Deleting previously uploaded asset ${name}...`); console.log(`♻️ Deleting previously uploaded asset ${name}...`);
@ -177,7 +180,7 @@ export const upload = async (
throw new Error( throw new Error(
`Failed to upload release asset ${name}. received 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)}`,
); );
} }
return json; return json;
@ -186,7 +189,7 @@ export const upload = async (
export const release = async ( export const release = async (
config: Config, config: Config,
releaser: Releaser, releaser: Releaser,
maxRetries: number = 3 maxRetries: number = 3,
): Promise<Release> => { ): Promise<Release> => {
if (maxRetries <= 0) { if (maxRetries <= 0) {
console.log(`❌ Too many retries. Aborting...`); console.log(`❌ Too many retries. Aborting...`);
@ -205,45 +208,63 @@ export const release = async (
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
let _release: Release | undefined = undefined;
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); _release = response.data.find((release) => release.tag_name === tag);
if (release) {
return release;
}
} }
} else {
_release = (
await releaser.getReleaseByTag({
owner,
repo,
tag,
})
).data;
}
if (_release === null || _release === undefined) {
return await createRelease(
tag,
config,
releaser,
owner,
repo,
discussion_category_name,
generate_release_notes,
maxRetries,
);
} }
let existingRelease = await releaser.getReleaseByTag({
owner,
repo,
tag,
});
const release_id = existingRelease.data.id; let existingRelease: Release = _release!;
console.log(
`Found release ${existingRelease.name} (with id=${existingRelease.id})`,
);
const release_id = existingRelease.id;
let target_commitish: string; let target_commitish: string;
if ( if (
config.input_target_commitish && config.input_target_commitish &&
config.input_target_commitish !== existingRelease.data.target_commitish config.input_target_commitish !== existingRelease.target_commitish
) { ) {
console.log( console.log(
`Updating commit from "${existingRelease.data.target_commitish}" to "${config.input_target_commitish}"` `Updating commit from "${existingRelease.target_commitish}" to "${config.input_target_commitish}"`,
); );
target_commitish = config.input_target_commitish; target_commitish = config.input_target_commitish;
} else { } else {
target_commitish = existingRelease.data.target_commitish; target_commitish = existingRelease.target_commitish;
} }
const tag_name = tag; const tag_name = tag;
const name = config.input_name || existingRelease.data.name || tag; const name = config.input_name || existingRelease.name || tag;
// revisit: support a new body-concat-strategy input for accumulating // revisit: support a new body-concat-strategy input for accumulating
// 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
const workflowBody = releaseBody(config) || ""; const workflowBody = releaseBody(config) || "";
const existingReleaseBody = existingRelease.data.body || ""; const existingReleaseBody = existingRelease.body || "";
let body: string; let body: string;
if (config.input_append_body && workflowBody && existingReleaseBody) { if (config.input_append_body && workflowBody && existingReleaseBody) {
body = existingReleaseBody + "\n" + workflowBody; body = existingReleaseBody + "\n" + workflowBody;
@ -254,11 +275,11 @@ export const release = async (
const draft = const draft =
config.input_draft !== undefined config.input_draft !== undefined
? config.input_draft ? config.input_draft
: existingRelease.data.draft; : existingRelease.draft;
const prerelease = const prerelease =
config.input_prerelease !== undefined config.input_prerelease !== undefined
? config.input_prerelease ? config.input_prerelease
: existingRelease.data.prerelease; : existingRelease.prerelease;
const make_latest = config.input_make_latest; const make_latest = config.input_make_latest;
@ -278,52 +299,87 @@ export const release = async (
}); });
return release.data; return release.data;
} catch (error) { } catch (error) {
if (error.status === 404) { if (error.status !== 404) {
const tag_name = tag;
const name = config.input_name || tag;
const body = releaseBody(config);
const draft = config.input_draft;
const prerelease = config.input_prerelease;
const target_commitish = config.input_target_commitish;
const make_latest = config.input_make_latest;
let commitMessage: string = "";
if (target_commitish) {
commitMessage = ` using commit "${target_commitish}"`;
}
console.log( console.log(
`👩‍🏭 Creating new GitHub release for tag ${tag_name}${commitMessage}...` `⚠️ Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}`,
);
try {
let release = await releaser.createRelease({
owner,
repo,
tag_name,
name,
body,
draft,
prerelease,
target_commitish,
discussion_category_name,
generate_release_notes,
make_latest,
});
return release.data;
} catch (error) {
// presume a race with competing metrix runs
console.log(
`⚠️ GitHub release failed with status: ${
error.status
}\n${JSON.stringify(error.response.data.errors)}\nretrying... (${
maxRetries - 1
} retries remaining)`
);
return release(config, releaser, maxRetries - 1);
}
} else {
console.log(
`⚠️ Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}`
); );
throw error; throw error;
} }
return await createRelease(
tag,
config,
releaser,
owner,
repo,
discussion_category_name,
generate_release_notes,
maxRetries,
);
} }
}; };
async function createRelease(
tag: string,
config: Config,
releaser: Releaser,
owner: string,
repo: string,
discussion_category_name: string | undefined,
generate_release_notes: boolean | undefined,
maxRetries: number,
) {
const tag_name = tag;
const name = config.input_name || tag;
const body = releaseBody(config);
const draft = config.input_draft;
const prerelease = config.input_prerelease;
const target_commitish = config.input_target_commitish;
const make_latest = config.input_make_latest;
let commitMessage: string = "";
if (target_commitish) {
commitMessage = ` using commit "${target_commitish}"`;
}
console.log(
`👩‍🏭 Creating new GitHub release for tag ${tag_name}${commitMessage}...`,
);
try {
let release = await releaser.createRelease({
owner,
repo,
tag_name,
name,
body,
draft,
prerelease,
target_commitish,
discussion_category_name,
generate_release_notes,
make_latest,
});
return release.data;
} catch (error) {
// presume a race with competing matrix runs
console.log(`⚠️ GitHub release failed with status: ${error.status}`);
console.log(`${JSON.stringify(error.response.data)}`);
switch (error.status) {
case 403:
console.log(
"Skip retry — your GitHub token/PAT does not have the required permission to create a release",
);
throw error;
case 404:
console.log("Skip retry - discussion category mismatch");
throw error;
case 422:
console.log("Skip retry - validation failed");
throw error;
}
console.log(`retrying... (${maxRetries - 1} retries remaining)`);
return release(config, releaser, maxRetries - 1);
}
}

View File

@ -25,7 +25,11 @@ async function run() {
if (config.input_files) { if (config.input_files) {
const patterns = unmatchedPatterns(config.input_files); const patterns = unmatchedPatterns(config.input_files);
patterns.forEach((pattern) => { patterns.forEach((pattern) => {
throw new Error(`⚠️ Pattern '${pattern}' does not match any files.`); if (config.input_fail_on_unmatched_files) {
throw new Error(`⚠️ Pattern '${pattern}' does not match any files.`);
} else {
console.warn(`🤔 Pattern '${pattern}' does not match any files.`);
}
}); });
if (patterns.length > 0 && config.input_fail_on_unmatched_files) { if (patterns.length > 0 && config.input_fail_on_unmatched_files) {
throw new Error(`⚠️ There were unmatched files`); throw new Error(`⚠️ There were unmatched files`);
@ -42,7 +46,7 @@ async function run() {
throttle: { throttle: {
onRateLimit: (retryAfter, options) => { onRateLimit: (retryAfter, options) => {
console.warn( console.warn(
`Request quota exhausted for request ${options.method} ${options.url}` `Request quota exhausted for request ${options.method} ${options.url}`,
); );
if (options.request.retryCount === 0) { if (options.request.retryCount === 0) {
// only retries once // only retries once
@ -53,7 +57,7 @@ async function run() {
onAbuseLimit: (retryAfter, options) => { onAbuseLimit: (retryAfter, options) => {
// does not retry, only logs a warning // does not retry, only logs a warning
console.warn( console.warn(
`Abuse detected for request ${options.method} ${options.url}` `Abuse detected for request ${options.method} ${options.url}`,
); );
}, },
}, },
@ -63,7 +67,11 @@ async function run() {
if (config.input_files && config.input_files.length > 0) { if (config.input_files && config.input_files.length > 0) {
const files = paths(config.input_files); const files = paths(config.input_files);
if (files.length == 0) { if (files.length == 0) {
throw new Error(`⚠️ ${config.input_files} not include valid file.`); if (config.input_fail_on_unmatched_files) {
throw new Error(`⚠️ ${config.input_files} not include valid file.`);
} else {
console.warn(`🤔 ${config.input_files} not include valid file.`);
}
} }
const currentAssets = rel.assets; const currentAssets = rel.assets;
const assets = await Promise.all( const assets = await Promise.all(
@ -73,11 +81,11 @@ async function run() {
gh, gh,
uploadUrl(rel.upload_url), uploadUrl(rel.upload_url),
path, path,
currentAssets currentAssets,
); );
delete json.uploader; delete json.uploader;
return json; return json;
}) }),
).catch((error) => { ).catch((error) => {
throw error; throw error;
}); });

View File

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

View File

@ -60,5 +60,5 @@
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}, },
"exclude": ["node_modules", "**/*.test.ts"] "exclude": ["node_modules", "**/*.test.ts", "jest.config.ts"]
} }