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