From 6b4e987b54fa28fef1844d6a6922c0fdb83632d7 Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Wed, 22 Nov 2023 18:10:24 -0600 Subject: [PATCH] It worked on my machine --- pnpm-lock.yaml | 1 - scripts/actions/download-draft-bins.js | 3 +- scripts/actions/sign.js | 35 ++++++++++++++---------- scripts/test.ts | 38 ++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 scripts/test.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aba556e4..c293f1fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8138,7 +8138,6 @@ packages: name: github-script version: 7.0.1 engines: {node: '>=20.0.0 <21.0.0'} - prepare: true requiresBuild: true dependencies: '@actions/core': 1.10.1 diff --git a/scripts/actions/download-draft-bins.js b/scripts/actions/download-draft-bins.js index 08b2bc57..c1128598 100644 --- a/scripts/actions/download-draft-bins.js +++ b/scripts/actions/download-draft-bins.js @@ -18,12 +18,11 @@ async function downloadFile(url, filepath = "./download") { await finished(body.pipe(downloadWriteStream)); } -const BINARIES_DIR = "binaries"; +const BINARIES_DIR = "./binaries"; /** @param {import('@types/github-script').AsyncFunctionArguments} AsyncFunctionArguments */ /** @param id {String} */ export const script = async ({ context, github }, id) => { - console.log(`📦 downloading release artifacts for ${id}`); try { diff --git a/scripts/actions/sign.js b/scripts/actions/sign.js index a27cab0d..0417ff6a 100644 --- a/scripts/actions/sign.js +++ b/scripts/actions/sign.js @@ -1,11 +1,12 @@ import fs from "fs"; const releaseId = "${{ needs.create-release.outputs.release_id }}"; -const SIGNED_BINARIES_DIR = "binaries/signed"; +const SIGNED_BINARIES_DIR = "./binaries/signed"; /** @param {import('@types/github-script').AsyncFunctionArguments} AsyncFunctionArguments */ -export const script = async ({ context, github }) => { - console.log("🔍 Start sign of windows binaries..."); +export const script = async ({ context, github }, releaseId) => { + console.log("🔍 Start sign of windows binaries for release id", releaseId); + console.log({ cwd: process.cwd() }); if (!fs.existsSync(SIGNED_BINARIES_DIR)) { console.log("No signed binaries found"); @@ -40,17 +41,21 @@ export const script = async ({ context, github }) => { const filePath = `${SIGNED_BINARIES_DIR}/${file}`; const fileData = fs.readFileSync(filePath); - const { data: uploadResponse } = await github.rest.repos.uploadReleaseAsset( - { - owner: context.repo.owner, - repo: context.repo.repo, - release_id: releaseId, - // @ts-ignore - data: fileData, - name: file, - }, - ); - - console.log(uploadResponse); + console.log("uploading asset", file, filePath); + + try { + const { data: uploadResponse } = + await github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: releaseId, + data: fileData, + name: file, + }); + + console.log("uploaded asset", uploadResponse.name, uploadResponse.id); + } catch (error) { + console.log("error uploading asset", error.message); + } } }; diff --git a/scripts/test.ts b/scripts/test.ts new file mode 100644 index 00000000..881208dc --- /dev/null +++ b/scripts/test.ts @@ -0,0 +1,38 @@ + +// test local script +// op run --env-file .env -- npx tsx scripts/test.ts