Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
c95fe14893 | |||
deddb09c64 | |||
33fcd69d45 | |||
01050bd877 | |||
92dffe6c28 |
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
|
||||
|
||||
## What's Changed
|
||||
|
@ -14,11 +14,10 @@ describe("github", () => {
|
||||
|
||||
describe("asset", () => {
|
||||
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(mime, "text/plain");
|
||||
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",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "action-gh-release",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
@ -19,7 +19,7 @@
|
||||
"@types/glob": "^8.1.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/mime": "^3.0.1",
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/node": "^22.10.5",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"jest": "^29.3.1",
|
||||
"jest-circus": "^29.3.1",
|
||||
@ -1598,9 +1598,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz",
|
||||
"integrity": "sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==",
|
||||
"version": "22.10.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz",
|
||||
"integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~6.20.0"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "action-gh-release",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"private": true,
|
||||
"description": "GitHub Action for creating GitHub Releases",
|
||||
"main": "lib/main.js",
|
||||
@ -32,7 +32,7 @@
|
||||
"@types/glob": "^8.1.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/mime": "^3.0.1",
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/node": "^22.10.5",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"jest": "^29.3.1",
|
||||
"jest-circus": "^29.3.1",
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { GitHub } from "@actions/github/lib/utils";
|
||||
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 { basename } from "path";
|
||||
|
||||
@ -10,7 +11,6 @@ export interface ReleaseAsset {
|
||||
name: string;
|
||||
mime: string;
|
||||
size: number;
|
||||
data: ReadStream;
|
||||
}
|
||||
|
||||
export interface Release {
|
||||
@ -145,7 +145,6 @@ export const asset = (path: string): ReleaseAsset => {
|
||||
name: basename(path),
|
||||
mime: mimeOrDefault(path),
|
||||
size: statSync(path).size,
|
||||
data: createReadStream(path, "binary"),
|
||||
};
|
||||
};
|
||||
|
||||
@ -161,7 +160,7 @@ export const upload = async (
|
||||
currentAssets: Array<{ id: number; name: string }>,
|
||||
): Promise<any> => {
|
||||
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(
|
||||
// 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
|
||||
@ -179,25 +178,31 @@ export const upload = async (
|
||||
console.log(`⬆️ Uploading ${name}...`);
|
||||
const endpoint = new URL(url);
|
||||
endpoint.searchParams.append("name", name);
|
||||
const resp = await github.request({
|
||||
method: "POST",
|
||||
url: endpoint.toString(),
|
||||
headers: {
|
||||
"content-length": `${size}`,
|
||||
"content-type": mime,
|
||||
authorization: `token ${config.github_token}`,
|
||||
},
|
||||
data: body,
|
||||
});
|
||||
const json = resp.data;
|
||||
if (resp.status !== 201) {
|
||||
throw new Error(
|
||||
`Failed to upload release asset ${name}. received status code ${
|
||||
resp.status
|
||||
}\n${json.message}\n${JSON.stringify(json.errors)}`,
|
||||
);
|
||||
const fh = await open(path);
|
||||
try {
|
||||
const resp = await github.request({
|
||||
method: "POST",
|
||||
url: endpoint.toString(),
|
||||
headers: {
|
||||
"content-length": `${size}`,
|
||||
"content-type": mime,
|
||||
authorization: `token ${config.github_token}`,
|
||||
},
|
||||
data: fh.readableWebStream({ type: "bytes" }),
|
||||
});
|
||||
const json = resp.data;
|
||||
if (resp.status !== 201) {
|
||||
throw new Error(
|
||||
`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 (
|
||||
|
@ -67,9 +67,9 @@ async function run() {
|
||||
const files = paths(config.input_files);
|
||||
if (files.length == 0) {
|
||||
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 {
|
||||
console.warn(`🤔 ${config.input_files} not include valid file.`);
|
||||
console.warn(`🤔 ${config.input_files} does not include a valid file.`);
|
||||
}
|
||||
}
|
||||
const currentAssets = rel.assets;
|
||||
|
Reference in New Issue
Block a user