Compare commits

...

24 Commits

Author SHA1 Message Date
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
9 changed files with 1462 additions and 4332 deletions

2
.nvmrc
View File

@ -1 +1 @@
20.11.1
20.14.0

View File

@ -1,4 +1,23 @@
## 2.0.2 (unreleased)
## 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

View File

@ -154,11 +154,10 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: ${{ github.workspace }}-CHANGELOG.txt
repository: my_gh_org/my_gh_repo
# note you'll typically need to create a personal access token
# with permissions to create releases in the other repo
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
env:
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
```
### 💅 Customizing
@ -183,7 +182,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) |
| `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 |
| `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
attempted first, then falling back on `body` if the path can not be read from.
@ -196,11 +195,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/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.

View File

@ -46,6 +46,9 @@ inputs:
append_body:
description: "Append to existing body instead of overwriting it. Default is 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:
"GITHUB_TOKEN": "As provided by Github Actions"
outputs:

6
dist/index.js vendored

File diff suppressed because one or more lines are too long

5614
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "action-gh-release",
"version": "0.1.15",
"version": "2.0.6",
"private": true,
"description": "GitHub Action for creating GitHub Releases",
"main": "lib/main.js",
@ -8,7 +8,8 @@
"build": "ncc build src/main.ts --minify",
"test": "jest",
"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": {
"type": "git",
@ -22,20 +23,20 @@
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@octokit/plugin-retry": "^4.0.3",
"@octokit/plugin-throttling": "^4.3.2",
"glob": "^8.0.3",
"@octokit/plugin-throttling": "^9.3.0",
"glob": "^10.4.2",
"mime": "^3.0.0"
},
"devDependencies": {
"@types/glob": "^8.0.0",
"@types/jest": "^29.2.3",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.12",
"@types/mime": "^3.0.1",
"@types/node": "^18.11.9",
"@vercel/ncc": "^0.34.0",
"@types/node": "^20.14.6",
"@vercel/ncc": "^0.38.1",
"jest": "^29.3.1",
"jest-circus": "^29.3.1",
"prettier": "2.8.0",
"ts-jest": "^29.0.3",
"ts-jest": "^29.1.4",
"typescript": "^4.9.3",
"typescript-formatter": "^7.2.2"
}

View File

@ -149,7 +149,10 @@ export const upload = async (
const [owner, repo] = config.github_repository.split("/");
const { name, size, mime, data: body } = asset(path);
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) {
console.log(`♻️ Deleting previously uploaded asset ${name}...`);
@ -278,52 +281,65 @@ export const release = async (
});
return release.data;
} catch (error) {
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(
`👩‍🏭 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 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 {
if (error.status !== 404) {
console.log(
`⚠️ Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}`
);
throw error;
}
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) {
const patterns = unmatchedPatterns(config.input_files);
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) {
throw new Error(`⚠️ There were unmatched files`);
@ -63,7 +67,11 @@ async function run() {
if (config.input_files && config.input_files.length > 0) {
const files = paths(config.input_files);
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 assets = await Promise.all(