|
| 1 | +name: CI |
| 2 | +env: |
| 3 | + DEBUG: napi:* |
| 4 | + APP_NAME: libsql |
| 5 | + MACOSX_DEPLOYMENT_TARGET: '10.13' |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + id-token: write |
| 9 | +'on': |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + tags-ignore: |
| 14 | + - '**' |
| 15 | + paths-ignore: |
| 16 | + - '**/*.md' |
| 17 | + - LICENSE |
| 18 | + - '**/*.gitignore' |
| 19 | + - .editorconfig |
| 20 | + - docs/** |
| 21 | + pull_request: null |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + settings: |
| 28 | + - host: macos-latest |
| 29 | + target: x86_64-apple-darwin |
| 30 | + build: yarn build --target x86_64-apple-darwin |
| 31 | + - host: windows-latest |
| 32 | + build: yarn build --target x86_64-pc-windows-msvc |
| 33 | + target: x86_64-pc-windows-msvc |
| 34 | + - host: ubuntu-latest |
| 35 | + target: x86_64-unknown-linux-gnu |
| 36 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian |
| 37 | + build: yarn build --target x86_64-unknown-linux-gnu |
| 38 | + - host: ubuntu-latest |
| 39 | + target: x86_64-unknown-linux-musl |
| 40 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 41 | + build: yarn build --target x86_64-unknown-linux-musl |
| 42 | + - host: macos-latest |
| 43 | + target: aarch64-apple-darwin |
| 44 | + build: yarn build --target aarch64-apple-darwin |
| 45 | + - host: ubuntu-latest |
| 46 | + target: aarch64-unknown-linux-gnu |
| 47 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 |
| 48 | + build: yarn build --target aarch64-unknown-linux-gnu |
| 49 | + - host: ubuntu-latest |
| 50 | + target: aarch64-unknown-linux-musl |
| 51 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 52 | + build: |- |
| 53 | + set -e && |
| 54 | + rustup target add aarch64-unknown-linux-musl && |
| 55 | + yarn build --target aarch64-unknown-linux-musl |
| 56 | + name: stable - ${{ matrix.settings.target }} - node@20 |
| 57 | + runs-on: ${{ matrix.settings.host }} |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + - name: Setup node |
| 61 | + uses: actions/setup-node@v4 |
| 62 | + if: ${{ !matrix.settings.docker }} |
| 63 | + with: |
| 64 | + node-version: 20 |
| 65 | + cache: yarn |
| 66 | + - name: Install |
| 67 | + uses: dtolnay/rust-toolchain@stable |
| 68 | + if: ${{ !matrix.settings.docker }} |
| 69 | + with: |
| 70 | + toolchain: stable |
| 71 | + targets: ${{ matrix.settings.target }} |
| 72 | + - name: Cache cargo |
| 73 | + uses: actions/cache@v4 |
| 74 | + with: |
| 75 | + path: | |
| 76 | + ~/.cargo/registry/index/ |
| 77 | + ~/.cargo/registry/cache/ |
| 78 | + ~/.cargo/git/db/ |
| 79 | + .cargo-cache |
| 80 | + target/ |
| 81 | + key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} |
| 82 | + - uses: goto-bus-stop/setup-zig@v2 |
| 83 | + if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }} |
| 84 | + with: |
| 85 | + version: 0.13.0 |
| 86 | + - name: Setup toolchain |
| 87 | + run: ${{ matrix.settings.setup }} |
| 88 | + if: ${{ matrix.settings.setup }} |
| 89 | + shell: bash |
| 90 | + - name: Setup node x86 |
| 91 | + if: matrix.settings.target == 'i686-pc-windows-msvc' |
| 92 | + run: yarn config set supportedArchitectures.cpu "ia32" |
| 93 | + shell: bash |
| 94 | + - name: Install dependencies |
| 95 | + run: yarn install |
| 96 | + - name: Setup node x86 |
| 97 | + uses: actions/setup-node@v4 |
| 98 | + if: matrix.settings.target == 'i686-pc-windows-msvc' |
| 99 | + with: |
| 100 | + node-version: 20 |
| 101 | + cache: yarn |
| 102 | + architecture: x86 |
| 103 | + - name: Build in docker |
| 104 | + uses: addnab/docker-run-action@v3 |
| 105 | + if: ${{ matrix.settings.docker }} |
| 106 | + with: |
| 107 | + image: ${{ matrix.settings.docker }} |
| 108 | + options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build' |
| 109 | + run: ${{ matrix.settings.build }} |
| 110 | + - name: Build |
| 111 | + run: ${{ matrix.settings.build }} |
| 112 | + if: ${{ !matrix.settings.docker }} |
| 113 | + shell: bash |
| 114 | + - name: Upload artifact |
| 115 | + uses: actions/upload-artifact@v4 |
| 116 | + with: |
| 117 | + name: bindings-${{ matrix.settings.target }} |
| 118 | + path: ${{ env.APP_NAME }}.*.node |
| 119 | + if-no-files-found: error |
| 120 | + test-macOS-windows-binding: |
| 121 | + name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} |
| 122 | + needs: |
| 123 | + - build |
| 124 | + strategy: |
| 125 | + fail-fast: false |
| 126 | + matrix: |
| 127 | + settings: |
| 128 | + - host: macos-latest |
| 129 | + target: x86_64-apple-darwin |
| 130 | + - host: windows-latest |
| 131 | + target: x86_64-pc-windows-msvc |
| 132 | + node: |
| 133 | + - '18' |
| 134 | + - '20' |
| 135 | + runs-on: ${{ matrix.settings.host }} |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v4 |
| 138 | + - name: Setup node |
| 139 | + uses: actions/setup-node@v4 |
| 140 | + with: |
| 141 | + node-version: ${{ matrix.node }} |
| 142 | + cache: yarn |
| 143 | + architecture: x64 |
| 144 | + - name: Install dependencies |
| 145 | + run: yarn install |
| 146 | + - name: Download artifacts |
| 147 | + uses: actions/download-artifact@v4 |
| 148 | + with: |
| 149 | + name: bindings-${{ matrix.settings.target }} |
| 150 | + path: . |
| 151 | + - name: List packages |
| 152 | + run: ls -R . |
| 153 | + shell: bash |
| 154 | + - name: Test bindings |
| 155 | + run: yarn test |
| 156 | + test-linux-x64-gnu-binding: |
| 157 | + name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} |
| 158 | + needs: |
| 159 | + - build |
| 160 | + strategy: |
| 161 | + fail-fast: false |
| 162 | + matrix: |
| 163 | + node: |
| 164 | + - '18' |
| 165 | + - '20' |
| 166 | + runs-on: ubuntu-latest |
| 167 | + steps: |
| 168 | + - uses: actions/checkout@v4 |
| 169 | + - name: Setup node |
| 170 | + uses: actions/setup-node@v4 |
| 171 | + with: |
| 172 | + node-version: ${{ matrix.node }} |
| 173 | + cache: yarn |
| 174 | + - name: Install dependencies |
| 175 | + run: yarn install |
| 176 | + - name: Download artifacts |
| 177 | + uses: actions/download-artifact@v4 |
| 178 | + with: |
| 179 | + name: bindings-x86_64-unknown-linux-gnu |
| 180 | + path: . |
| 181 | + - name: List packages |
| 182 | + run: ls -R . |
| 183 | + shell: bash |
| 184 | + - name: Test bindings |
| 185 | + run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn test |
| 186 | + test-linux-x64-musl-binding: |
| 187 | + name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} |
| 188 | + needs: |
| 189 | + - build |
| 190 | + strategy: |
| 191 | + fail-fast: false |
| 192 | + matrix: |
| 193 | + node: |
| 194 | + - '18' |
| 195 | + - '20' |
| 196 | + runs-on: ubuntu-latest |
| 197 | + steps: |
| 198 | + - uses: actions/checkout@v4 |
| 199 | + - name: Setup node |
| 200 | + uses: actions/setup-node@v4 |
| 201 | + with: |
| 202 | + node-version: ${{ matrix.node }} |
| 203 | + cache: yarn |
| 204 | + - name: Install dependencies |
| 205 | + run: | |
| 206 | + yarn config set supportedArchitectures.libc "musl" |
| 207 | + yarn install |
| 208 | + - name: Download artifacts |
| 209 | + uses: actions/download-artifact@v4 |
| 210 | + with: |
| 211 | + name: bindings-x86_64-unknown-linux-musl |
| 212 | + path: . |
| 213 | + - name: List packages |
| 214 | + run: ls -R . |
| 215 | + shell: bash |
| 216 | + - name: Test bindings |
| 217 | + run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-alpine yarn test |
| 218 | + test-linux-aarch64-gnu-binding: |
| 219 | + name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} |
| 220 | + needs: |
| 221 | + - build |
| 222 | + strategy: |
| 223 | + fail-fast: false |
| 224 | + matrix: |
| 225 | + node: |
| 226 | + - '18' |
| 227 | + - '20' |
| 228 | + runs-on: ubuntu-latest |
| 229 | + steps: |
| 230 | + - uses: actions/checkout@v4 |
| 231 | + - name: Download artifacts |
| 232 | + uses: actions/download-artifact@v4 |
| 233 | + with: |
| 234 | + name: bindings-aarch64-unknown-linux-gnu |
| 235 | + path: . |
| 236 | + - name: List packages |
| 237 | + run: ls -R . |
| 238 | + shell: bash |
| 239 | + - name: Install dependencies |
| 240 | + run: | |
| 241 | + yarn config set supportedArchitectures.cpu "arm64" |
| 242 | + yarn config set supportedArchitectures.libc "glibc" |
| 243 | + yarn install |
| 244 | + - name: Set up QEMU |
| 245 | + uses: docker/setup-qemu-action@v3 |
| 246 | + with: |
| 247 | + platforms: arm64 |
| 248 | + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 249 | + - name: Setup and run tests |
| 250 | + uses: addnab/docker-run-action@v3 |
| 251 | + with: |
| 252 | + image: node:${{ matrix.node }}-slim |
| 253 | + options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build' |
| 254 | + run: | |
| 255 | + set -e |
| 256 | + yarn test |
| 257 | + ls -la |
| 258 | + test-linux-aarch64-musl-binding: |
| 259 | + name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} |
| 260 | + needs: |
| 261 | + - build |
| 262 | + runs-on: ubuntu-latest |
| 263 | + steps: |
| 264 | + - uses: actions/checkout@v4 |
| 265 | + - name: Download artifacts |
| 266 | + uses: actions/download-artifact@v4 |
| 267 | + with: |
| 268 | + name: bindings-aarch64-unknown-linux-musl |
| 269 | + path: . |
| 270 | + - name: List packages |
| 271 | + run: ls -R . |
| 272 | + shell: bash |
| 273 | + - name: Install dependencies |
| 274 | + run: | |
| 275 | + yarn config set supportedArchitectures.cpu "arm64" |
| 276 | + yarn config set supportedArchitectures.libc "musl" |
| 277 | + yarn install |
| 278 | + - name: Set up QEMU |
| 279 | + uses: docker/setup-qemu-action@v3 |
| 280 | + with: |
| 281 | + platforms: arm64 |
| 282 | + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 283 | + - name: Setup and run tests |
| 284 | + uses: addnab/docker-run-action@v3 |
| 285 | + with: |
| 286 | + image: node:lts-alpine |
| 287 | + options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build' |
| 288 | + run: | |
| 289 | + set -e |
| 290 | + yarn test |
| 291 | + publish: |
| 292 | + name: Publish |
| 293 | + runs-on: ubuntu-latest |
| 294 | + needs: |
| 295 | + - test-macOS-windows-binding |
| 296 | + - test-linux-x64-gnu-binding |
| 297 | + - test-linux-x64-musl-binding |
| 298 | + - test-linux-aarch64-gnu-binding |
| 299 | + - test-linux-aarch64-musl-binding |
| 300 | + steps: |
| 301 | + - uses: actions/checkout@v4 |
| 302 | + - name: Setup node |
| 303 | + uses: actions/setup-node@v4 |
| 304 | + with: |
| 305 | + node-version: 20 |
| 306 | + cache: yarn |
| 307 | + - name: Install dependencies |
| 308 | + run: yarn install |
| 309 | + - name: Download all artifacts |
| 310 | + uses: actions/download-artifact@v4 |
| 311 | + with: |
| 312 | + path: artifacts |
| 313 | + - name: Move artifacts |
| 314 | + run: yarn artifacts |
| 315 | + - name: List packages |
| 316 | + run: ls -R ./npm |
| 317 | + shell: bash |
| 318 | + - name: Publish |
| 319 | + run: | |
| 320 | + npm config set provenance true |
| 321 | + if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; |
| 322 | + then |
| 323 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 324 | + npm publish --access public |
| 325 | + elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; |
| 326 | + then |
| 327 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 328 | + npm publish --tag next --access public |
| 329 | + else |
| 330 | + echo "Not a release, skipping publish" |
| 331 | + fi |
| 332 | + env: |
| 333 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 334 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments