mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-05-10 10:44:19 +00:00
Merge branch 'softprops:master' into master
This commit is contained in:
commit
55f660a454
8 changed files with 64 additions and 35 deletions
8
.github/dependabot.yml
vendored
8
.github/dependabot.yml
vendored
|
@ -4,6 +4,10 @@ updates:
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
|
groups:
|
||||||
|
npm:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
ignore:
|
ignore:
|
||||||
- dependency-name: node-fetch
|
- dependency-name: node-fetch
|
||||||
versions:
|
versions:
|
||||||
|
@ -14,5 +18,9 @@ updates:
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
|
groups:
|
||||||
|
github-actions:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
commit-message:
|
commit-message:
|
||||||
prefix: "chore(deps)"
|
prefix: "chore(deps)"
|
||||||
|
|
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,3 +1,16 @@
|
||||||
|
## 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
|
## 2.2.0
|
||||||
|
|
||||||
## What's Changed
|
## What's Changed
|
||||||
|
|
|
@ -14,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(await text(data), "release me");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
12
package-lock.json
generated
12
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "2.2.0",
|
"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,7 +19,7 @@
|
||||||
"@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.10.2",
|
"@types/node": "^22.10.5",
|
||||||
"@vercel/ncc": "^0.38.3",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"jest": "^29.3.1",
|
"jest": "^29.3.1",
|
||||||
"jest-circus": "^29.3.1",
|
"jest-circus": "^29.3.1",
|
||||||
|
@ -1598,9 +1598,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "22.10.2",
|
"version": "22.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz",
|
||||||
"integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==",
|
"integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.20.0"
|
"undici-types": "~6.20.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "2.2.0",
|
"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,7 +32,7 @@
|
||||||
"@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.10.2",
|
"@types/node": "^22.10.5",
|
||||||
"@vercel/ncc": "^0.38.3",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"jest": "^29.3.1",
|
"jest": "^29.3.1",
|
||||||
"jest-circus": "^29.3.1",
|
"jest-circus": "^29.3.1",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { GitHub } from "@actions/github/lib/utils";
|
import { GitHub } from "@actions/github/lib/utils";
|
||||||
import { Config, isTag, releaseBody, alignAssetName } from "./util";
|
import { Config, isTag, releaseBody, alignAssetName } from "./util";
|
||||||
import { createReadStream, statSync, type ReadStream } 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: ReadStream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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: createReadStream(path, "binary"),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -161,7 +160,7 @@ 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
|
||||||
|
@ -179,6 +178,8 @@ 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 fh = await open(path);
|
||||||
|
try {
|
||||||
const resp = await github.request({
|
const resp = await github.request({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: endpoint.toString(),
|
url: endpoint.toString(),
|
||||||
|
@ -187,7 +188,7 @@ export const upload = async (
|
||||||
"content-type": mime,
|
"content-type": mime,
|
||||||
authorization: `token ${config.github_token}`,
|
authorization: `token ${config.github_token}`,
|
||||||
},
|
},
|
||||||
data: body,
|
data: fh.readableWebStream({ type: "bytes" }),
|
||||||
});
|
});
|
||||||
const json = resp.data;
|
const json = resp.data;
|
||||||
if (resp.status !== 201) {
|
if (resp.status !== 201) {
|
||||||
|
@ -197,7 +198,11 @@ export const upload = async (
|
||||||
}\n${json.message}\n${JSON.stringify(json.errors)}`,
|
}\n${json.message}\n${JSON.stringify(json.errors)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
console.log(`✅ Uploaded ${name}`);
|
||||||
return json;
|
return json;
|
||||||
|
} finally {
|
||||||
|
await fh.close();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const release = async (
|
export const release = async (
|
||||||
|
|
|
@ -67,9 +67,13 @@ 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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue