From a3b15479fc483353424c2730fa77d0f27f128064 Mon Sep 17 00:00:00 2001 From: Timor Raiman Date: Tue, 19 Sep 2023 14:47:22 +0300 Subject: [PATCH] manually adopt and apply patch from https://github.com/softprops/action-gh-release/issues/206#issuecomment-1325087743 --- package.json | 4 +--- src/github.ts | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index aa7af0b..5fc3212 100644 --- a/package.json +++ b/package.json @@ -24,15 +24,13 @@ "@octokit/plugin-retry": "^4.0.3", "@octokit/plugin-throttling": "^4.3.2", "glob": "^8.0.3", - "mime": "^3.0.0", - "node-fetch": "^2.6.7" + "mime": "^3.0.0" }, "devDependencies": { "@types/glob": "^8.0.0", "@types/jest": "^29.2.3", "@types/mime": "^3.0.1", "@types/node": "^18.11.9", - "@types/node-fetch": "^2.5.12", "@vercel/ncc": "^0.34.0", "jest": "^29.3.1", "jest-circus": "^29.3.1", diff --git a/src/github.ts b/src/github.ts index f4a0402..494115c 100644 --- a/src/github.ts +++ b/src/github.ts @@ -1,4 +1,3 @@ -import fetch from "node-fetch"; import { GitHub } from "@actions/github/lib/utils"; import { Config, isTag, releaseBody } from "./util"; import { statSync, readFileSync } from "fs"; @@ -159,16 +158,17 @@ export const upload = async ( console.log(`⬆️ Uploading ${name}...`); const endpoint = new URL(url); endpoint.searchParams.append("name", name); - const resp = await fetch(endpoint, { + const resp = await github.request({ + method: "POST", + url: endpoint.toString(), headers: { "content-length": `${size}`, "content-type": mime, authorization: `token ${config.github_token}`, }, - method: "POST", - body, + data: body, }); - const json = await resp.json(); + const json = resp.data; if (resp.status !== 201) { throw new Error( `Failed to upload release asset ${name}. received status code ${