ci: give prebuild jobs contents:write so release uploads work #152
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: build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| release: | |
| types: | |
| - released | |
| workflow_dispatch: {} | |
| env: | |
| # See https://github.com/nodejs/release#release-schedule | |
| # Node.js v20 EOL = 2026-04-30. v22 EOL = 2027-04-30. v23 EOL = 2025-06-01. v24 EOL = 2028-04-30. v25 EOL = 2026-06-01. | |
| # Node.js 20-24 can build with GCC 10 (bullseye) | |
| NODE_BUILD_CMD_LEGACY: npx --no-install prebuild -r node -t 20.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 --include-regex '_sqlite3' | |
| # Node.js 25+ requires GCC 11+ for <source_location> header (bookworm) | |
| NODE_BUILD_CMD_MODERN: npx --no-install prebuild -r node -t 25.0.0 --include-regex '_sqlite3' | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-22.04 | |
| - macos-15 | |
| - macos-15-intel | |
| - windows-2022 | |
| node: | |
| - 20 | |
| - 22 | |
| - 23 | |
| - 24 | |
| - 25 | |
| name: Testing Node ${{ matrix.node }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - if: ${{ startsWith(matrix.os, 'windows') }} | |
| run: pip.exe install setuptools | |
| - if: ${{ startsWith(matrix.os, 'macos') }} | |
| run: brew install python-setuptools icu4c | |
| - if: ${{ !startsWith(matrix.os, 'windows') && !startsWith(matrix.os, 'macos') }} | |
| run: python3 -m pip install setuptools | |
| - if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.node < 25 }} | |
| run: | | |
| sudo apt update | |
| sudo apt install -y gcc-10 g++-10 libreadline-dev libncurses5-dev libicu-dev | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 | |
| - if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.node >= 25 }} | |
| run: | | |
| sudo apt update | |
| sudo apt install -y gcc-11 g++-11 libreadline-dev libncurses5-dev libicu-dev | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 | |
| - run: npm install --ignore-scripts | |
| - run: npm run build-debug | |
| - run: npm test | |
| - run: npm run build-release | |
| - name: Test shell wrapper (Windows) | |
| if: ${{ startsWith(matrix.os, 'windows') }} | |
| shell: powershell | |
| run: | | |
| echo "SELECT 'wrapper test';" | node shell.js | |
| node shell.js --version | |
| - name: Test shell wrapper (Unix) | |
| if: ${{ !startsWith(matrix.os, 'windows') }} | |
| shell: bash | |
| run: | | |
| echo "SELECT 'wrapper test';" | node shell.js | |
| node shell.js --version | |
| test-bun: | |
| strategy: | |
| matrix: | |
| os: | |
| - ubuntu-22.04 | |
| - macos-15 | |
| - macos-15-intel | |
| bun: | |
| - 1.3.5 | |
| name: Testing Bun ${{ matrix.bun }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 | |
| with: | |
| bun-version: ${{ matrix.bun }} | |
| - if: ${{ startsWith(matrix.os, 'macos') }} | |
| run: brew install python-setuptools icu4c | |
| - if: ${{ !startsWith(matrix.os, 'macos') }} | |
| run: python3 -m pip install setuptools | |
| - if: ${{ startsWith(matrix.os, 'ubuntu') }} | |
| run: | | |
| sudo apt update | |
| sudo apt install -y gcc-10 g++-10 libreadline-dev libncurses5-dev libicu-dev | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 | |
| - run: bun install --ignore-scripts | |
| - run: bun run build-debug | |
| - run: bun run test | |
| - run: bun run build-release | |
| - name: Test shell wrapper (Windows) | |
| if: ${{ startsWith(matrix.os, 'windows') }} | |
| shell: powershell | |
| run: | | |
| echo "SELECT 'wrapper test';" | bun shell.js | |
| bun shell.js --version | |
| - name: Test shell wrapper (Unix) | |
| if: ${{ !startsWith(matrix.os, 'windows') }} | |
| shell: bash | |
| run: | | |
| echo "SELECT 'wrapper test';" | bun shell.js | |
| bun shell.js --version | |
| publish: | |
| if: ${{ github.event_name == 'release' }} | |
| name: Publishing to NPM | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| id-token: write # Required for OIDC trusted publishing | |
| contents: read | |
| needs: | |
| - prebuild | |
| - prebuild-alpine | |
| - prebuild-alpine-arm | |
| - prebuild-linux-x64 | |
| - prebuild-linux-arm | |
| - prebuild-linux-x64-node-modern | |
| - prebuild-linux-arm-node-modern | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - name: Upgrade npm for OIDC support | |
| run: npm install -g npm@latest | |
| - run: npm publish --provenance | |
| prebuild: | |
| if: ${{ github.event_name == 'release' }} | |
| permissions: | |
| contents: write # prebuild -u uploads the .node assets to the GitHub release | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - macos-15 | |
| - macos-15-intel | |
| - windows-2022 | |
| name: Prebuild on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: 20 | |
| - if: ${{ startsWith(matrix.os, 'windows') }} | |
| run: pip.exe install setuptools | |
| - if: ${{ startsWith(matrix.os, 'macos') }} | |
| run: brew install python-setuptools icu4c | |
| - run: npm install --ignore-scripts | |
| - run: ${{ env.NODE_BUILD_CMD_LEGACY }} -u ${{ secrets.GITHUB_TOKEN }} | |
| - run: ${{ env.NODE_BUILD_CMD_MODERN }} -u ${{ secrets.GITHUB_TOKEN }} | |
| - if: matrix.os == 'windows-2022' | |
| run: | | |
| ${{ env.NODE_BUILD_CMD_LEGACY }} --arch ia32 -u ${{ secrets.GITHUB_TOKEN }} | |
| ${{ env.NODE_BUILD_CMD_MODERN }} --arch ia32 -u ${{ secrets.GITHUB_TOKEN }} | |
| ${{ env.NODE_BUILD_CMD_LEGACY }} --arch arm64 -u ${{ secrets.GITHUB_TOKEN }} | |
| ${{ env.NODE_BUILD_CMD_MODERN }} --arch arm64 -u ${{ secrets.GITHUB_TOKEN }} | |
| prebuild-linux-x64: | |
| if: ${{ github.event_name == 'release' }} | |
| permissions: | |
| contents: write # prebuild -u uploads the .node assets to the GitHub release | |
| name: Prebuild on Linux x64 | |
| runs-on: ubuntu-latest | |
| container: node:20-bullseye | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - run: apt-get update && apt-get install -y libicu-dev | |
| - run: npm install --ignore-scripts | |
| - run: ${{ env.NODE_BUILD_CMD_LEGACY }} -u ${{ secrets.GITHUB_TOKEN }} | |
| prebuild-linux-x64-node-modern: | |
| if: ${{ github.event_name == 'release' }} | |
| permissions: | |
| contents: write # prebuild -u uploads the .node assets to the GitHub release | |
| name: Prebuild on Linux x64 (Node 25+) | |
| runs-on: ubuntu-latest | |
| container: node:20-bookworm | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - run: apt-get update && apt-get install -y libicu-dev | |
| - run: npm install --ignore-scripts | |
| - run: ${{ env.NODE_BUILD_CMD_MODERN }} -u ${{ secrets.GITHUB_TOKEN }} | |
| prebuild-alpine: | |
| if: ${{ github.event_name == 'release' }} | |
| permissions: | |
| contents: write # prebuild -u uploads the .node assets to the GitHub release | |
| name: Prebuild on alpine | |
| runs-on: ubuntu-latest | |
| container: node:20-alpine | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - run: apk add build-base git python3 py3-setuptools libstdc++ readline-dev ncurses-dev icu-dev icu-static --update-cache | |
| - run: npm install --ignore-scripts | |
| - run: ${{ env.NODE_BUILD_CMD_LEGACY }} -u ${{ secrets.GITHUB_TOKEN }} | |
| - run: ${{ env.NODE_BUILD_CMD_MODERN }} -u ${{ secrets.GITHUB_TOKEN }} | |
| prebuild-alpine-arm: | |
| if: ${{ github.event_name == 'release' }} | |
| permissions: | |
| contents: write # prebuild -u uploads the .node assets to the GitHub release | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: | |
| - arm/v7 | |
| - arm64 | |
| name: Prebuild on alpine (${{ matrix.arch }}) | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3 | |
| - run: | | |
| docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch }} node:20-alpine -c "\ | |
| apk add build-base git python3 py3-setuptools libstdc++ readline-dev ncurses-dev icu-dev icu-static --update-cache && \ | |
| cd /tmp/project && \ | |
| npm install --ignore-scripts && \ | |
| ${{ env.NODE_BUILD_CMD_LEGACY }} -u ${{ secrets.GITHUB_TOKEN }} && \ | |
| ${{ env.NODE_BUILD_CMD_MODERN }} -u ${{ secrets.GITHUB_TOKEN }}" | |
| prebuild-linux-arm: | |
| if: ${{ github.event_name == 'release' }} | |
| permissions: | |
| contents: write # prebuild -u uploads the .node assets to the GitHub release | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: | |
| - arm/v7 | |
| - arm64 | |
| name: Prebuild on Linux (${{ matrix.arch }}) | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3 | |
| - run: | | |
| docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch }} node:20-bullseye -c "\ | |
| apt-get update && apt-get install -y libicu-dev && \ | |
| cd /tmp/project && \ | |
| npm install --ignore-scripts && \ | |
| ${{ env.NODE_BUILD_CMD_LEGACY }} -u ${{ secrets.GITHUB_TOKEN }}" | |
| prebuild-linux-arm-node-modern: | |
| if: ${{ github.event_name == 'release' }} | |
| permissions: | |
| contents: write # prebuild -u uploads the .node assets to the GitHub release | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: | |
| - arm/v7 | |
| - arm64 | |
| name: Prebuild on Linux (${{ matrix.arch }}) (Node 25+) | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3 | |
| - run: | | |
| docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch }} node:20-bookworm -c "\ | |
| apt-get update && apt-get install -y libicu-dev && \ | |
| cd /tmp/project && \ | |
| npm install --ignore-scripts && \ | |
| ${{ env.NODE_BUILD_CMD_MODERN }} -u ${{ secrets.GITHUB_TOKEN }}" |