Simplify Node.js binary naming

This commit is contained in:
Wilson Lin 2020-07-04 00:00:10 +10:00
parent 224e28c8a6
commit 7c2c898d36
3 changed files with 6 additions and 44 deletions

View File

@ -54,8 +54,9 @@ jobs:
pip install --upgrade b2
- name: Upload to B2
run: |
binary_name="$(node -e 'console.log([process.platform, process.arch, process.versions.modules].join("__"))')"
b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} ./nodejs/native/index.node hyperbuild/bin/nodejs/${{ steps.version.outputs.VERSION }}/${{ matrix.ARCH }}-node${{ matrix.node }}.node
b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} "./nodejs/native/index.node hyperbuild/bin/nodejs/${{ steps.version.outputs.VERSION }}/$binary_name.node"
package:
runs-on: ubuntu-latest
needs: build

View File

@ -22,23 +22,8 @@ fi
npx neon build --release
mv native/Cargo.toml.orig native/Cargo.toml
if [[ "$OSTYPE" == "linux-gnu" ]]; then
os_name="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
os_name="macos"
elif [[ "$OSTYPE" == "cygwin" ]]; then
os_name="windows"
elif [[ "$OSTYPE" == "msys" ]]; then
os_name="windows"
elif [[ "$OSTYPE" == "win32" ]]; then
os_name="windows"
else
echo "Unknown OS"
exit 1
fi
binary_name="$(node -e 'console.log([process.platform, process.arch, process.versions.modules].join("__"))')"
node_version=$(node -e 'console.log(process.versions.node.split(".")[0])')
mv native/index.node "dist/$os_name-x86_64-node$node_version.node"
mv native/index.node "dist/$binary_name.node"
popd

View File

@ -1,30 +1,6 @@
const binaryName = [
[process.platform, {
darwin: 'macos',
linux: 'linux',
win32: 'windows',
}],
'-',
[process.arch, {
x64: 'x86_64',
}],
'-node',
[process.versions.modules, {
// Sourced from https://nodejs.org/en/download/releases/.
57: 8,
59: 9,
64: 10,
67: 11,
72: 12,
79: 13,
}],
'.node',
].map(p => typeof p == 'string'
? p
: p[1][p[0] as string]
).join('');
const binaryName = [process.platform, process.arch, process.versions.modules].join('__');
const hyperbuild = require(`./${binaryName}`);
const hyperbuild = require(`./${binaryName}.node`);
export const minify = (code: string): string => {
const buf = Buffer.from(code);