-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
package.sh
executable file
·36 lines (25 loc) · 963 Bytes
/
package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash -e
# SPDX-License-Identifier: MPL-2.0
date=$(git log -1 --date=short --pretty=format:%cd || date -u)
# Setup environment for building inside Dockerized toolchain
export NVM_DIR="${HOME}/.nvm"
[ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh"
[ $(id -u) = 0 ] && umask 0
rm -rf node_modules
if [ -z "${ADDON_ARCH}" ]; then
TARFILE_SUFFIX=
else
NODE_VERSION="$(node --version)"
TARFILE_SUFFIX="-${ADDON_ARCH}-${NODE_VERSION/\.*/}"
fi
npm install --production
shasum --algorithm 256 manifest.json package.json *.js LICENSE README.md > SHA256SUMS
find node_modules \( -type f -o -type l \) -exec shasum --algorithm 256 {} \; >> SHA256SUMS
TARFILE="$(npm pack)"
tar xzf ${TARFILE}
rm ${TARFILE}
TARFILE_ARCH="${TARFILE/.tgz/${TARFILE_SUFFIX}.tgz}"
cp -r node_modules ./package
GZIP="-n" tar czf "${TARFILE_ARCH}" --mtime="${date}" package
shasum --algorithm 256 ${TARFILE_ARCH} > ${TARFILE_ARCH}.sha256sum
rm -rf SHA256SUMS package