promise api #37
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: CI | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - '*' | |
| env: | |
| FORCE_COLOR: 1 | |
| jobs: | |
| verify-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Verify tag version matches package.json | |
| run: | | |
| # Check if we're running on a tag | |
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| # Extract tag name from GITHUB_REF (e.g., refs/tags/v6.0.2 -> v6.0.2) | |
| TAG_NAME="${GITHUB_REF#refs/tags/}" | |
| # Remove 'v' prefix if present to get the version number | |
| TAG_VERSION="${TAG_NAME#v}" | |
| # Get version from package.json | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| echo "Tag version: $TAG_VERSION" | |
| echo "Package version: $PACKAGE_VERSION" | |
| if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then | |
| echo "ERROR: Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)" | |
| echo "Please update package.json or create a new tag with the correct version" | |
| echo "GitHub release will NOT be created." | |
| exit 1 | |
| fi | |
| echo "Version match verified!" | |
| else | |
| echo "Skipping version verification - not a tag event" | |
| fi | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile --ignore-scripts | |
| - name: Run lint | |
| run: yarn lint | |
| build: | |
| needs: [verify-version, lint] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - macos-latest | |
| - ubuntu-24.04 | |
| - windows-latest | |
| host: | |
| - x64 | |
| target: | |
| - x64 | |
| node: | |
| - 20 | |
| - 22 | |
| - 24 | |
| exclude: | |
| # Node 20 x64 crashes under Rosetta 2 on ARM64 macOS runners | |
| - os: macos-latest | |
| node: 20 | |
| host: x64 | |
| include: | |
| - os: macos-latest | |
| node: 20 | |
| host: arm64 | |
| target: arm64 | |
| - os: macos-latest | |
| node: 22 | |
| host: arm64 | |
| target: arm64 | |
| - os: macos-latest | |
| node: 24 | |
| host: arm64 | |
| target: arm64 | |
| - os: ubuntu-24.04-arm | |
| node: 20 | |
| host: arm64 | |
| target: arm64 | |
| - os: ubuntu-24.04-arm | |
| node: 22 | |
| host: arm64 | |
| target: arm64 | |
| - os: ubuntu-24.04-arm | |
| node: 24 | |
| host: arm64 | |
| target: arm64 | |
| name: ${{ matrix.os }} (node=${{ matrix.node }}, host=${{ matrix.host }}, target=${{ matrix.target }}) | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| architecture: ${{ matrix.host }} | |
| - name: Add msbuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| if: contains(matrix.os, 'windows') | |
| with: | |
| msbuild-architecture: ${{ matrix.target }} | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile --ignore-scripts | |
| - name: Check Node compatibility | |
| run: node tools/semver-check.js | |
| - name: Add env vars | |
| shell: bash | |
| run: | | |
| echo "V=1" >> $GITHUB_ENV | |
| if [ "${{ matrix.target }}" = "x86" ]; then | |
| echo "TARGET=ia32" >> $GITHUB_ENV | |
| else | |
| echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV | |
| fi | |
| - name: Add Linux env vars | |
| if: contains(matrix.os, 'ubuntu') | |
| run: | | |
| echo "CFLAGS=${CFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV | |
| echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV | |
| - name: Build binaries | |
| run: yarn prebuild -a ${{ env.TARGET }} | |
| - name: Print binary info | |
| if: contains(matrix.os, 'ubuntu') | |
| run: | | |
| ldd build/**/node_sqlite3.node | |
| echo "---" | |
| nm build/**/node_sqlite3.node | grep "GLIBC_" | c++filt || true | |
| echo "---" | |
| file build/**/node_sqlite3.node | |
| - name: Run tests | |
| run: yarn test | |
| - name: Upload binaries to commit artifacts | |
| uses: actions/upload-artifact@v7 | |
| if: matrix.node == 24 | |
| with: | |
| name: prebuilt-binaries-${{ matrix.os }}-${{ matrix.host }} | |
| path: prebuilds/* | |
| retention-days: 7 | |
| - name: Upload binaries to GitHub Release | |
| run: yarn upload --upload-all ${{ github.token }} | |
| if: matrix.node == 24 && startsWith(github.ref, 'refs/tags/') | |
| build-musl: | |
| needs: [verify-version] | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: ubuntu-24.04-arm | |
| platform: linux/arm64 | |
| arch: arm64 | |
| - runner: ubuntu-24.04 | |
| platform: linux/amd64 | |
| arch: amd64 | |
| runs-on: ${{ matrix.runner }} | |
| name: musl ${{ matrix.arch }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build binaries and test | |
| run: | | |
| docker build \ | |
| --file ./tools/BinaryBuilder.Dockerfile \ | |
| --tag sqlite-builder \ | |
| --no-cache \ | |
| --build-arg VARIANT=alpine3.20 \ | |
| --build-arg NODE_VERSION=24 \ | |
| . | |
| CONTAINER_ID=$(docker create -it sqlite-builder) | |
| docker cp $CONTAINER_ID:/usr/src/build/prebuilds/ ./prebuilds | |
| - name: Upload binaries to commit artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: prebuilt-binaries-musl-${{ matrix.arch }} | |
| path: prebuilds/* | |
| retention-days: 7 | |
| - name: Upload binaries to GitHub Release | |
| run: yarn install --frozen-lockfile --ignore-scripts && yarn upload --upload-all ${{ github.token }} | |
| if: startsWith(github.ref, 'refs/tags/') | |
| publish-npm: | |
| needs: [build, build-musl] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile --ignore-scripts | |
| - name: Publish to npm | |
| run: npm publish |