diff --git a/.github/workflows/node_release.yml b/.github/workflows/node_release.yml new file mode 100644 index 00000000..d0c62329 --- /dev/null +++ b/.github/workflows/node_release.yml @@ -0,0 +1,118 @@ +name: Node Release + +on: + pull_request: + paths: + - node/** + - .github/workflows/node_release.yml + +jobs: + macos: + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + lfs: true + - name: Install system dependencies + run: brew install protobuf + - name: Install rustup target + run: rustup target add aarch64-apple-darwin + - name: Build x86_64 + run: cargo build --lib -p vectordb-node --release --target x86_64-apple-darwin + - name: Upload x86_64 dylib + uses: actions/upload-artifact@v3 + with: + path: target/x86_64-apple-darwin/release/libvectordb_node.dylib + name: x86_64-apple-darwin.node + retention-days: 5 + - name: Build aarch64 + run: cargo build --lib -p vectordb-node --release --target aarch64-apple-darwin + - name: Upload aarch64 dylib + uses: actions/upload-artifact@v3 + with: + path: target/aarch64-apple-darwin/release/libvectordb_node.dylib + name: aarch64-apple-darwin.node + retention-days: 5 + + linux-x64: + runs-on: ubuntu-latest + container: quay.io/pypa/manylinux2014_x86_64 + steps: + - uses: actions/checkout@v3 + - name: Install system dependencies + run: | + yum install -y openssl-devel + # protobuf is too old, so we directly download binaries + PB_REL="https://github.com/protocolbuffers/protobuf/releases" + PB_VERSION=23.1 + curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-x86_64.zip + unzip protoc-$PB_VERSION-linux-x86_64.zip -d $HOME/.local + echo "${HOME}/.local/bin" >> $GITHUB_PATH + # TODO: replace this with something more modern + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Build GNU x86_64 + run: cargo build --lib -p vectordb-node --release --verbose + - name: Upload GNU x86_64 dylib + uses: actions/upload-artifact@v3 + with: + path: target/x86_64-unknown-linux-gnu/release/libvectordb_node.so + name: x86_64-unknown-linux-gnu.node + retention-days: 5 + + draft-release: + runs-on: ubuntu-latest + needs: + - linux-x64 + - macos + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + - name: Move libraries + run: mv *.node node/ + # TODO: make sure we aren't rebuilding the library here. + - name: Build module + run: | + npm install + npm run build + working-directory: node + - name: Test module + run: | + npm run tsc + npm test + working-directory: node + - name: Zip module + run: | + rm -rf node/node_modules + zip -r vectordb-node.zip node + - name: Upload + uses: actions/upload-artifact@v3 + with: + path: vectordb-node.zip + retention-days: 5 + # - name: Create draft release + # uses: softprops/action-gh-release@v1 + # if: startsWith(github.ref, 'refs/tags/') + # with: + # draft: true + # generate_release_notes: true + # files: + # vectordb-node-$GITHUB_REF-node-v3-linux-x64.zip # x86_64-unknown-linux-gnu.node + # vectordb-node-$GITHUB_REF-node-v3-darwin-x64.zip # x86_64-apple-darwin.node + # vectordb-node-$GITHUB_REF-node-v3-linux-x64.zip # aarch64-apple-darwin.node + + # TODO: create draft release + # use: https://github.com/softprops/action-gh-release + # format like: https://github.com/tungv/cypher.js/releases/tag/v1.0.0-beta.6 + # + + # test-linux-x64: + # runs-on: ubuntu-latest + # needs: + # - draft-release + # steps: + # - \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index b95029fd..18fc1f65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,4 +3,4 @@ members = [ "rust/vectordb", "rust/ffi/node" ] -resolver = "2" +resolver = "2" \ No newline at end of file diff --git a/node/README.md b/node/README.md index 5e0a4838..22ae0028 100644 --- a/node/README.md +++ b/node/README.md @@ -8,6 +8,9 @@ A JavaScript / Node.js library for [LanceDB](https://github.com/lancedb/lancedb) npm install vectordb ``` +This will download the appropriate native library for your platform. We currently +support x86_64 Linux, Intel MacOS, and ARM (M1/M2) MacOS. + ## Usage ### Basic Example @@ -24,6 +27,12 @@ The [examples](./examples) folder contains complete examples. ## Development +Build the rust library with: + +```bash +npm run build +``` + The LanceDB javascript is built with npm: ```bash