Build - docs: clarify required pre-research documentation references in Critical Fixes Technical Project Plan #177
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 & Release | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "@photostructure/sqlite release: bump version (current = use package.json)" | |
| required: false | |
| type: choice | |
| default: "current" | |
| options: | |
| - current | |
| - patch | |
| - minor | |
| - major | |
| run-name: ${{ github.event_name == 'workflow_dispatch' && format('Release - {0}', github.event.inputs.version) || format('Build - {0}', github.event.head_commit.message || github.event.pull_request.title) }} | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 # Extend timeout to 30 minutes (default is 6 hours for a job) | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - run: sudo apt-get update | |
| - run: sudo apt-get install -y clang-tidy bear build-essential | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| - run: npm ci --ignore-scripts | |
| - run: npm run build:dist | |
| - run: npm run lint | |
| timeout-minutes: 20 # Give the lint step more time | |
| prebuild-mac-x64: | |
| runs-on: macos-13-large # Intel x64 runner | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| - run: npm ci --ignore-scripts | |
| - run: npm run build:native | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: prebuilds-mac-x64 | |
| path: prebuilds/ | |
| prebuild-mac-arm64: | |
| runs-on: macos-14 # Apple Silicon ARM64 runner | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| - run: npm ci --ignore-scripts | |
| - run: npm run build:native | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: prebuilds-mac-arm64 | |
| path: prebuilds/ | |
| prebuild-win-x64: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| - run: npm ci --ignore-scripts | |
| - run: npm run build:native | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: prebuilds-win-x64 | |
| path: prebuilds/ | |
| prebuild-win-arm64: | |
| runs-on: windows-latest | |
| env: | |
| TARGET_ARCH: arm64 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| - run: npm ci --ignore-scripts | |
| - run: npm run build:native | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: prebuilds-win-arm64 | |
| path: prebuilds/ | |
| prebuild-linux-glibc: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: [x64, arm64] | |
| runs-on: ubuntu-24.04 # Use newer runner for Docker support | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: ./.github/actions/setup-qemu | |
| with: | |
| arch: ${{ matrix.arch }} | |
| - run: npm ci --ignore-scripts | |
| - run: TARGET_ARCH=${{ matrix.arch }} npm run build:linux-glibc | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: prebuilds-linux-${{ matrix.arch }}-glibc | |
| path: prebuilds/ | |
| prebuild-linux-musl: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: [x64, arm64] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: ./.github/actions/setup-qemu | |
| with: | |
| arch: ${{ matrix.arch }} | |
| - run: | | |
| CONTAINER_NAME="node-sqlite-musl-build-$$" | |
| docker run -d --name "$CONTAINER_NAME" --platform linux/${{ matrix.arch == 'x64' && 'amd64' || 'arm64' }} node:20-alpine sleep 3600 | |
| docker cp . "$CONTAINER_NAME:/tmp/project" | |
| docker exec "$CONTAINER_NAME" sh -c "cd /tmp/project && apk add build-base git python3 py3-setuptools --update-cache && npm ci --ignore-scripts && npm run build:native" | |
| docker cp "$CONTAINER_NAME:/tmp/project/prebuilds" . 2>/dev/null || true | |
| docker cp "$CONTAINER_NAME:/tmp/project/build" . 2>/dev/null || true | |
| docker rm -f "$CONTAINER_NAME" >/dev/null | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: prebuilds-linux-${{ matrix.arch }}-musl | |
| path: prebuilds/ | |
| test-mac-win: | |
| needs: | |
| [ | |
| prebuild-mac-x64, | |
| prebuild-mac-arm64, | |
| prebuild-win-x64, | |
| prebuild-win-arm64, | |
| ] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-13-large, macos-14, windows-latest] | |
| node-version: [20, 22, 23, 24] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| path: ./prebuilds | |
| merge-multiple: true | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: "npm" | |
| - run: npm ci | |
| - run: npm run build:dist | |
| - run: npm test | |
| test-ubuntu: | |
| needs: [prebuild-linux-glibc] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-22.04, ubuntu-24.04] | |
| arch: [x64, arm64] | |
| node-version: [20, 22, 23, 24] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: ./.github/actions/setup-qemu | |
| with: | |
| arch: ${{ matrix.arch }} | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| path: ./prebuilds | |
| merge-multiple: true | |
| - run: npm ci | |
| - run: npm run build:dist | |
| - run: npm test | |
| test-alpine: | |
| needs: [prebuild-linux-musl] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: [x64, arm64] | |
| node-version: [20, 22, 23, 24] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: ./.github/actions/setup-qemu | |
| with: | |
| arch: ${{ matrix.arch }} | |
| - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| path: ./prebuilds | |
| merge-multiple: true | |
| - run: | | |
| docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch == 'x64' && 'amd64' || 'arm64' }} node:${{ matrix.node-version }}-alpine -c "\ | |
| apk add build-base git python3 py3-setuptools --update-cache && \ | |
| cd /tmp/project && \ | |
| npm ci && \ | |
| npm run build:dist && \ | |
| npm test" | |
| # Node.js compatibility tests require --experimental-sqlite flag and Node 22+ | |
| # We test only on Node 24 as the experimental SQLite API may change between versions | |
| test-api-compatibility: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| node-version: [24] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: "npm" | |
| - run: npm ci | |
| - run: npm run build:dist | |
| - name: Check API compatibility types (TypeScript compile-time validation) | |
| run: npm run lint:api-compat | |
| - name: Run API type compatibility tests (ensures our TypeScript types match node:sqlite) | |
| run: npm run test:api-compat | |
| - name: Run behavioral compatibility tests (validates runtime behavior matches node:sqlite) | |
| run: npm run test:node-compat | |
| publish: | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| [test-mac-win, test-ubuntu, test-alpine, lint, test-api-compatibility] | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| # Fetch full history for proper git operations | |
| fetch-depth: 0 | |
| - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| path: ./prebuilds | |
| merge-multiple: true | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: lts/* | |
| cache: "npm" | |
| registry-url: "https://registry.npmjs.org" | |
| - uses: photostructure/git-ssh-signing-action@a770c2ff3aea31d9df9f2974ac9d672f2bfe62f3 # v1.1.0 | |
| with: | |
| ssh-signing-key: ${{ secrets.SSH_SIGNING_KEY }} | |
| git-user-name: ${{ secrets.GIT_USER_NAME }} | |
| git-user-email: ${{ secrets.GIT_USER_EMAIL }} | |
| - run: ls -laR ./prebuilds | |
| - run: npm ci | |
| - run: npm run prepare-release | |
| - name: Version and tag release | |
| run: | | |
| # Handle version bump based on input | |
| if [ "${{ github.event.inputs.version }}" = "current" ]; then | |
| # Use the version from package.json, stripping any pre-release suffix | |
| RELEASE_VERSION=$(node -p "require('./package.json').version.replace(/-.*$/, '')") | |
| npm version $RELEASE_VERSION --message "release: %s" | |
| else | |
| # Normal version bump (patch, minor, major) | |
| npm version ${{ github.event.inputs.version }} --message "release: %s" | |
| fi | |
| # Get the new version for later use | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#environment-files | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| - name: Publish to npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish | |
| - name: Create GitHub Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Push the version commit and tag | |
| git push origin main --follow-tags | |
| # Create GitHub release | |
| gh release create "v$NEW_VERSION" \ | |
| --title "Release v$NEW_VERSION" \ | |
| --generate-notes \ | |
| --verify-tag |