0.1.5 #7
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*" | |
| 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 | |
| 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: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./prebuilds | |
| - name: Create GitHub Release (uses PAT) | |
| id: create_release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.ref }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
| - name: Upload prebuilds to Release (uses PAT) | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: prebuilds/**/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
| - name: Authenticate to npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| # Write a temporary .npmrc so npm publish is authenticated on the runner | |
| echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc | |
| - name: Publish to npm | |
| run: | | |
| npm publish --access public --ignore-scripts |