From 0063c4e82a3c6b2476e0c96e69dc51347c27838f Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 4 Dec 2024 13:59:54 -0700 Subject: [PATCH 1/9] chore(NODE-6603): set errexit in install script and download prebuilt windows zstd (#51) --- .github/workflows/test.yml | 2 +- binding.gyp | 5 ++++- etc/install-zstd.sh | 27 +++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57413b7..762f5b8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: run: npm run install-zstd shell: bash - - name: install dependencies and compmile + - name: install dependencies and compile run: npm install --loglevel verbose shell: bash diff --git a/binding.gyp b/binding.gyp index 3da1b99..75c6fec 100644 --- a/binding.gyp +++ b/binding.gyp @@ -23,9 +23,12 @@ { 'link_settings': { 'libraries': [ - '<(module_root_dir)/deps/zstd/build/cmake/lib/Debug/zstd_static.lib' + '<(module_root_dir)/deps/zstd/static/zstd_static.lib' ] }, + 'include_dirs': [ + '<(module_root_dir)/deps/zstd/include' + ], }, { # macos and linux 'link_settings': { diff --git a/etc/install-zstd.sh b/etc/install-zstd.sh index d9ba539..852165a 100644 --- a/etc/install-zstd.sh +++ b/etc/install-zstd.sh @@ -1,16 +1,39 @@ #!/bin/sh set -o xtrace +set -o errexit clean_deps() { rm -rf deps } +download_windows() { + # windows does not support symlinks, so we must download the `win64` build specifically + curl -L -o zstd.zip "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-v$ZSTD_VERSION-win64.zip" + # unlike tar, unzip does not have a "strip components" option. so we unzip the file, copy all the contents to the correct location, + # and then delete both the .zip and the unziped content. + unzip zstd.zip + cp -r zstd-v$ZSTD_VERSION-win64/* deps/zstd + rm zstd.zip + rm -rf zstd-v$ZSTD_VERSION-win64 +} + download_zstd() { mkdir -p deps/zstd ZSTD_VERSION=$(node -p "require('./package.json')['mongodb:zstd_version']") + is_windows=$(node -p "process.platform === 'win32'") - curl -L "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz" \ - | tar -zxf - -C deps/zstd --strip-components 1 + if [ "$is_windows" == "true" ]; then + download_windows + exit 0 # no need to build windows + else + # tar flags + # -C specifies the output location + # --strip-components removes one level of directory nesting + # curl flags + # -L follows redirects + curl -L "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz" \ + | tar -zxf - -C deps/zstd --strip-components 1 + fi } build_zstd() { From b4886b5f21c5f7937b15a9729c3b74bb35cc2145 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Thu, 5 Dec 2024 11:26:52 -0700 Subject: [PATCH 2/9] docs(NODE-6595): update compatibility table for zstd@2.0 (#53) --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b1cc57c..f348d53 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # @mongodb-js/zstd -[![CI](https://github.com/mongodb-js/zstd/actions/workflows/CI.yml/badge.svg)](https://github.com/mongodb-js/zstd/actions/workflows/CI.yml) +[![CI](https://github.com/mongodb-js/zstd/actions/workflows/test.yml/badge.svg)](https://github.com/mongodb-js/zstd/actions/workflows/test.yml) Zstandard compression library for Node.js @@ -56,12 +56,13 @@ To verify the native `.node` packages, follow the same steps as above using `mon Only the following version combinations with the [MongoDB Node.js Driver](https://github.com/mongodb/node-mongodb-native) are considered stable. -| | `@mongodb-js/zstd@1.x` | -| ------------- | ---------------------- | -| `mongodb@6.x` | ✓ `^1.1.0` | -| `mongodb@5.x` | ✓ | -| `mongodb@4.x` | ✓ | -| `mongodb@3.x` | N/A | +| | `@mongodb-js/zstd@1.x` | `@mongodb-js/zstd@2.x` | +| ---------------- | ---------------------- | ---------------------- | +| `mongodb@>=6.11` | ✓ `^1.1.0` | `^2.0.0` | +| `mongodb@<6.11` | ✓ `^1.1.0` | N/A | +| `mongodb@5.x` | ✓ | N/A | +| `mongodb@4.x` | ✓ | N/A | +| `mongodb@3.x` | N/A | N/A | ## API From 7d8c6de63fe79b693442265f3fe6a88b914bd260 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Thu, 5 Dec 2024 13:36:03 -0500 Subject: [PATCH 3/9] chore: remove outdated release section from readme (#55) --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index f348d53..7671dfd 100644 --- a/README.md +++ b/README.md @@ -108,12 +108,3 @@ First, install and build the zstd library: Then: `npm test` - -## Releasing - -CI will automatically publish when it detects a new release after: - -``` -npm run release -- --release-as -git push --follow-tags origin main -``` From 57b964010431ad214bc692446c79167dab8405b4 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Thu, 5 Dec 2024 11:38:49 -0700 Subject: [PATCH 4/9] build(NODE-6604): fix windows builds (#52) --- .github/workflows/test.yml | 2 +- binding.gyp | 7 ++--- etc/install-zstd.sh | 52 ++++++++++++++++++-------------------- 3 files changed, 27 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 762f5b8..89f9590 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: shell: bash - name: install dependencies and compile - run: npm install --loglevel verbose + run: npm install --ignore-scripts --loglevel verbose && npm run prebuild shell: bash - name: Test ${{ matrix.os }} diff --git a/binding.gyp b/binding.gyp index 75c6fec..da470aa 100644 --- a/binding.gyp +++ b/binding.gyp @@ -23,17 +23,14 @@ { 'link_settings': { 'libraries': [ - '<(module_root_dir)/deps/zstd/static/zstd_static.lib' + '<(module_root_dir)/deps/zstd/out/lib/Debug/zstd_static.lib' ] }, - 'include_dirs': [ - '<(module_root_dir)/deps/zstd/include' - ], }, { # macos and linux 'link_settings': { 'libraries': [ - '<(module_root_dir)/deps/zstd/build/cmake/lib/libzstd.a', + '<(module_root_dir)/deps/zstd/out/lib/libzstd.a', ] }, } diff --git a/etc/install-zstd.sh b/etc/install-zstd.sh index 852165a..0e2945a 100644 --- a/etc/install-zstd.sh +++ b/etc/install-zstd.sh @@ -6,44 +6,40 @@ clean_deps() { rm -rf deps } -download_windows() { - # windows does not support symlinks, so we must download the `win64` build specifically - curl -L -o zstd.zip "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-v$ZSTD_VERSION-win64.zip" - # unlike tar, unzip does not have a "strip components" option. so we unzip the file, copy all the contents to the correct location, - # and then delete both the .zip and the unziped content. - unzip zstd.zip - cp -r zstd-v$ZSTD_VERSION-win64/* deps/zstd - rm zstd.zip - rm -rf zstd-v$ZSTD_VERSION-win64 -} - download_zstd() { mkdir -p deps/zstd ZSTD_VERSION=$(node -p "require('./package.json')['mongodb:zstd_version']") - is_windows=$(node -p "process.platform === 'win32'") - - if [ "$is_windows" == "true" ]; then - download_windows - exit 0 # no need to build windows - else - # tar flags - # -C specifies the output location - # --strip-components removes one level of directory nesting - # curl flags - # -L follows redirects - curl -L "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz" \ - | tar -zxf - -C deps/zstd --strip-components 1 - fi + + # only unpack the source and build files needed to compile the project + necessary_files="zstd-$ZSTD_VERSION/build zstd-$ZSTD_VERSION/lib zstd-$ZSTD_VERSION/programs" + + # flags + # -L follow redirects + # -C output directory + # - tar from stdin + # --strip-components ignore the top-level directory when unpacking + curl -L "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz" \ + | tar -zxf - -C deps/zstd --strip-components 1 $necessary_files } build_zstd() { export MACOSX_DEPLOYMENT_TARGET=11 - cd deps/zstd/build/cmake + cd deps/zstd + + mkdir out + cd out # CMAKE_RC_FLAGS is a workaround for a bug in 1.5.6 that breaks compilation on windows. # The fix is merged but not yet released. see https://github.com/facebook/zstd/issues/3999 - cmake -DCMAKE_RC_FLAGS="$(pwd)/lib" -DZSTD_MULTITHREAD_SUPPORT=OFF -DZSTD_BUILD_SHARED=OFF -DCMAKE_OSX_ARCHITECTURES='x86_64;arm64' . - cmake --build . + cmake \ + -DCMAKE_RC_FLAGS="$(pwd)/lib" \ + -DZSTD_MULTITHREAD_SUPPORT=OFF \ + -DZSTD_BUILD_SHARED=OFF \ + -DCMAKE_OSX_ARCHITECTURES='x86_64;arm64' \ + -DCMAKE_BUILD_TYPE=Release \ + ../build/cmake + + cmake --build . --target libzstd_static } clean_deps From 3aba9c8653eed3341ca727050b2c43481640e008 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Thu, 5 Dec 2024 11:45:17 -0700 Subject: [PATCH 5/9] docs: update prebuild matrix in readme (#56) --- README.md | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7671dfd..4476bc2 100644 --- a/README.md +++ b/README.md @@ -38,20 +38,6 @@ No verification is done when using npm to install the package. The contents of t To verify the native `.node` packages, follow the same steps as above using `mongodb-js-zstd-X.Y.Z-platform.tgz` and the corresponding `.sig` file. - -## OS Support matrix - -| | node12 | node14 | node16 | node18 | node20 | -| ---------------- | ------ | ------ | ------ | ------ | ------ | -| Windows x64 | ✓ | ✓ | ✓ | ✓ | ✓ | -| macOS x64 | ✓ | ✓ | ✓ | ✓ | ✓ | -| macOS arm64 | ✓ | ✓ | ✓ | ✓ | ✓ | -| Linux x64 gnu | ✓ | ✓ | ✓ | ✓ | ✓ | -| Linux arm gnu | ✓ | ✓ | ✓ | ✓ | ✓ | -| Linux arm64 gnu | ✓ | ✓ | ✓ | ✓ | ✓ | -| Linux x64 musl | ✓ | ✓ | ✓ | ✓ | ✓ | -| Linux arm64 musl | ✓ | ✓ | ✓ | ✓ | ✓ | - ## MongoDB Node.js Driver Version Compatibility Only the following version combinations with the [MongoDB Node.js Driver](https://github.com/mongodb/node-mongodb-native) are considered stable. @@ -64,6 +50,24 @@ Only the following version combinations with the [MongoDB Node.js Driver](https: | `mongodb@4.x` | ✓ | N/A | | `mongodb@3.x` | N/A | N/A | +#### Prebuild Platforms + +Below are the platforms that are available as prebuilds on each github release. +`prebuild-install` downloads these automatically depending on the platform you are running npm install on. + +- Linux GLIBC 2.23 or later + - s390x + - arm64 + - x64 +- Linux MUSL 1.1.20 + - arm64 + - x64 +- MacOS universal binary + - x64 + - arm64 +- Windows + - x64 + ## API ```ts @@ -106,5 +110,9 @@ First, install and build the zstd library: `npm run install-zstd` -Then: +Then build the bindings: + +`npm run prebuild` + +Then test: `npm test` From 5cf10834758cb2073308205a2224b1453cf3477b Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Thu, 5 Dec 2024 11:56:01 -0700 Subject: [PATCH 6/9] docs: zstd2.0 works with driver 6.12, not 6.11 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4476bc2..d9f523f 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ Only the following version combinations with the [MongoDB Node.js Driver](https: | | `@mongodb-js/zstd@1.x` | `@mongodb-js/zstd@2.x` | | ---------------- | ---------------------- | ---------------------- | -| `mongodb@>=6.11` | ✓ `^1.1.0` | `^2.0.0` | -| `mongodb@<6.11` | ✓ `^1.1.0` | N/A | +| `mongodb@>=6.12` | ✓ `^1.1.0` | `^2.0.0` | +| `mongodb@<6.12` | ✓ `^1.1.0` | N/A | | `mongodb@5.x` | ✓ | N/A | | `mongodb@4.x` | ✓ | N/A | | `mongodb@3.x` | N/A | N/A | From 134d4836c6687222c584b8417bb916bed9e2de1b Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Thu, 5 Dec 2024 11:58:38 -0700 Subject: [PATCH 7/9] chore(main): release 2.0.0-alpha.3 (#57) --- .release-please-manifest.json | 2 +- HISTORY.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index af4b15c..924b352 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-alpha.2" + ".": "2.0.0-alpha.3" } diff --git a/HISTORY.md b/HISTORY.md index 29701a8..cef7156 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.0.0-alpha.3](https://github.com/mongodb-js/zstd/compare/v2.0.0-alpha.2...v2.0.0-alpha.3) (2024-12-05) + ## [2.0.0-alpha.2](https://github.com/mongodb-js/zstd/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2024-12-04) diff --git a/package-lock.json b/package-lock.json index 2eb27ae..79e3b7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mongodb-js/zstd", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@mongodb-js/zstd", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 93156a7..1da7297 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mongodb-js/zstd", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "main": "lib/index.js", "types": "index.d.ts", "repository": "https://github.com/mongodb-js/zstd", From 999c5064f7e1033a889b4e1d9b3cd491a5ec2ff9 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Thu, 5 Dec 2024 13:08:57 -0700 Subject: [PATCH 8/9] fix: bundle release build on windows (#59) Co-authored-by: Neal Beeken --- binding.gyp | 2 +- etc/install-zstd.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/binding.gyp b/binding.gyp index da470aa..4aa6259 100644 --- a/binding.gyp +++ b/binding.gyp @@ -23,7 +23,7 @@ { 'link_settings': { 'libraries': [ - '<(module_root_dir)/deps/zstd/out/lib/Debug/zstd_static.lib' + '<(module_root_dir)/deps/zstd/out/lib/Release/zstd_static.lib' ] }, }, diff --git a/etc/install-zstd.sh b/etc/install-zstd.sh index 0e2945a..1f3bae8 100644 --- a/etc/install-zstd.sh +++ b/etc/install-zstd.sh @@ -39,7 +39,7 @@ build_zstd() { -DCMAKE_BUILD_TYPE=Release \ ../build/cmake - cmake --build . --target libzstd_static + cmake --build . --target libzstd_static --config Release } clean_deps From c45f0cc23bd7421e674a98f9c6ed1121e43961dd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:30:47 -0700 Subject: [PATCH 9/9] chore(main): release 2.0.0-alpha.3 (#58) Co-authored-by: Bailey Pearson --- HISTORY.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index cef7156..7c196fb 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. See [standa ## [2.0.0-alpha.3](https://github.com/mongodb-js/zstd/compare/v2.0.0-alpha.2...v2.0.0-alpha.3) (2024-12-05) +### Bug Fixes + +* bundle release build on windows ([#59](https://github.com/mongodb-js/zstd/issues/59)) ([999c506](https://github.com/mongodb-js/zstd/commit/999c5064f7e1033a889b4e1d9b3cd491a5ec2ff9)) + ## [2.0.0-alpha.2](https://github.com/mongodb-js/zstd/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2024-12-04)