publish job will install only the packaging dependencies and skip the… #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Prebuild and Publish | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| build-prebuilds: | |
| name: Build prebuilds (Windows & Linux) | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - node: "18.x" | |
| arch: "x64" | |
| runner: windows-latest | |
| platform: win32 | |
| - node: "18.x" | |
| arch: "x64" | |
| runner: ubuntu-latest | |
| platform: linux | |
| - node: "20.x" | |
| arch: "x64" | |
| runner: windows-latest | |
| platform: win32 | |
| - node: "20.x" | |
| arch: "x64" | |
| runner: ubuntu-latest | |
| platform: linux | |
| - node: "22.x" | |
| arch: "x64" | |
| runner: windows-latest | |
| platform: win32 | |
| - node: "22.x" | |
| arch: "x64" | |
| runner: ubuntu-latest | |
| platform: linux | |
| - node: "24.x" | |
| arch: "x64" | |
| runner: windows-latest | |
| platform: win32 | |
| - node: "24.x" | |
| arch: "x64" | |
| runner: ubuntu-latest | |
| platform: linux | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: Install Linux build deps | |
| if: ${{ matrix.platform == 'linux' }} | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libcups2-dev build-essential python3 | |
| shell: bash | |
| - name: Install deps | |
| run: npm ci | |
| - name: Build native addon | |
| run: npm run build | |
| - name: Create prebuild artifact (Windows) | |
| if: ${{ matrix.platform == 'win32' }} | |
| id: prebuild | |
| env: | |
| npm_config_disturl: https://nodejs.org/dist | |
| run: | | |
| if (!(Test-Path prebuilds)) { New-Item -ItemType Directory -Path prebuilds | Out-Null } | |
| $nodever = (node -v).Trim() | |
| Write-Host "Detected node runtime: $nodever" | |
| npx --no-install prebuild --strip --target $nodever --arch=${{ matrix.arch }} --platform=win32 --runtime=node --out prebuilds | |
| Write-Host "Created prebuilds:"; Get-ChildItem prebuilds | ForEach-Object { Write-Host $_.FullName } | |
| - name: Create prebuild artifact (Linux) | |
| if: ${{ matrix.platform == 'linux' }} | |
| id: prebuild-linux | |
| env: | |
| npm_config_disturl: https://nodejs.org/dist | |
| run: | | |
| mkdir -p prebuilds | |
| nodever=$(node -v) | |
| echo "Detected node runtime: $nodever" | |
| npx --no-install prebuild --strip --target $nodever --arch=${{ matrix.arch }} --platform=linux --runtime=node --out prebuilds | |
| echo "Created prebuilds:"; ls -la prebuilds | |
| shell: bash | |
| - name: Upload prebuild artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: prebuilds-${{ matrix.node }}-${{ matrix.arch }}-${{ matrix.platform }} | |
| path: prebuilds/* | |
| publish: | |
| name: Create release and publish | |
| runs-on: ubuntu-latest | |
| needs: build-prebuilds | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install deps | |
| run: npm ci --ignore-scripts | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./prebuilds | |
| - name: Create or update GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: prebuilds/**/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
| - name: Publish to npm | |
| run: npm publish |