Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
c95fe14893 | |||
deddb09c64 | |||
33fcd69d45 | |||
01050bd877 | |||
92dffe6c28 | |||
7b4da11513 | |||
64f1fa19ef | |||
9e35a64dfd | |||
92bc83c421 | |||
09f0e37203 | |||
f138a07409 | |||
39a5683760 | |||
62368ac126 | |||
181b5bc7bb | |||
3284404123 | |||
01570a1f39 | |||
d5f028c822 | |||
98daca21d1 | |||
b019a5bbb6 | |||
73e673b2de |
46
CHANGELOG.md
46
CHANGELOG.md
@ -1,3 +1,49 @@
|
|||||||
|
## 2.2.1
|
||||||
|
|
||||||
|
## What's Changed
|
||||||
|
|
||||||
|
### Bug fixes 🐛
|
||||||
|
|
||||||
|
* fix: big file uploads by @xen0n in https://github.com/softprops/action-gh-release/pull/562
|
||||||
|
|
||||||
|
### Other Changes 🔄
|
||||||
|
* chore(deps): bump @types/node from 22.10.1 to 22.10.2 by @dependabot in https://github.com/softprops/action-gh-release/pull/559
|
||||||
|
* chore(deps): bump @types/node from 22.10.2 to 22.10.5 by @dependabot in https://github.com/softprops/action-gh-release/pull/569
|
||||||
|
* chore: update error and warning messages for not matching files in files field by @ytimocin in https://github.com/softprops/action-gh-release/pull/568
|
||||||
|
|
||||||
|
## 2.2.0
|
||||||
|
|
||||||
|
## What's Changed
|
||||||
|
|
||||||
|
### Exciting New Features 🎉
|
||||||
|
|
||||||
|
* feat: read the release assets asynchronously by @xen0n in https://github.com/softprops/action-gh-release/pull/552
|
||||||
|
|
||||||
|
### Bug fixes 🐛
|
||||||
|
|
||||||
|
* fix(docs): clarify the default for tag_name by @alexeagle in https://github.com/softprops/action-gh-release/pull/544
|
||||||
|
|
||||||
|
### Other Changes 🔄
|
||||||
|
|
||||||
|
* chore(deps): bump typescript from 5.6.3 to 5.7.2 by @dependabot in https://github.com/softprops/action-gh-release/pull/548
|
||||||
|
* chore(deps): bump @types/node from 22.9.0 to 22.9.4 by @dependabot in https://github.com/softprops/action-gh-release/pull/547
|
||||||
|
* chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 by @dependabot in https://github.com/softprops/action-gh-release/pull/545
|
||||||
|
* chore(deps): bump @vercel/ncc from 0.38.2 to 0.38.3 by @dependabot in https://github.com/softprops/action-gh-release/pull/543
|
||||||
|
* chore(deps): bump prettier from 3.3.3 to 3.4.1 by @dependabot in https://github.com/softprops/action-gh-release/pull/550
|
||||||
|
* chore(deps): bump @types/node from 22.9.4 to 22.10.1 by @dependabot in https://github.com/softprops/action-gh-release/pull/551
|
||||||
|
* chore(deps): bump prettier from 3.4.1 to 3.4.2 by @dependabot in https://github.com/softprops/action-gh-release/pull/554
|
||||||
|
|
||||||
|
## 2.1.0
|
||||||
|
|
||||||
|
## What's Changed
|
||||||
|
|
||||||
|
### Exciting New Features 🎉
|
||||||
|
* feat: add support for release assets with multiple spaces within the name by @dukhine in https://github.com/softprops/action-gh-release/pull/518
|
||||||
|
* feat: preserve upload order by @richarddd in https://github.com/softprops/action-gh-release/pull/500
|
||||||
|
|
||||||
|
### Other Changes 🔄
|
||||||
|
* chore(deps): bump @types/node from 22.8.2 to 22.8.7 by @dependabot in https://github.com/softprops/action-gh-release/pull/539
|
||||||
|
|
||||||
## 2.0.9
|
## 2.0.9
|
||||||
|
|
||||||
- maintenance release with updated dependencies
|
- maintenance release with updated dependencies
|
||||||
|
@ -183,9 +183,10 @@ The following are optional as `step.with` keys
|
|||||||
| `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 |
|
||||||
|
| `preserve_order` | Boolean | Indicator of whether order of files should be preserved when uploading assets |
|
||||||
| `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_name` |
|
||||||
| `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. 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. |
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
//import * as assert from "assert";
|
|
||||||
//const assert = require('assert');
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
import { text } from "stream/consumers";
|
||||||
import { mimeOrDefault, asset } from "../src/github";
|
import { mimeOrDefault, asset } from "../src/github";
|
||||||
|
|
||||||
describe("github", () => {
|
describe("github", () => {
|
||||||
@ -15,11 +14,10 @@ describe("github", () => {
|
|||||||
|
|
||||||
describe("asset", () => {
|
describe("asset", () => {
|
||||||
it("derives asset info from a path", async () => {
|
it("derives asset info from a path", async () => {
|
||||||
const { name, mime, size, data } = asset("tests/data/foo/bar.txt");
|
const { name, mime, size } = asset("tests/data/foo/bar.txt");
|
||||||
assert.equal(name, "bar.txt");
|
assert.equal(name, "bar.txt");
|
||||||
assert.equal(mime, "text/plain");
|
assert.equal(mime, "text/plain");
|
||||||
assert.equal(size, 10);
|
assert.equal(size, 10);
|
||||||
assert.equal(data.toString(), "release me");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
parseInputFiles,
|
parseInputFiles,
|
||||||
unmatchedPatterns,
|
unmatchedPatterns,
|
||||||
uploadUrl,
|
uploadUrl,
|
||||||
|
alignAssetName,
|
||||||
} from "../src/util";
|
} from "../src/util";
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ describe("util", () => {
|
|||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -67,6 +69,7 @@ describe("util", () => {
|
|||||||
input_body_path: "__tests__/release.txt",
|
input_body_path: "__tests__/release.txt",
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -88,6 +91,7 @@ describe("util", () => {
|
|||||||
input_body_path: "__tests__/release.txt",
|
input_body_path: "__tests__/release.txt",
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -121,6 +125,7 @@ describe("util", () => {
|
|||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -148,6 +153,7 @@ describe("util", () => {
|
|||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
@ -173,6 +179,7 @@ describe("util", () => {
|
|||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false,
|
input_fail_on_unmatched_files: false,
|
||||||
@ -198,6 +205,7 @@ describe("util", () => {
|
|||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -215,6 +223,7 @@ describe("util", () => {
|
|||||||
parseConfig({
|
parseConfig({
|
||||||
INPUT_DRAFT: "false",
|
INPUT_DRAFT: "false",
|
||||||
INPUT_PRERELEASE: "true",
|
INPUT_PRERELEASE: "true",
|
||||||
|
INPUT_PRESERVE_ORDER: "true",
|
||||||
GITHUB_TOKEN: "env-token",
|
GITHUB_TOKEN: "env-token",
|
||||||
INPUT_TOKEN: "input-token",
|
INPUT_TOKEN: "input-token",
|
||||||
}),
|
}),
|
||||||
@ -227,6 +236,7 @@ describe("util", () => {
|
|||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: true,
|
input_prerelease: true,
|
||||||
|
input_preserve_order: true,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -254,6 +264,7 @@ describe("util", () => {
|
|||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: true,
|
input_prerelease: true,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -280,6 +291,7 @@ describe("util", () => {
|
|||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: true,
|
input_prerelease: true,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -305,6 +317,7 @@ describe("util", () => {
|
|||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -330,6 +343,7 @@ describe("util", () => {
|
|||||||
input_body_path: undefined,
|
input_body_path: undefined,
|
||||||
input_draft: undefined,
|
input_draft: undefined,
|
||||||
input_prerelease: undefined,
|
input_prerelease: undefined,
|
||||||
|
input_preserve_order: undefined,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
@ -368,4 +382,20 @@ describe("util", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("replaceSpacesWithDots", () => {
|
||||||
|
it("replaces all spaces with dots", () => {
|
||||||
|
expect(alignAssetName("John Doe.bla")).toBe("John.Doe.bla");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("handles names with multiple spaces", () => {
|
||||||
|
expect(alignAssetName("John William Doe.bla")).toBe(
|
||||||
|
"John.William.Doe.bla",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns the same string if there are no spaces", () => {
|
||||||
|
expect(alignAssetName("JohnDoe")).toBe("JohnDoe");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,6 +21,9 @@ inputs:
|
|||||||
prerelease:
|
prerelease:
|
||||||
description: "Identify the release as a prerelease. Defaults to false"
|
description: "Identify the release as a prerelease. Defaults to false"
|
||||||
required: false
|
required: false
|
||||||
|
preserve_order:
|
||||||
|
description: "Preserver the order of the artifacts when uploading"
|
||||||
|
required: false
|
||||||
files:
|
files:
|
||||||
description: "Newline-delimited list of path globs for asset files to upload"
|
description: "Newline-delimited list of path globs for asset files to upload"
|
||||||
required: false
|
required: false
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
50
package-lock.json
generated
50
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "2.0.9",
|
"version": "2.2.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "2.0.9",
|
"version": "2.2.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.11.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/github": "^6.0.0",
|
"@actions/github": "^6.0.0",
|
||||||
@ -19,14 +19,14 @@
|
|||||||
"@types/glob": "^8.1.0",
|
"@types/glob": "^8.1.0",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/mime": "^3.0.1",
|
"@types/mime": "^3.0.1",
|
||||||
"@types/node": "^22.8.2",
|
"@types/node": "^22.10.5",
|
||||||
"@vercel/ncc": "^0.38.2",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"jest": "^29.3.1",
|
"jest": "^29.3.1",
|
||||||
"jest-circus": "^29.3.1",
|
"jest-circus": "^29.3.1",
|
||||||
"prettier": "3.3.3",
|
"prettier": "3.4.2",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.7.2",
|
||||||
"typescript-formatter": "^7.2.2"
|
"typescript-formatter": "^7.2.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1598,12 +1598,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "22.8.2",
|
"version": "22.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz",
|
||||||
"integrity": "sha512-NzaRNFV+FZkvK/KLCsNdTvID0SThyrs5SHB6tsD/lajr22FGC73N2QeDPM2wHtVde8mgcXuSsHQkH5cX1pbPLw==",
|
"integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.19.8"
|
"undici-types": "~6.20.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/stack-utils": {
|
"node_modules/@types/stack-utils": {
|
||||||
@ -1628,9 +1628,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@vercel/ncc": {
|
"node_modules/@vercel/ncc": {
|
||||||
"version": "0.38.2",
|
"version": "0.38.3",
|
||||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.2.tgz",
|
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.3.tgz",
|
||||||
"integrity": "sha512-3yel3jaxUg9pHBv4+KeC9qlbdZPug+UMtUOlhvpDYCMSgcNSrS2Hv1LoqMsOV7hf2lYscx+BESfJOIla1WsmMQ==",
|
"integrity": "sha512-rnK6hJBS6mwc+Bkab+PGPs9OiS0i/3kdTO+CkI8V0/VrW3vmz7O2Pxjw/owOlmo6PKEIxRSeZKv/kuL9itnpYA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"ncc": "dist/ncc/cli.js"
|
"ncc": "dist/ncc/cli.js"
|
||||||
@ -2114,9 +2114,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
"shebang-command": "^2.0.0",
|
"shebang-command": "^2.0.0",
|
||||||
@ -3931,9 +3931,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "3.3.3",
|
"version": "3.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.2.tgz",
|
||||||
"integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==",
|
"integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"prettier": "bin/prettier.cjs"
|
"prettier": "bin/prettier.cjs"
|
||||||
@ -4494,9 +4494,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.6.3",
|
"version": "5.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
|
||||||
"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
|
"integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
@ -4537,9 +4537,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "6.19.8",
|
"version": "6.20.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||||
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
|
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/universal-user-agent": {
|
"node_modules/universal-user-agent": {
|
||||||
|
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "2.0.9",
|
"version": "2.2.1",
|
||||||
"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",
|
||||||
@ -32,14 +32,14 @@
|
|||||||
"@types/glob": "^8.1.0",
|
"@types/glob": "^8.1.0",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/mime": "^3.0.1",
|
"@types/mime": "^3.0.1",
|
||||||
"@types/node": "^22.8.2",
|
"@types/node": "^22.10.5",
|
||||||
"@vercel/ncc": "^0.38.2",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"jest": "^29.3.1",
|
"jest": "^29.3.1",
|
||||||
"jest-circus": "^29.3.1",
|
"jest-circus": "^29.3.1",
|
||||||
"prettier": "3.3.3",
|
"prettier": "3.4.2",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.7.2",
|
||||||
"typescript-formatter": "^7.2.2"
|
"typescript-formatter": "^7.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +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, alignAssetName } from "./util";
|
||||||
import { statSync, readFileSync } from "fs";
|
import { statSync } from "fs";
|
||||||
|
import { open } from "fs/promises";
|
||||||
import { getType } from "mime";
|
import { getType } from "mime";
|
||||||
import { basename } from "path";
|
import { basename } from "path";
|
||||||
|
|
||||||
@ -10,7 +11,6 @@ export interface ReleaseAsset {
|
|||||||
name: string;
|
name: string;
|
||||||
mime: string;
|
mime: string;
|
||||||
size: number;
|
size: number;
|
||||||
data: Buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Release {
|
export interface Release {
|
||||||
@ -145,7 +145,6 @@ export const asset = (path: string): ReleaseAsset => {
|
|||||||
name: basename(path),
|
name: basename(path),
|
||||||
mime: mimeOrDefault(path),
|
mime: mimeOrDefault(path),
|
||||||
size: statSync(path).size,
|
size: statSync(path).size,
|
||||||
data: readFileSync(path),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -161,12 +160,12 @@ export const upload = async (
|
|||||||
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, mime, size } = asset(path);
|
||||||
const currentAsset = currentAssets.find(
|
const currentAsset = currentAssets.find(
|
||||||
// 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.
|
// 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
|
// 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
|
// see https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset
|
||||||
({ name: currentName }) => currentName == name.replace(" ", "."),
|
({ name: currentName }) => currentName == alignAssetName(name),
|
||||||
);
|
);
|
||||||
if (currentAsset) {
|
if (currentAsset) {
|
||||||
console.log(`♻️ Deleting previously uploaded asset ${name}...`);
|
console.log(`♻️ Deleting previously uploaded asset ${name}...`);
|
||||||
@ -179,25 +178,31 @@ export const upload = async (
|
|||||||
console.log(`⬆️ Uploading ${name}...`);
|
console.log(`⬆️ Uploading ${name}...`);
|
||||||
const endpoint = new URL(url);
|
const endpoint = new URL(url);
|
||||||
endpoint.searchParams.append("name", name);
|
endpoint.searchParams.append("name", name);
|
||||||
const resp = await github.request({
|
const fh = await open(path);
|
||||||
method: "POST",
|
try {
|
||||||
url: endpoint.toString(),
|
const resp = await github.request({
|
||||||
headers: {
|
method: "POST",
|
||||||
"content-length": `${size}`,
|
url: endpoint.toString(),
|
||||||
"content-type": mime,
|
headers: {
|
||||||
authorization: `token ${config.github_token}`,
|
"content-length": `${size}`,
|
||||||
},
|
"content-type": mime,
|
||||||
data: body,
|
authorization: `token ${config.github_token}`,
|
||||||
});
|
},
|
||||||
const json = resp.data;
|
data: fh.readableWebStream({ type: "bytes" }),
|
||||||
if (resp.status !== 201) {
|
});
|
||||||
throw new Error(
|
const json = resp.data;
|
||||||
`Failed to upload release asset ${name}. received status code ${
|
if (resp.status !== 201) {
|
||||||
resp.status
|
throw new Error(
|
||||||
}\n${json.message}\n${JSON.stringify(json.errors)}`,
|
`Failed to upload release asset ${name}. received status code ${
|
||||||
);
|
resp.status
|
||||||
|
}\n${json.message}\n${JSON.stringify(json.errors)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
console.log(`✅ Uploaded ${name}`);
|
||||||
|
return json;
|
||||||
|
} finally {
|
||||||
|
await fh.close();
|
||||||
}
|
}
|
||||||
return json;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const release = async (
|
export const release = async (
|
||||||
|
41
src/main.ts
41
src/main.ts
@ -67,27 +67,34 @@ async function run() {
|
|||||||
const files = paths(config.input_files);
|
const files = paths(config.input_files);
|
||||||
if (files.length == 0) {
|
if (files.length == 0) {
|
||||||
if (config.input_fail_on_unmatched_files) {
|
if (config.input_fail_on_unmatched_files) {
|
||||||
throw new Error(`⚠️ ${config.input_files} not include valid file.`);
|
throw new Error(`⚠️ ${config.input_files} does not include a valid file.`);
|
||||||
} else {
|
} else {
|
||||||
console.warn(`🤔 ${config.input_files} not include valid file.`);
|
console.warn(`🤔 ${config.input_files} does not include a valid file.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const currentAssets = rel.assets;
|
const currentAssets = rel.assets;
|
||||||
const assets = await Promise.all(
|
|
||||||
files.map(async (path) => {
|
const uploadFile = async (path) => {
|
||||||
const json = await upload(
|
const json = await upload(
|
||||||
config,
|
config,
|
||||||
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) => {
|
|
||||||
throw error;
|
let assets;
|
||||||
});
|
if (!config.input_preserve_order) {
|
||||||
|
assets = await Promise.all(files.map(uploadFile));
|
||||||
|
} else {
|
||||||
|
assets = [];
|
||||||
|
for (const path of files) {
|
||||||
|
assets.push(await uploadFile(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
setOutput("assets", assets);
|
setOutput("assets", assets);
|
||||||
}
|
}
|
||||||
console.log(`🎉 Release ready at ${rel.html_url}`);
|
console.log(`🎉 Release ready at ${rel.html_url}`);
|
||||||
|
@ -13,6 +13,7 @@ export interface Config {
|
|||||||
input_body_path?: string;
|
input_body_path?: string;
|
||||||
input_files?: string[];
|
input_files?: string[];
|
||||||
input_draft?: boolean;
|
input_draft?: boolean;
|
||||||
|
input_preserve_order?: boolean;
|
||||||
input_prerelease?: boolean;
|
input_prerelease?: boolean;
|
||||||
input_fail_on_unmatched_files?: boolean;
|
input_fail_on_unmatched_files?: boolean;
|
||||||
input_target_commitish?: string;
|
input_target_commitish?: string;
|
||||||
@ -62,6 +63,9 @@ export const parseConfig = (env: Env): Config => {
|
|||||||
input_body_path: env.INPUT_BODY_PATH,
|
input_body_path: env.INPUT_BODY_PATH,
|
||||||
input_files: parseInputFiles(env.INPUT_FILES || ""),
|
input_files: parseInputFiles(env.INPUT_FILES || ""),
|
||||||
input_draft: env.INPUT_DRAFT ? env.INPUT_DRAFT === "true" : undefined,
|
input_draft: env.INPUT_DRAFT ? env.INPUT_DRAFT === "true" : undefined,
|
||||||
|
input_preserve_order: env.INPUT_PRESERVE_ORDER
|
||||||
|
? env.INPUT_PRESERVE_ORDER == "true"
|
||||||
|
: undefined,
|
||||||
input_prerelease: env.INPUT_PRERELEASE
|
input_prerelease: env.INPUT_PRERELEASE
|
||||||
? env.INPUT_PRERELEASE == "true"
|
? env.INPUT_PRERELEASE == "true"
|
||||||
: undefined,
|
: undefined,
|
||||||
@ -105,3 +109,7 @@ export const unmatchedPatterns = (patterns: string[]): string[] => {
|
|||||||
export const isTag = (ref: string): boolean => {
|
export const isTag = (ref: string): boolean => {
|
||||||
return ref.startsWith("refs/tags/");
|
return ref.startsWith("refs/tags/");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const alignAssetName = (assetName: string): string => {
|
||||||
|
return assetName.replace(/ /g, ".");
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user