-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·38 lines (33 loc) · 1.36 KB
/
build.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
37
38
#!/bin/bash
while getopts d OPT
do
case $OPT in
d) DEBUG=1 ;;
esac
done
shift $((OPTIND - 1))
BUILD_COMMAND="build"
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ -n "$DEBUG" ]; then
BUILD_COMMAND="build:dev"
fi
docker run --rm \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
--env NODE_OPTIONS="--openssl-legacy-provider" \
-v ${PWD}:/project \
-v ${PWD##*/}-node-modules:/project/node_modules \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine \
bash -c "yarn && npm run ${BUILD_COMMAND} \
&& tar zcvf build/${PACKAGE_NAME}-${PACKAGE_VERSION}-mac.tar.gz -C build/mac ${PACKAGE_NAME}.app \
&& rm -f build/${PACKAGE_NAME}-${PACKAGE_VERSION}-mac.zip \
&& chown -R $(id -u):$(id -g) /project/{build,dist}"
if [ -n "$DEBUG" ]; then
mv build/${PACKAGE_NAME}\ ${PACKAGE_VERSION}{,d}.exe
mv build/${PACKAGE_NAME}-${PACKAGE_VERSION}{,d}.AppImage
mv build/${PACKAGE_NAME}-${PACKAGE_VERSION}{,d}-mac.tar.gz
fi