From 7e0ed8e2ab46fdba2e8437d9ad5f5e2e3cb505f7 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 08:44:38 -0400 Subject: [PATCH 01/34] try to have CI prebuild and sign --- .github/workflows/prebuild-pr.yml | 55 ++++++++++++++----------------- package.json | 5 +-- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index a4ab8bda..3eb82734 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -4,52 +4,47 @@ on: pull_request: jobs: - prebuild-linux: - name: Prebuild Binaries for Linux - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Setup Dependencies - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update -y -qq - sudo apt-get install -y g++-multilib gcc-multilib libcups2-dev libcups2-dev:i386 libc6-dev-i386 linux-libc-dev linux-libc-dev:i386 - - uses: actions/setup-node@v1 - with: - node-version: 16.x - - uses: actions/checkout@v1 - - run: npm i - - name: Prebuild - run: | - npm run apply-patches - npm run prebuild -- --strip --all --arch ia32 - npm run prebuild -- --strip --all --arch x64 prebuild-macos: name: Prebuild Binaries for macOS runs-on: macos-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v1 + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 with: - node-version: 16.x - - uses: actions/checkout@v1 + node-version: 20 - run: npm i - - name: Prebuild + + - name: Extract certificate + uses: apple-actions/import-codesign-certs@v3 + with: + p12-file-base64: ${{ secrets.APPLICATION_CERTIFICATE_P12 }} + p12-password: ${{ secrets.APPLICATION_CERTIFICATE_P12_PASSWORD }} + + - name: Build and sign macOS prebuild run: | - npm run apply-patches - npm run prebuild -- --strip --all --arch x64 + npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip + codesign --sign "Developer ID Application: Your Name ${var.TEAM_ID}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node" + + - name: Upload prebuild to GitHub release + run: npx prebuild --upload-all + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + prebuild-windows: name: Prebuild Binaries for Windows runs-on: windows-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v3 with: - node-version: 16.x - - uses: actions/checkout@v1 + node-version: 20 + - uses: actions/checkout@v3 - run: npm i - name: Prebuild run: | - npm run apply-patches npm run prebuild -- --strip --all --arch ia32 npm run prebuild -- --strip --all --arch x64 diff --git a/package.json b/package.json index 77f573f2..d7efa1d1 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,10 @@ }, "binary": { "module_name": "node_printer", - "module_path": "./lib/", + "module_path": "prebuilds/{platform}-{arch}/", "host": "https://github.com/casechek/node-printer/releases/download/", - "remote_path": "v{version}" + "remote_path": "./releases/", + "package_name": "node_printer.node" }, "license": "MIT", "main": "./lib/printer", From 19bb55a6e67a0cad8e758bcd65f2eae75ac0f264 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 08:53:30 -0400 Subject: [PATCH 02/34] fix npm install order --- .github/workflows/prebuild-pr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index d6cd8427..10df1610 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -13,11 +13,13 @@ jobs: uses: actions/setup-node@v4 with: node-version: 20 - - run: npm i - name: Checkout uses: actions/checkout@v4 + - name: Install dependencies + run: npm i + - name: Extract certificate uses: apple-actions/import-codesign-certs@v3 with: From bd63619d8881133598ef5ebe8371888be6e64c23 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 08:59:29 -0400 Subject: [PATCH 03/34] remove extra " --- .github/workflows/prebuild-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 10df1610..6b04fcdf 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -29,7 +29,7 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - codesign --sign "Developer ID Application: Your Name ${var.TEAM_ID}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node" + codesign --sign "Developer ID Application: Your Name ${var.TEAM_ID}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node - name: Upload prebuild to GitHub release run: npx prebuild --upload-all @@ -50,3 +50,4 @@ jobs: run: | npm run prebuild -- --strip --arch ia32 npm run prebuild -- --strip --arch x64 + npm run prebuild -- --upload-all From 684fb010d1738182ecfa64549e78d7436827633d Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 09:01:14 -0400 Subject: [PATCH 04/34] remove var mapping in string --- .github/workflows/prebuild-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 6b04fcdf..af2f5dfa 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -29,7 +29,7 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - codesign --sign "Developer ID Application: Your Name ${var.TEAM_ID}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node + codesign --sign "Developer ID Application: Your Name ${{var.TEAM_ID}}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node - name: Upload prebuild to GitHub release run: npx prebuild --upload-all From e8641b81c086ee47098bc043372e87c704398d2f Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 09:01:32 -0400 Subject: [PATCH 05/34] fix var mapping in string --- .github/workflows/prebuild-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index af2f5dfa..dc547799 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -29,7 +29,7 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - codesign --sign "Developer ID Application: Your Name ${{var.TEAM_ID}}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node + codesign --sign "Developer ID Application: Your Name ${{vars.TEAM_ID}}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node - name: Upload prebuild to GitHub release run: npx prebuild --upload-all From d6ace38e15eec3687d55a89e958c43ddc64e4aeb Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 09:14:11 -0400 Subject: [PATCH 06/34] fix adding release --- .github/workflows/prebuild-pr.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index dc547799..a688941a 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -20,6 +20,10 @@ jobs: - name: Install dependencies run: npm i + - name: Get Version + id: get-version + run: echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT + - name: Extract certificate uses: apple-actions/import-codesign-certs@v3 with: @@ -31,6 +35,14 @@ jobs: npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip codesign --sign "Developer ID Application: Your Name ${{vars.TEAM_ID}}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node + - name: Create GitHub Release if it doesn't exist + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ steps.get-version.outputs.version }} + draft: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload prebuild to GitHub release run: npx prebuild --upload-all env: @@ -46,6 +58,19 @@ jobs: node-version: 20 - uses: actions/checkout@v4 - run: npm i + + - name: Get Version + id: get-version + run: echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT + + - name: Create GitHub Release if it doesn't exist + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ steps.get-version.outputs.version }} + draft: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Prebuild run: | npm run prebuild -- --strip --arch ia32 From 08b8d72757295662ac5c26df4680db944a7ca253 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 09:23:37 -0400 Subject: [PATCH 07/34] fix get version syntax issue --- .github/workflows/prebuild-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index a688941a..0bc7ce78 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -22,7 +22,7 @@ jobs: - name: Get Version id: get-version - run: echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT + run: echo "version=$(node -p 'require(\"./package.json\").version')" >> $GITHUB_OUTPUT - name: Extract certificate uses: apple-actions/import-codesign-certs@v3 @@ -61,7 +61,7 @@ jobs: - name: Get Version id: get-version - run: echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT + run: echo "version=$(node -p 'require(\"./package.json\").version')" >> $GITHUB_OUTPUT - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 From e5874676c77bc00c4115a72a9c1a027974bc4b2f Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 09:29:48 -0400 Subject: [PATCH 08/34] fix get version syntax issue try 2 --- .github/workflows/prebuild-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 0bc7ce78..a688941a 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -22,7 +22,7 @@ jobs: - name: Get Version id: get-version - run: echo "version=$(node -p 'require(\"./package.json\").version')" >> $GITHUB_OUTPUT + run: echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT - name: Extract certificate uses: apple-actions/import-codesign-certs@v3 @@ -61,7 +61,7 @@ jobs: - name: Get Version id: get-version - run: echo "version=$(node -p 'require(\"./package.json\").version')" >> $GITHUB_OUTPUT + run: echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 From 82339fcf2680e828001be3773f75d23d93b28349 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 09:41:05 -0400 Subject: [PATCH 09/34] fix get version syntax issue try 3 --- .github/workflows/prebuild-pr.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index a688941a..0d3db9fb 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -22,7 +22,10 @@ jobs: - name: Get Version id: get-version - run: echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT + shell: bash + run: | + echo "console.log(require('./package.json').version);" > get-version.js + echo "version=$(node get-version.js)" >> $GITHUB_OUTPUT - name: Extract certificate uses: apple-actions/import-codesign-certs@v3 @@ -61,7 +64,10 @@ jobs: - name: Get Version id: get-version - run: echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT + shell: bash + run: | + echo "console.log(require('./package.json').version);" > get-version.js + echo "version=$(node get-version.js)" >> $GITHUB_OUTPUT - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 From 481f5c110bb7eb74c296efac360892ac69ff210b Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 09:50:48 -0400 Subject: [PATCH 10/34] fix signing --- .github/workflows/prebuild-pr.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 0d3db9fb..05df26b5 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -22,7 +22,6 @@ jobs: - name: Get Version id: get-version - shell: bash run: | echo "console.log(require('./package.json').version);" > get-version.js echo "version=$(node get-version.js)" >> $GITHUB_OUTPUT @@ -36,7 +35,7 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - codesign --sign "Developer ID Application: Your Name ${{vars.TEAM_ID}}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node + codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 @@ -64,7 +63,6 @@ jobs: - name: Get Version id: get-version - shell: bash run: | echo "console.log(require('./package.json').version);" > get-version.js echo "version=$(node get-version.js)" >> $GITHUB_OUTPUT @@ -79,6 +77,5 @@ jobs: - name: Prebuild run: | - npm run prebuild -- --strip --arch ia32 - npm run prebuild -- --strip --arch x64 + npm run prebuild-all npm run prebuild -- --upload-all From f9c035184295ca3bd8a9a50a820cf0a5063944ea Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 09:59:46 -0400 Subject: [PATCH 11/34] fix signing and upload to releases --- .github/workflows/prebuild-pr.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 05df26b5..c7d956de 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -35,7 +35,7 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node + codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime prebuilds/darwin-x64/node_printer.node - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 @@ -78,4 +78,8 @@ jobs: - name: Prebuild run: | npm run prebuild-all - npm run prebuild -- --upload-all + + - name: Upload prebuilds to GitHub release + run: npm run prebuild -- --upload-all + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1a07f3c82c9dd6f756573da9a177dcef1f3cc889 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 10:12:49 -0400 Subject: [PATCH 12/34] debugging as we cant find the files after prebuild --- .github/workflows/prebuild-pr.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index c7d956de..b57ce368 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -35,7 +35,10 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime prebuilds/darwin-x64/node_printer.node + ls -la prebuilds/ + ls -la prebuilds/darwin-x64/ || echo "Directory not found" + ls -la prebuilds/@casechek/ || echo "Directory not found" + codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime prebuilds/darwin-x64/node_printer.node || echo "File not found for signing" - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 @@ -46,7 +49,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload prebuild to GitHub release - run: npx prebuild --upload-all + run: npx prebuild --upload-all -u ${{ secrets.GITHUB_TOKEN }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -78,8 +81,9 @@ jobs: - name: Prebuild run: | npm run prebuild-all + dir prebuilds - name: Upload prebuilds to GitHub release - run: npm run prebuild -- --upload-all + run: npx prebuild --upload-all -u ${{ secrets.GITHUB_TOKEN }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3e4ea4680ef982da620dcd3dbb695b21ccbb7163 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 10:25:20 -0400 Subject: [PATCH 13/34] debugging as we cant find the files after prebuild --- .github/workflows/prebuild-pr.yml | 11 +++++------ package.json | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index b57ce368..3f692d93 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -35,21 +35,19 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - ls -la prebuilds/ - ls -la prebuilds/darwin-x64/ || echo "Directory not found" - ls -la prebuilds/@casechek/ || echo "Directory not found" - codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime prebuilds/darwin-x64/node_printer.node || echo "File not found for signing" + codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 with: tag_name: v${{ steps.get-version.outputs.version }} draft: true + files: prebuilds/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload prebuild to GitHub release - run: npx prebuild --upload-all -u ${{ secrets.GITHUB_TOKEN }} + run: npx prebuild --upload -u ${{ secrets.GITHUB_TOKEN }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -75,6 +73,7 @@ jobs: with: tag_name: v${{ steps.get-version.outputs.version }} draft: true + files: prebuilds/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -84,6 +83,6 @@ jobs: dir prebuilds - name: Upload prebuilds to GitHub release - run: npx prebuild --upload-all -u ${{ secrets.GITHUB_TOKEN }} + run: npx prebuild --upload -u ${{ secrets.GITHUB_TOKEN }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index d7de45b2..a984081b 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,10 @@ }, "binary": { "module_name": "node_printer", - "module_path": "prebuilds/{platform}-{arch}/", + "module_path": "prebuilds", "host": "https://github.com/casechek/node-printer/releases/download/", - "remote_path": "./releases/", - "package_name": "node_printer.node" + "remote_path": "v{version}", + "package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz" }, "license": "MIT", "main": "./lib/printer", From 67ddf0fb84d9375b230df7d5dc60801b0378ed20 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 10:26:50 -0400 Subject: [PATCH 14/34] just use the file in prebuilds now --- .github/workflows/prebuild-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 3f692d93..6889731c 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -35,7 +35,7 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime ./prebuilds/darwin-x64/node_printer.node + codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime ./prebuilds/node_printer.node - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 From 5eb75502f884da7c170137d82ac7759889765844 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 10:41:27 -0400 Subject: [PATCH 15/34] just use the file in prebuilds now --- .github/workflows/prebuild-pr.yml | 7 ++++--- package.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 6889731c..6000d6f3 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -77,10 +77,11 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Prebuild + - name: Prebuild Windows binaries run: | - npm run prebuild-all - dir prebuilds + npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform win32 --strip + npx prebuild --backend node-gyp --target 20.3.0 --arch ia32 --platform win32 --strip + dir prebuilds || echo "Prebuilds directory not found" - name: Upload prebuilds to GitHub release run: npx prebuild --upload -u ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index a984081b..d8147e83 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "scripts": { "install": "prebuild-install || node-gyp rebuild", - "prebuild-all": "prebuild --all --force --strip --verbose --openssl_fips=X", + "prebuild-all": "prebuild --all --force --strip --verbose", "prebuild": "prebuild", "prebuild-electron": "prebuild --strip --verbose", "rebuild": "node-gyp rebuild", From 90747cf89f3de28431ee561de7f487fd88ba583c Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 10:50:42 -0400 Subject: [PATCH 16/34] update version to get a new release of node-printer and prebuilts --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8147e83..e66693ae 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@casechek/node-printer", "description": "Node.js printer bindings", - "version": "0.6.2", + "version": "0.7.0", "homepage": "https://github.com/casechek/node-printer", "author": { "name": "Ion Lupascu", From aa00564dd3238e86d067d0736f16a9f5a6c80222 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 10:54:03 -0400 Subject: [PATCH 17/34] add pr number to releases --- .github/workflows/prebuild-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 6000d6f3..77c58182 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -24,7 +24,7 @@ jobs: id: get-version run: | echo "console.log(require('./package.json').version);" > get-version.js - echo "version=$(node get-version.js)" >> $GITHUB_OUTPUT + echo "version=$(node get-version.js)-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT - name: Extract certificate uses: apple-actions/import-codesign-certs@v3 @@ -66,7 +66,7 @@ jobs: id: get-version run: | echo "console.log(require('./package.json').version);" > get-version.js - echo "version=$(node get-version.js)" >> $GITHUB_OUTPUT + echo "version=$(node get-version.js)-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 From 5096c97ea56664f9be5c0f1dc93a6c19574205f3 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 11:00:37 -0400 Subject: [PATCH 18/34] prevent windows versions from overriding themselves --- .github/workflows/prebuild-pr.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 77c58182..6b78ecd0 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -79,9 +79,18 @@ jobs: - name: Prebuild Windows binaries run: | + # Build 64-bit version npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform win32 --strip + # Save the 64-bit build + mkdir -p prebuilds-x64 + move prebuilds\*.tar.gz prebuilds-x64\ + + # Build 32-bit version npx prebuild --backend node-gyp --target 20.3.0 --arch ia32 --platform win32 --strip - dir prebuilds || echo "Prebuilds directory not found" + # Move all tar.gz files to the release directory + dir prebuilds\*.tar.gz + dir prebuilds-x64\*.tar.gz + move prebuilds-x64\*.tar.gz prebuilds\ - name: Upload prebuilds to GitHub release run: npx prebuild --upload -u ${{ secrets.GITHUB_TOKEN }} From 5a8c12c96cbeeff215ecd3371bc2931d850a22a5 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 11:09:23 -0400 Subject: [PATCH 19/34] add os and version folder to store all the .node files so they dont overwrite each other --- .github/workflows/prebuild-pr.yml | 24 ++++++++++-------------- package.json | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 6b78ecd0..7e6e7482 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -35,7 +35,8 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime ./prebuilds/node_printer.node + ls -la prebuilds/darwin-x64/ || echo "Directory not found" + codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime prebuilds/darwin-x64/node_printer.node - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 @@ -73,26 +74,21 @@ jobs: with: tag_name: v${{ steps.get-version.outputs.version }} draft: true - files: prebuilds/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Prebuild Windows binaries run: | - # Build 64-bit version + # Build x64 version with explicit path npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform win32 --strip - # Save the 64-bit build - mkdir -p prebuilds-x64 - move prebuilds\*.tar.gz prebuilds-x64\ - # Build 32-bit version + # Build ia32 version with explicit path npx prebuild --backend node-gyp --target 20.3.0 --arch ia32 --platform win32 --strip - # Move all tar.gz files to the release directory - dir prebuilds\*.tar.gz - dir prebuilds-x64\*.tar.gz - move prebuilds-x64\*.tar.gz prebuilds\ + + # List the directories to verify + dir prebuilds + dir prebuilds\win32-x64 || echo "x64 directory not found" + dir prebuilds\win32-ia32 || echo "ia32 directory not found" - name: Upload prebuilds to GitHub release - run: npx prebuild --upload -u ${{ secrets.GITHUB_TOKEN }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx prebuild --upload-all -u ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index e66693ae..9cc09ab7 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "binary": { "module_name": "node_printer", - "module_path": "prebuilds", + "module_path": "prebuilds/{platform}-{arch}/", "host": "https://github.com/casechek/node-printer/releases/download/", "remote_path": "v{version}", "package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz" From 406917b1b42e853b544a4c22c7f2bd012660eeaa Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 11:27:44 -0400 Subject: [PATCH 20/34] add os and version folder to store all the .node files so they dont overwrite each other --- .github/workflows/prebuild-pr.yml | 26 ++++++++++++++++++-------- package.json | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 7e6e7482..f3cdfab7 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -35,15 +35,17 @@ jobs: - name: Build and sign macOS prebuild run: | npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip - ls -la prebuilds/darwin-x64/ || echo "Directory not found" - codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime prebuilds/darwin-x64/node_printer.node + mkdir -p lib/darwin-x64 + cp lib/node_printer.node lib/darwin-x64/ + ls -la lib/darwin-x64/ || echo "Directory not found" + codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime lib/darwin-x64/node_printer.node || echo "File not found for signing" - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 with: tag_name: v${{ steps.get-version.outputs.version }} draft: true - files: prebuilds/*.tar.gz + files: lib/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -79,16 +81,24 @@ jobs: - name: Prebuild Windows binaries run: | - # Build x64 version with explicit path + # Create platform-specific directories + mkdir -p lib/win32-x64 + mkdir -p lib/win32-ia32 + + # Build x64 version npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform win32 --strip + # Copy to platform-specific directory + copy lib\node_printer.node lib\win32-x64\ - # Build ia32 version with explicit path + # Build ia32 version npx prebuild --backend node-gyp --target 20.3.0 --arch ia32 --platform win32 --strip + # Copy to platform-specific directory + copy lib\node_printer.node lib\win32-ia32\ # List the directories to verify - dir prebuilds - dir prebuilds\win32-x64 || echo "x64 directory not found" - dir prebuilds\win32-ia32 || echo "ia32 directory not found" + dir lib + dir lib\win32-x64 || echo "x64 directory not found" + dir lib\win32-ia32 || echo "ia32 directory not found" - name: Upload prebuilds to GitHub release run: npx prebuild --upload-all -u ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 9cc09ab7..f17d3b34 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "binary": { "module_name": "node_printer", - "module_path": "prebuilds/{platform}-{arch}/", + "module_path": "lib", "host": "https://github.com/casechek/node-printer/releases/download/", "remote_path": "v{version}", "package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz" From 77de20b3f3ced62a40c07726898cace6c857537b Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 11:54:49 -0400 Subject: [PATCH 21/34] fix the file upload using a more standard process --- .github/workflows/prebuild-pr.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index f3cdfab7..2ab70dfe 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -39,18 +39,23 @@ jobs: cp lib/node_printer.node lib/darwin-x64/ ls -la lib/darwin-x64/ || echo "Directory not found" codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime lib/darwin-x64/node_printer.node || echo "File not found for signing" + # Package the binary for upload + tar -czvf node_printer-darwin-x64.tar.gz -C lib/darwin-x64 node_printer.node - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 with: tag_name: v${{ steps.get-version.outputs.version }} draft: true - files: lib/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload prebuild to GitHub release - run: npx prebuild --upload -u ${{ secrets.GITHUB_TOKEN }} + - name: Upload macOS binary to GitHub release + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ steps.get-version.outputs.version }} + draft: true + files: node_printer-darwin-x64.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -99,6 +104,18 @@ jobs: dir lib dir lib\win32-x64 || echo "x64 directory not found" dir lib\win32-ia32 || echo "ia32 directory not found" + + # Package the binaries for upload + tar -czvf node_printer-win32-x64.tar.gz -C lib/win32-x64 node_printer.node + tar -czvf node_printer-win32-ia32.tar.gz -C lib/win32-ia32 node_printer.node - - name: Upload prebuilds to GitHub release - run: npx prebuild --upload-all -u ${{ secrets.GITHUB_TOKEN }} + - name: Upload Windows binaries to GitHub release + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ steps.get-version.outputs.version }} + draft: true + files: | + node_printer-win32-x64.tar.gz + node_printer-win32-ia32.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From bf6e503ccec9b7132c790ee3b124e9e5f1c686c2 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 13:47:34 -0400 Subject: [PATCH 22/34] cleanup a little and get tagging to apply properly --- .github/workflows/prebuild-pr.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 2ab70dfe..8b60076d 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -34,13 +34,11 @@ jobs: - name: Build and sign macOS prebuild run: | - npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip + npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip --pack mkdir -p lib/darwin-x64 cp lib/node_printer.node lib/darwin-x64/ ls -la lib/darwin-x64/ || echo "Directory not found" codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime lib/darwin-x64/node_printer.node || echo "File not found for signing" - # Package the binary for upload - tar -czvf node_printer-darwin-x64.tar.gz -C lib/darwin-x64 node_printer.node - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 @@ -55,7 +53,9 @@ jobs: with: tag_name: v${{ steps.get-version.outputs.version }} draft: true - files: node_printer-darwin-x64.tar.gz + files: | + *.tar.gz + prebuilds/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -91,12 +91,12 @@ jobs: mkdir -p lib/win32-ia32 # Build x64 version - npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform win32 --strip + npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform win32 --strip --pack # Copy to platform-specific directory copy lib\node_printer.node lib\win32-x64\ # Build ia32 version - npx prebuild --backend node-gyp --target 20.3.0 --arch ia32 --platform win32 --strip + npx prebuild --backend node-gyp --target 20.3.0 --arch ia32 --platform win32 --strip --pack # Copy to platform-specific directory copy lib\node_printer.node lib\win32-ia32\ @@ -104,10 +104,6 @@ jobs: dir lib dir lib\win32-x64 || echo "x64 directory not found" dir lib\win32-ia32 || echo "ia32 directory not found" - - # Package the binaries for upload - tar -czvf node_printer-win32-x64.tar.gz -C lib/win32-x64 node_printer.node - tar -czvf node_printer-win32-ia32.tar.gz -C lib/win32-ia32 node_printer.node - name: Upload Windows binaries to GitHub release uses: softprops/action-gh-release@v1 @@ -115,7 +111,7 @@ jobs: tag_name: v${{ steps.get-version.outputs.version }} draft: true files: | - node_printer-win32-x64.tar.gz - node_printer-win32-ia32.tar.gz + *.tar.gz + prebuilds/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f6ce69a52b40ad5454edf62a1da71dd9d72aa3f0 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 13:55:41 -0400 Subject: [PATCH 23/34] fix path --- .github/workflows/prebuild-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 8b60076d..da78572d 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -55,7 +55,7 @@ jobs: draft: true files: | *.tar.gz - prebuilds/*.tar.gz + lib/**/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -112,6 +112,6 @@ jobs: draft: true files: | *.tar.gz - prebuilds/*.tar.gz + lib/**/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9dd9f96a005113a9d567b2e5cdeff1222f973cd1 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 14:03:38 -0400 Subject: [PATCH 24/34] fix paths and add some logging --- .github/workflows/prebuild-pr.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index da78572d..0113ac52 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -39,6 +39,9 @@ jobs: cp lib/node_printer.node lib/darwin-x64/ ls -la lib/darwin-x64/ || echo "Directory not found" codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime lib/darwin-x64/node_printer.node || echo "File not found for signing" + # List directories to see where tar.gz files are + echo "Checking for tar.gz files:" + find . -name "*.tar.gz" -type f - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 @@ -55,7 +58,7 @@ jobs: draft: true files: | *.tar.gz - lib/**/*.tar.gz + **/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -104,6 +107,10 @@ jobs: dir lib dir lib\win32-x64 || echo "x64 directory not found" dir lib\win32-ia32 || echo "ia32 directory not found" + + # List directories to see where tar.gz files are + echo "Checking for tar.gz files:" + dir *.tar.gz /s - name: Upload Windows binaries to GitHub release uses: softprops/action-gh-release@v1 @@ -112,6 +119,6 @@ jobs: draft: true files: | *.tar.gz - lib/**/*.tar.gz + **/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e85469ac9a4006522632292db96d7dd131d05780 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 14:11:34 -0400 Subject: [PATCH 25/34] fix the bad dir --- .github/workflows/prebuild-pr.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 0113ac52..eec5ebcd 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -107,10 +107,6 @@ jobs: dir lib dir lib\win32-x64 || echo "x64 directory not found" dir lib\win32-ia32 || echo "ia32 directory not found" - - # List directories to see where tar.gz files are - echo "Checking for tar.gz files:" - dir *.tar.gz /s - name: Upload Windows binaries to GitHub release uses: softprops/action-gh-release@v1 From 22fd595a373512c5f2ec6194f94a66223e1bb5da Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 14:23:15 -0400 Subject: [PATCH 26/34] fix version issue --- .github/workflows/prebuild-pr.yml | 43 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index eec5ebcd..e5b8feda 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -20,11 +20,13 @@ jobs: - name: Install dependencies run: npm i - - name: Get Version - id: get-version - run: | - echo "console.log(require('./package.json').version);" > get-version.js - echo "version=$(node get-version.js)-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + - name: Get package version + id: package-version + uses: martinbeentjes/npm-get-version-action@main + + - name: Set release version + id: set-version + run: echo "version=${{ steps.package-version.outputs.current-version }}-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT - name: Extract certificate uses: apple-actions/import-codesign-certs@v3 @@ -46,7 +48,7 @@ jobs: - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.get-version.outputs.version }} + tag_name: v${{ steps.set-version.outputs.version }} draft: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -54,7 +56,7 @@ jobs: - name: Upload macOS binary to GitHub release uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.get-version.outputs.version }} + tag_name: v${{ steps.set-version.outputs.version }} draft: true files: | *.tar.gz @@ -67,22 +69,29 @@ jobs: runs-on: windows-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v4 + - name: Setup Node + uses: actions/setup-node@v4 with: node-version: 20 - - uses: actions/checkout@v4 - - run: npm i - - name: Get Version - id: get-version - run: | - echo "console.log(require('./package.json').version);" > get-version.js - echo "version=$(node get-version.js)-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: npm i + + - name: Get package version + id: package-version + uses: martinbeentjes/npm-get-version-action@main + + - name: Set release version + id: set-version + run: echo "version=${{ steps.package-version.outputs.current-version }}-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.get-version.outputs.version }} + tag_name: v${{ steps.set-version.outputs.version }} draft: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -111,7 +120,7 @@ jobs: - name: Upload Windows binaries to GitHub release uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.get-version.outputs.version }} + tag_name: v${{ steps.set-version.outputs.version }} draft: true files: | *.tar.gz From b97b0f965b76553a4b98adc014af4f2e0b6a3c11 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 14:33:25 -0400 Subject: [PATCH 27/34] move the version check to the main so we dont have to do one per os --- .github/workflows/prebuild-pr.yml | 43 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index e5b8feda..770400f1 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -4,8 +4,26 @@ on: pull_request: jobs: + get-version: + name: Get Package Version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.set-version.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get package version + id: package-version + uses: martinbeentjes/npm-get-version-action@1.3.1 + + - name: Set release version + id: set-version + run: echo "version=${{ steps.package-version.outputs.current-version }}-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + prebuild-macos: name: Prebuild Binaries for macOS + needs: get-version runs-on: macos-latest timeout-minutes: 30 steps: @@ -20,14 +38,6 @@ jobs: - name: Install dependencies run: npm i - - name: Get package version - id: package-version - uses: martinbeentjes/npm-get-version-action@main - - - name: Set release version - id: set-version - run: echo "version=${{ steps.package-version.outputs.current-version }}-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT - - name: Extract certificate uses: apple-actions/import-codesign-certs@v3 with: @@ -48,7 +58,7 @@ jobs: - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.set-version.outputs.version }} + tag_name: v${{ needs.get-version.outputs.version }} draft: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -56,7 +66,7 @@ jobs: - name: Upload macOS binary to GitHub release uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.set-version.outputs.version }} + tag_name: v${{ needs.get-version.outputs.version }} draft: true files: | *.tar.gz @@ -66,6 +76,7 @@ jobs: prebuild-windows: name: Prebuild Binaries for Windows + needs: get-version runs-on: windows-latest timeout-minutes: 30 steps: @@ -80,18 +91,10 @@ jobs: - name: Install dependencies run: npm i - - name: Get package version - id: package-version - uses: martinbeentjes/npm-get-version-action@main - - - name: Set release version - id: set-version - run: echo "version=${{ steps.package-version.outputs.current-version }}-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT - - name: Create GitHub Release if it doesn't exist uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.set-version.outputs.version }} + tag_name: v${{ needs.get-version.outputs.version }} draft: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -120,7 +123,7 @@ jobs: - name: Upload Windows binaries to GitHub release uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.set-version.outputs.version }} + tag_name: v${{ needs.get-version.outputs.version }} draft: true files: | *.tar.gz From 9c5f494712afd44066d9f75bcf754c20a3aa30f5 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 14:34:22 -0400 Subject: [PATCH 28/34] move the version check to the main so we dont have to do one per os --- .github/workflows/prebuild-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 770400f1..c31b9004 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -15,7 +15,7 @@ jobs: - name: Get package version id: package-version - uses: martinbeentjes/npm-get-version-action@1.3.1 + uses: martinbeentjes/npm-get-version-action@v1.3.1 - name: Set release version id: set-version From 99132e60a30022f1ac4b9818e52c9c354989bf4b Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 15:07:30 -0400 Subject: [PATCH 29/34] update to publish the release --- .github/workflows/prebuild-pr.yml | 47 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index c31b9004..016ebed7 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.set-version.outputs.version }} + release_id: ${{ steps.create-release.outputs.id }} steps: - name: Checkout uses: actions/checkout@v4 @@ -21,6 +22,17 @@ jobs: id: set-version run: echo "version=${{ steps.package-version.outputs.current-version }}-pr${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + - name: Create GitHub Release + id: create-release + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ steps.set-version.outputs.version }} + draft: true # Initial creation as draft + name: Release v${{ steps.set-version.outputs.version }} + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + prebuild-macos: name: Prebuild Binaries for macOS needs: get-version @@ -55,19 +67,11 @@ jobs: echo "Checking for tar.gz files:" find . -name "*.tar.gz" -type f - - name: Create GitHub Release if it doesn't exist - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ needs.get-version.outputs.version }} - draft: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload macOS binary to GitHub release uses: softprops/action-gh-release@v1 with: tag_name: v${{ needs.get-version.outputs.version }} - draft: true + draft: true # Keep as draft during upload files: | *.tar.gz **/*.tar.gz @@ -91,14 +95,6 @@ jobs: - name: Install dependencies run: npm i - - name: Create GitHub Release if it doesn't exist - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ needs.get-version.outputs.version }} - draft: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Prebuild Windows binaries run: | # Create platform-specific directories @@ -124,9 +120,24 @@ jobs: uses: softprops/action-gh-release@v1 with: tag_name: v${{ needs.get-version.outputs.version }} - draft: true + draft: true # Keep as draft during upload files: | *.tar.gz **/*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-release: + name: Publish GitHub Release + needs: [get-version, prebuild-macos, prebuild-windows] + runs-on: ubuntu-latest + # Optional: Add a condition to only publish on certain events or branches + # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + steps: + - name: Publish Release + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ needs.get-version.outputs.version }} + draft: false # Publish the release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d9340ebe9d1734e2b3fa960c0ea87acb34f06ee8 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 15:18:48 -0400 Subject: [PATCH 30/34] append to the release, until we close it --- .github/workflows/prebuild-pr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 016ebed7..10823ee8 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -75,6 +75,7 @@ jobs: files: | *.tar.gz **/*.tar.gz + append_body: true # Append to existing release notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -124,6 +125,7 @@ jobs: files: | *.tar.gz **/*.tar.gz + append_body: true # Append to existing release notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -139,5 +141,6 @@ jobs: with: tag_name: v${{ needs.get-version.outputs.version }} draft: false # Publish the release + append_body: true # Ensure we're updating the existing release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d64e980e026c3f5f7d6127642297f47182098bfa Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 15:40:56 -0400 Subject: [PATCH 31/34] update our release publisher version so it doesnt create a second release --- .github/workflows/prebuild-pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 10823ee8..9dacf41f 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -24,7 +24,7 @@ jobs: - name: Create GitHub Release id: create-release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: v${{ steps.set-version.outputs.version }} draft: true # Initial creation as draft @@ -68,7 +68,7 @@ jobs: find . -name "*.tar.gz" -type f - name: Upload macOS binary to GitHub release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: v${{ needs.get-version.outputs.version }} draft: true # Keep as draft during upload @@ -118,7 +118,7 @@ jobs: dir lib\win32-ia32 || echo "ia32 directory not found" - name: Upload Windows binaries to GitHub release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: v${{ needs.get-version.outputs.version }} draft: true # Keep as draft during upload @@ -137,7 +137,7 @@ jobs: # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true steps: - name: Publish Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: v${{ needs.get-version.outputs.version }} draft: false # Publish the release From 3107ba697d1e8e968054254d6e69638ae972432a Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 15:49:53 -0400 Subject: [PATCH 32/34] update the main workflow to match just not create pr in release name --- .github/workflows/prebuild-main.yml | 157 ++++++++++++++++++++++------ .github/workflows/prebuild-pr.yml | 16 ++- 2 files changed, 130 insertions(+), 43 deletions(-) diff --git a/.github/workflows/prebuild-main.yml b/.github/workflows/prebuild-main.yml index 57bf9a29..b2aca371 100644 --- a/.github/workflows/prebuild-main.yml +++ b/.github/workflows/prebuild-main.yml @@ -1,55 +1,144 @@ -name: Prebuild Binaries and Publish +name: Main Prebuild Binaries on: - push: - branches: - - main + pull_request: jobs: - prebuild-linux: - name: Prebuild Binaries for Linux + get-version: + name: Get Package Version runs-on: ubuntu-latest - timeout-minutes: 30 + outputs: + version: ${{ steps.set-version.outputs.version }} + release_id: ${{ steps.create-release.outputs.id }} steps: - - name: Setup Dependencies - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update -y -qq - sudo apt-get install -y g++-multilib gcc-multilib libcups2-dev libcups2-dev:i386 libc6-dev-i386 linux-libc-dev linux-libc-dev:i386 - - uses: actions/setup-node@v4 + - name: Checkout + uses: actions/checkout@v4 + + - name: Get package version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.3.1 + + - name: Set release version + id: set-version + run: echo "version=${{ steps.package-version.outputs.current-version }}" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + id: create-release + uses: softprops/action-gh-release@v2 with: - node-version: 20.x - - uses: actions/checkout@v4 - - run: npm i - - name: Prebuild - run: | - npm run prebuild -- --strip --arch ia32 -u ${{ secrets.PREBUILD_TOKEN }} - npm run prebuild -- --strip --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} + tag_name: v${{ steps.set-version.outputs.version }} + draft: true + name: Release v${{ steps.set-version.outputs.version }} + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + prebuild-macos: name: Prebuild Binaries for macOS + needs: get-version runs-on: macos-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: npm i + + - name: Extract certificate + uses: apple-actions/import-codesign-certs@v3 with: - node-version: 20.x - - uses: actions/checkout@v4 - - run: npm i - - name: Prebuild + p12-file-base64: ${{ secrets.APPLICATION_CERTIFICATE_P12 }} + p12-password: ${{ secrets.APPLICATION_CERTIFICATE_P12_PASSWORD }} + + - name: Build and sign macOS prebuild run: | - npm run prebuild -- --strip --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} - npm run prebuild -- --strip --arch arm64 -u ${{ secrets.PREBUILD_TOKEN }} + npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform darwin --strip --pack + mkdir -p lib/darwin-x64 + cp lib/node_printer.node lib/darwin-x64/ + ls -la lib/darwin-x64/ || echo "Directory not found" + codesign --sign "${{ vars.TEAM_ID }}" --timestamp --options runtime lib/darwin-x64/node_printer.node || echo "File not found for signing" + # List directories to see where tar.gz files are + echo "Checking for tar.gz files:" + find . -name "*.tar.gz" -type f + + - name: Upload macOS binary to GitHub release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ needs.get-version.outputs.version }} + draft: true + files: | + *.tar.gz + **/*.tar.gz + append_body: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + prebuild-windows: name: Prebuild Binaries for Windows + needs: get-version runs-on: windows-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v4 + - name: Setup Node + uses: actions/setup-node@v4 with: - node-version: 20.x - - uses: actions/checkout@v4 - - run: npm i - - name: Prebuild + node-version: 20 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: npm i + + - name: Prebuild Windows binaries run: | - npm run prebuild -- --strip --arch ia32 -u ${{ secrets.PREBUILD_TOKEN }} - npm run prebuild -- --strip --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} + # Create platform-specific directories + mkdir -p lib/win32-x64 + mkdir -p lib/win32-ia32 + + # Build x64 version + npx prebuild --backend node-gyp --target 20.3.0 --arch x64 --platform win32 --strip --pack + # Copy to platform-specific directory + copy lib\node_printer.node lib\win32-x64\ + + # Build ia32 version + npx prebuild --backend node-gyp --target 20.3.0 --arch ia32 --platform win32 --strip --pack + # Copy to platform-specific directory + copy lib\node_printer.node lib\win32-ia32\ + + # List the directories to verify + dir lib + dir lib\win32-x64 || echo "x64 directory not found" + dir lib\win32-ia32 || echo "ia32 directory not found" + + - name: Upload Windows binaries to GitHub release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ needs.get-version.outputs.version }} + draft: true + files: | + *.tar.gz + **/*.tar.gz + append_body: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-release: + name: Publish GitHub Release + needs: [get-version, prebuild-macos, prebuild-windows] + runs-on: ubuntu-latest + steps: + - name: Publish Release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ needs.get-version.outputs.version }} + draft: false + append_body: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index 9dacf41f..792f99f2 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -27,7 +27,7 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: v${{ steps.set-version.outputs.version }} - draft: true # Initial creation as draft + draft: true name: Release v${{ steps.set-version.outputs.version }} generate_release_notes: true env: @@ -71,11 +71,11 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: v${{ needs.get-version.outputs.version }} - draft: true # Keep as draft during upload + draft: true files: | *.tar.gz **/*.tar.gz - append_body: true # Append to existing release notes + append_body: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -121,11 +121,11 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: v${{ needs.get-version.outputs.version }} - draft: true # Keep as draft during upload + draft: true files: | *.tar.gz **/*.tar.gz - append_body: true # Append to existing release notes + append_body: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -133,14 +133,12 @@ jobs: name: Publish GitHub Release needs: [get-version, prebuild-macos, prebuild-windows] runs-on: ubuntu-latest - # Optional: Add a condition to only publish on certain events or branches - # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true steps: - name: Publish Release uses: softprops/action-gh-release@v2 with: tag_name: v${{ needs.get-version.outputs.version }} - draft: false # Publish the release - append_body: true # Ensure we're updating the existing release + draft: false + append_body: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0f936e5ba8de5e85cbf2a53d527178d497fc7fc5 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 15:51:12 -0400 Subject: [PATCH 33/34] only run main on main branch push --- .github/workflows/prebuild-main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prebuild-main.yml b/.github/workflows/prebuild-main.yml index b2aca371..0fbc3382 100644 --- a/.github/workflows/prebuild-main.yml +++ b/.github/workflows/prebuild-main.yml @@ -1,7 +1,9 @@ name: Main Prebuild Binaries on: - pull_request: + push: + branches: + - main jobs: get-version: From de41d9276043d0d7ccd9c73c6ed454aac19a8350 Mon Sep 17 00:00:00 2001 From: Stephen Carlin Date: Mon, 5 May 2025 15:55:05 -0400 Subject: [PATCH 34/34] remove unused package.json script --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index f17d3b34..0a7b75f3 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ }, "scripts": { "install": "prebuild-install || node-gyp rebuild", - "prebuild-all": "prebuild --all --force --strip --verbose", "prebuild": "prebuild", "prebuild-electron": "prebuild --strip --verbose", "rebuild": "node-gyp rebuild",