From 7f4aa8013e83cbae323dbe9c6d6bb96c99a40a6a Mon Sep 17 00:00:00 2001 From: Black-Hole Date: Wed, 25 Oct 2023 21:50:26 +0800 Subject: [PATCH] chore(ci): improve npm publish logic (#5) --- package.json | 2 +- scripts/cross-build.sh | 4 ++-- scripts/prepublish-only.sh | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100755 scripts/prepublish-only.sh diff --git a/package.json b/package.json index 4e8b94f..bd01d16 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "clean": "cargo clean && rimraf lib", "build": "pnpm clean && ./scripts/cross-build.sh && tsup-node", "build:debug": "pnpm clean && napi build --platform lib && tsup-node", - "prepublishOnly": "pnpm build" + "prepublishOnly": "./scripts/prepublish-only.sh" }, "devDependencies": { "@napi-rs/cli": "^1.0.0", diff --git a/scripts/cross-build.sh b/scripts/cross-build.sh index 0cb4e96..6702ea3 100755 --- a/scripts/cross-build.sh +++ b/scripts/cross-build.sh @@ -5,6 +5,6 @@ platform_list=("x86_64-apple-darwin" "aarch64-apple-darwin") for platform in "${platform_list[@]}" do - echo "napi build --platform --target $platform --release lib" - napi build --platform --target $platform --release lib + echo "pnpm exec napi build --platform --target $platform --release lib" + pnpm exec napi build --platform --target $platform --release lib done diff --git a/scripts/prepublish-only.sh b/scripts/prepublish-only.sh new file mode 100755 index 0000000..79a3376 --- /dev/null +++ b/scripts/prepublish-only.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -o pipefail + +if [ -z $CI]; then + pnpm run build; +else + exit 0; +fi;