| 1 | name: NPM Publish |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | tags: |
| 6 | - "v*" |
| 7 | |
| 8 | jobs: |
| 9 | node: |
| 10 | name: vectordb Typescript |
| 11 | runs-on: ubuntu-latest |
| 12 | # Only runs on tags that matches the make-release action |
| 13 | if: startsWith(github.ref, 'refs/tags/v') |
| 14 | defaults: |
| 15 | run: |
| 16 | shell: bash |
| 17 | working-directory: node |
| 18 | steps: |
| 19 | - name: Checkout |
| 20 | uses: actions/checkout@v4 |
| 21 | - uses: actions/setup-node@v3 |
| 22 | with: |
| 23 | node-version: 20 |
| 24 | cache: "npm" |
| 25 | cache-dependency-path: node/package-lock.json |
| 26 | - name: Install dependencies |
| 27 | run: | |
| 28 | sudo apt update |
| 29 | sudo apt install -y protobuf-compiler libssl-dev |
| 30 | - name: Build |
| 31 | run: | |
| 32 | npm ci |
| 33 | npm run tsc |
| 34 | npm pack |
| 35 | - name: Upload Linux Artifacts |
| 36 | uses: actions/upload-artifact@v4 |
| 37 | with: |
| 38 | name: node-package |
| 39 | path: | |
| 40 | node/vectordb-*.tgz |
| 41 | |
| 42 | node-macos: |
| 43 | name: vectordb ${{ matrix.config.arch }} |
| 44 | strategy: |
| 45 | matrix: |
| 46 | config: |
| 47 | - arch: x86_64-apple-darwin |
| 48 | runner: macos-13 |
| 49 | - arch: aarch64-apple-darwin |
| 50 | # xlarge is implicitly arm64. |
| 51 | runner: macos-14 |
| 52 | runs-on: ${{ matrix.config.runner }} |
| 53 | # Only runs on tags that matches the make-release action |
| 54 | if: startsWith(github.ref, 'refs/tags/v') |
| 55 | steps: |
| 56 | - name: Checkout |
| 57 | uses: actions/checkout@v4 |
| 58 | - name: Install system dependencies |
| 59 | run: brew install protobuf |
| 60 | - name: Install npm dependencies |
| 61 | run: | |
| 62 | cd node |
| 63 | npm ci |
| 64 | - name: Build MacOS native node modules |
| 65 | run: bash ci/build_macos_artifacts.sh ${{ matrix.config.arch }} |
| 66 | - name: Upload Darwin Artifacts |
| 67 | uses: actions/upload-artifact@v4 |
| 68 | with: |
| 69 | name: node-native-darwin-${{ matrix.config.arch }} |
| 70 | path: | |
| 71 | node/dist/lancedb-vectordb-darwin*.tgz |
| 72 | |
| 73 | nodejs-macos: |
| 74 | name: lancedb ${{ matrix.config.arch }} |
| 75 | strategy: |
| 76 | matrix: |
| 77 | config: |
| 78 | - arch: x86_64-apple-darwin |
| 79 | runner: macos-13 |
| 80 | - arch: aarch64-apple-darwin |
| 81 | # xlarge is implicitly arm64. |
| 82 | runner: macos-14 |
| 83 | runs-on: ${{ matrix.config.runner }} |
| 84 | # Only runs on tags that matches the make-release action |
| 85 | if: startsWith(github.ref, 'refs/tags/v') |
| 86 | steps: |
| 87 | - name: Checkout |
| 88 | uses: actions/checkout@v4 |
| 89 | - name: Install system dependencies |
| 90 | run: brew install protobuf |
| 91 | - name: Install npm dependencies |
| 92 | run: | |
| 93 | cd nodejs |
| 94 | npm ci |
| 95 | - name: Build MacOS native nodejs modules |
| 96 | run: bash ci/build_macos_artifacts_nodejs.sh ${{ matrix.config.arch }} |
| 97 | - name: Upload Darwin Artifacts |
| 98 | uses: actions/upload-artifact@v4 |
| 99 | with: |
| 100 | name: nodejs-native-darwin-${{ matrix.config.arch }} |
| 101 | path: | |
| 102 | nodejs/dist/*.node |
| 103 | |
| 104 | node-linux: |
| 105 | name: vectordb (${{ matrix.config.arch}}-unknown-linux-gnu) |
| 106 | runs-on: ${{ matrix.config.runner }} |
| 107 | # Only runs on tags that matches the make-release action |
| 108 | if: startsWith(github.ref, 'refs/tags/v') |
| 109 | strategy: |
| 110 | fail-fast: false |
| 111 | matrix: |
| 112 | config: |
| 113 | - arch: x86_64 |
| 114 | runner: ubuntu-latest |
| 115 | - arch: aarch64 |
| 116 | # For successful fat LTO builds, we need a large runner to avoid OOM errors. |
| 117 | runner: warp-ubuntu-latest-arm64-4x |
| 118 | steps: |
| 119 | - name: Checkout |
| 120 | uses: actions/checkout@v4 |
| 121 | # To avoid OOM errors on ARM, we create a swap file. |
| 122 | - name: Configure aarch64 build |
| 123 | if: ${{ matrix.config.arch == 'aarch64' }} |
| 124 | run: | |
| 125 | free -h |
| 126 | sudo fallocate -l 16G /swapfile |
| 127 | sudo chmod 600 /swapfile |
| 128 | sudo mkswap /swapfile |
| 129 | sudo swapon /swapfile |
| 130 | echo "/swapfile swap swap defaults 0 0" >> sudo /etc/fstab |
| 131 | # print info |
| 132 | swapon --show |
| 133 | free -h |
| 134 | - name: Build Linux Artifacts |
| 135 | run: | |
| 136 | bash ci/build_linux_artifacts.sh ${{ matrix.config.arch }} |
| 137 | - name: Upload Linux Artifacts |
| 138 | uses: actions/upload-artifact@v4 |
| 139 | with: |
| 140 | name: node-native-linux-${{ matrix.config.arch }} |
| 141 | path: | |
| 142 | node/dist/lancedb-vectordb-linux*.tgz |
| 143 | |
| 144 | nodejs-linux: |
| 145 | name: lancedb (${{ matrix.config.arch}}-unknown-linux-gnu |
| 146 | runs-on: ${{ matrix.config.runner }} |
| 147 | # Only runs on tags that matches the make-release action |
| 148 | if: startsWith(github.ref, 'refs/tags/v') |
| 149 | strategy: |
| 150 | fail-fast: false |
| 151 | matrix: |
| 152 | config: |
| 153 | - arch: x86_64 |
| 154 | runner: ubuntu-latest |
| 155 | - arch: aarch64 |
| 156 | # For successful fat LTO builds, we need a large runner to avoid OOM errors. |
| 157 | runner: buildjet-16vcpu-ubuntu-2204-arm |
| 158 | steps: |
| 159 | - name: Checkout |
| 160 | uses: actions/checkout@v4 |
| 161 | # Buildjet aarch64 runners have only 1.5 GB RAM per core, vs 3.5 GB per core for |
| 162 | # x86_64 runners. To avoid OOM errors on ARM, we create a swap file. |
| 163 | - name: Configure aarch64 build |
| 164 | if: ${{ matrix.config.arch == 'aarch64' }} |
| 165 | run: | |
| 166 | free -h |
| 167 | sudo fallocate -l 16G /swapfile |
| 168 | sudo chmod 600 /swapfile |
| 169 | sudo mkswap /swapfile |
| 170 | sudo swapon /swapfile |
| 171 | echo "/swapfile swap swap defaults 0 0" >> sudo /etc/fstab |
| 172 | # print info |
| 173 | swapon --show |
| 174 | free -h |
| 175 | - name: Build Linux Artifacts |
| 176 | run: | |
| 177 | bash ci/build_linux_artifacts_nodejs.sh ${{ matrix.config.arch }} |
| 178 | - name: Upload Linux Artifacts |
| 179 | uses: actions/upload-artifact@v4 |
| 180 | with: |
| 181 | name: nodejs-native-linux-${{ matrix.config.arch }} |
| 182 | path: | |
| 183 | nodejs/dist/*.node |
| 184 | # The generic files are the same in all distros so we just pick |
| 185 | # one to do the upload. |
| 186 | - name: Upload Generic Artifacts |
| 187 | if: ${{ matrix.config.arch == 'x86_64' }} |
| 188 | uses: actions/upload-artifact@v4 |
| 189 | with: |
| 190 | name: nodejs-dist |
| 191 | path: | |
| 192 | nodejs/dist/* |
| 193 | !nodejs/dist/*.node |
| 194 | |
| 195 | node-windows: |
| 196 | name: vectordb ${{ matrix.target }} |
| 197 | runs-on: windows-2022 |
| 198 | # Only runs on tags that matches the make-release action |
| 199 | if: startsWith(github.ref, 'refs/tags/v') |
| 200 | strategy: |
| 201 | fail-fast: false |
| 202 | matrix: |
| 203 | target: [x86_64-pc-windows-msvc] |
| 204 | steps: |
| 205 | - name: Checkout |
| 206 | uses: actions/checkout@v4 |
| 207 | - name: Install Protoc v21.12 |
| 208 | working-directory: C:\ |
| 209 | run: | |
| 210 | New-Item -Path 'C:\protoc' -ItemType Directory |
| 211 | Set-Location C:\protoc |
| 212 | Invoke-WebRequest https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-win64.zip -OutFile C:\protoc\protoc.zip |
| 213 | 7z x protoc.zip |
| 214 | Add-Content $env:GITHUB_PATH "C:\protoc\bin" |
| 215 | shell: powershell |
| 216 | - name: Install npm dependencies |
| 217 | run: | |
| 218 | cd node |
| 219 | npm ci |
| 220 | - name: Build Windows native node modules |
| 221 | run: .\ci\build_windows_artifacts.ps1 ${{ matrix.target }} |
| 222 | - name: Upload Windows Artifacts |
| 223 | uses: actions/upload-artifact@v4 |
| 224 | with: |
| 225 | name: node-native-windows |
| 226 | path: | |
| 227 | node/dist/lancedb-vectordb-win32*.tgz |
| 228 | |
| 229 | nodejs-windows: |
| 230 | name: lancedb ${{ matrix.target }} |
| 231 | runs-on: windows-2022 |
| 232 | # Only runs on tags that matches the make-release action |
| 233 | if: startsWith(github.ref, 'refs/tags/v') |
| 234 | strategy: |
| 235 | fail-fast: false |
| 236 | matrix: |
| 237 | target: [x86_64-pc-windows-msvc] |
| 238 | steps: |
| 239 | - name: Checkout |
| 240 | uses: actions/checkout@v4 |
| 241 | - name: Install Protoc v21.12 |
| 242 | working-directory: C:\ |
| 243 | run: | |
| 244 | New-Item -Path 'C:\protoc' -ItemType Directory |
| 245 | Set-Location C:\protoc |
| 246 | Invoke-WebRequest https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-win64.zip -OutFile C:\protoc\protoc.zip |
| 247 | 7z x protoc.zip |
| 248 | Add-Content $env:GITHUB_PATH "C:\protoc\bin" |
| 249 | shell: powershell |
| 250 | - name: Install npm dependencies |
| 251 | run: | |
| 252 | cd nodejs |
| 253 | npm ci |
| 254 | - name: Build Windows native node modules |
| 255 | run: .\ci\build_windows_artifacts_nodejs.ps1 ${{ matrix.target }} |
| 256 | - name: Upload Windows Artifacts |
| 257 | uses: actions/upload-artifact@v4 |
| 258 | with: |
| 259 | name: nodejs-native-windows |
| 260 | path: | |
| 261 | nodejs/dist/*.node |
| 262 | |
| 263 | release: |
| 264 | name: vectordb NPM Publish |
| 265 | needs: [node, node-macos, node-linux, node-windows] |
| 266 | runs-on: ubuntu-latest |
| 267 | # Only runs on tags that matches the make-release action |
| 268 | if: startsWith(github.ref, 'refs/tags/v') |
| 269 | steps: |
| 270 | - uses: actions/download-artifact@v4 |
| 271 | with: |
| 272 | pattern: node-* |
| 273 | - name: Display structure of downloaded files |
| 274 | run: ls -R |
| 275 | - uses: actions/setup-node@v3 |
| 276 | with: |
| 277 | node-version: 20 |
| 278 | registry-url: "https://registry.npmjs.org" |
| 279 | - name: Publish to NPM |
| 280 | env: |
| 281 | NODE_AUTH_TOKEN: ${{ secrets.LANCEDB_NPM_REGISTRY_TOKEN }} |
| 282 | run: | |
| 283 | # Tag beta as "preview" instead of default "latest". See lancedb |
| 284 | # npm publish step for more info. |
| 285 | if [[ $GITHUB_REF =~ refs/tags/v(.*)-beta.* ]]; then |
| 286 | PUBLISH_ARGS="--tag preview" |
| 287 | fi |
| 288 | |
| 289 | mv */*.tgz . |
| 290 | for filename in *.tgz; do |
| 291 | npm publish $PUBLISH_ARGS $filename |
| 292 | done |
| 293 | - name: Notify Slack Action |
| 294 | uses: ravsamhq/notify-slack-action@2.3.0 |
| 295 | if: ${{ always() }} |
| 296 | with: |
| 297 | status: ${{ job.status }} |
| 298 | notify_when: "failure" |
| 299 | notification_title: "{workflow} is failing" |
| 300 | env: |
| 301 | SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }} |
| 302 | |
| 303 | release-nodejs: |
| 304 | name: lancedb NPM Publish |
| 305 | needs: [nodejs-macos, nodejs-linux, nodejs-windows] |
| 306 | runs-on: ubuntu-latest |
| 307 | # Only runs on tags that matches the make-release action |
| 308 | if: startsWith(github.ref, 'refs/tags/v') |
| 309 | defaults: |
| 310 | run: |
| 311 | shell: bash |
| 312 | working-directory: nodejs |
| 313 | steps: |
| 314 | - name: Checkout |
| 315 | uses: actions/checkout@v4 |
| 316 | - uses: actions/download-artifact@v4 |
| 317 | with: |
| 318 | name: nodejs-dist |
| 319 | path: nodejs/dist |
| 320 | - uses: actions/download-artifact@v4 |
| 321 | name: Download arch-specific binaries |
| 322 | with: |
| 323 | pattern: nodejs-* |
| 324 | path: nodejs/nodejs-artifacts |
| 325 | merge-multiple: true |
| 326 | - name: Display structure of downloaded files |
| 327 | run: find . |
| 328 | - uses: actions/setup-node@v3 |
| 329 | with: |
| 330 | node-version: 20 |
| 331 | registry-url: "https://registry.npmjs.org" |
| 332 | - name: Install napi-rs |
| 333 | run: npm install -g @napi-rs/cli |
| 334 | - name: Prepare artifacts |
| 335 | run: npx napi artifacts -d nodejs-artifacts |
| 336 | - name: Display structure of staged files |
| 337 | run: find npm |
| 338 | - name: Publish to NPM |
| 339 | env: |
| 340 | NODE_AUTH_TOKEN: ${{ secrets.LANCEDB_NPM_REGISTRY_TOKEN }} |
| 341 | # By default, things are published to the latest tag. This is what is |
| 342 | # installed by default if the user does not specify a version. This is |
| 343 | # good for stable releases, but for pre-releases, we want to publish to |
| 344 | # the "preview" tag so they can install with `npm install lancedb@preview`. |
| 345 | # See: https://medium.com/@mbostock/prereleases-and-npm-e778fc5e2420 |
| 346 | run: | |
| 347 | if [[ $GITHUB_REF =~ refs/tags/v(.*)-beta.* ]]; then |
| 348 | npm publish --access public --tag preview |
| 349 | else |
| 350 | npm publish --access public |
| 351 | fi |
| 352 | - name: Notify Slack Action |
| 353 | uses: ravsamhq/notify-slack-action@2.3.0 |
| 354 | if: ${{ always() }} |
| 355 | with: |
| 356 | status: ${{ job.status }} |
| 357 | notify_when: "failure" |
| 358 | notification_title: "{workflow} is failing" |
| 359 | env: |
| 360 | SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }} |
| 361 | |
| 362 | update-package-lock: |
| 363 | needs: [release] |
| 364 | runs-on: ubuntu-latest |
| 365 | permissions: |
| 366 | contents: write |
| 367 | steps: |
| 368 | - name: Checkout |
| 369 | uses: actions/checkout@v4 |
| 370 | with: |
| 371 | ref: main |
| 372 | persist-credentials: false |
| 373 | fetch-depth: 0 |
| 374 | lfs: true |
| 375 | - uses: ./.github/workflows/update_package_lock |
| 376 | with: |
| 377 | github_token: ${{ secrets.GITHUB_TOKEN }} |
| 378 | |
| 379 | update-package-lock-nodejs: |
| 380 | needs: [release-nodejs] |
| 381 | runs-on: ubuntu-latest |
| 382 | permissions: |
| 383 | contents: write |
| 384 | steps: |
| 385 | - name: Checkout |
| 386 | uses: actions/checkout@v4 |
| 387 | with: |
| 388 | ref: main |
| 389 | persist-credentials: false |
| 390 | fetch-depth: 0 |
| 391 | lfs: true |
| 392 | - uses: ./.github/workflows/update_package_lock_nodejs |
| 393 | with: |
| 394 | github_token: ${{ secrets.GITHUB_TOKEN }} |
| 395 | |
| 396 | gh-release: |
| 397 | runs-on: ubuntu-latest |
| 398 | permissions: |
| 399 | contents: write |
| 400 | steps: |
| 401 | - uses: actions/checkout@v4 |
| 402 | with: |
| 403 | fetch-depth: 0 |
| 404 | lfs: true |
| 405 | - name: Extract version |
| 406 | id: extract_version |
| 407 | env: |
| 408 | GITHUB_REF: ${{ github.ref }} |
| 409 | run: | |
| 410 | set -e |
| 411 | echo "Extracting tag and version from $GITHUB_REF" |
| 412 | if [[ $GITHUB_REF =~ refs/tags/v(.*) ]]; then |
| 413 | VERSION=${BASH_REMATCH[1]} |
| 414 | TAG=v$VERSION |
| 415 | echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 416 | echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 417 | else |
| 418 | echo "Failed to extract version from $GITHUB_REF" |
| 419 | exit 1 |
| 420 | fi |
| 421 | echo "Extracted version $VERSION from $GITHUB_REF" |
| 422 | if [[ $VERSION =~ beta ]]; then |
| 423 | echo "This is a beta release" |
| 424 | |
| 425 | # Get last release (that is not this one) |
| 426 | FROM_TAG=$(git tag --sort='version:refname' \ |
| 427 | | grep ^v \ |
| 428 | | grep -vF "$TAG" \ |
| 429 | | python ci/semver_sort.py v \ |
| 430 | | tail -n 1) |
| 431 | else |
| 432 | echo "This is a stable release" |
| 433 | # Get last stable tag (ignore betas) |
| 434 | FROM_TAG=$(git tag --sort='version:refname' \ |
| 435 | | grep ^v \ |
| 436 | | grep -vF "$TAG" \ |
| 437 | | grep -v beta \ |
| 438 | | python ci/semver_sort.py v \ |
| 439 | | tail -n 1) |
| 440 | fi |
| 441 | echo "Found from tag $FROM_TAG" |
| 442 | echo "from_tag=$FROM_TAG" >> $GITHUB_OUTPUT |
| 443 | - name: Create Release Notes |
| 444 | id: release_notes |
| 445 | uses: mikepenz/release-changelog-builder-action@v4 |
| 446 | with: |
| 447 | configuration: .github/release_notes.json |
| 448 | toTag: ${{ steps.extract_version.outputs.tag }} |
| 449 | fromTag: ${{ steps.extract_version.outputs.from_tag }} |
| 450 | env: |
| 451 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 452 | - name: Create GH release |
| 453 | uses: softprops/action-gh-release@v2 |
| 454 | with: |
| 455 | prerelease: ${{ contains('beta', github.ref) }} |
| 456 | tag_name: ${{ steps.extract_version.outputs.tag }} |
| 457 | token: ${{ secrets.GITHUB_TOKEN }} |
| 458 | generate_release_notes: false |
| 459 | name: Node/Rust LanceDB v${{ steps.extract_version.outputs.version }} |
| 460 | body: ${{ steps.release_notes.outputs.changelog }} |