Skip to content

Commit

Permalink
[build] Add packaging scripts for each platform (#3656)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp authored Jan 13, 2022
1 parent defb8d4 commit b16a648
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"package": "yarn build && ./node_modules/.bin/electron-builder build --publish never",
"package-win": "yarn build && ./node_modules/.bin/electron-builder build --win --x64",
"package-linux": "yarn build && ./node_modules/.bin/electron-builder build --linux",
"package-mac": "yarn build && ./node_modules/.bin/electron-builder build --mac",
"package-mac-amd64": "yarn build && ./node_modules/.bin/electron-builder build --mac --x64",
"package-mac-arm64": "yarn build && ./node_modules/.bin/electron-builder build --mac --arm64",
"package-all": "yarn build && ./node_modules/.bin/electron-builder build -mwl",
"package-dev-linux": "yarn build && ./node_modules/.bin/electron-builder build --linux tar.gz",
"i18n-prepare-untranslated": "node ./scripts/prepareUntranslated.js",
Expand Down
20 changes: 20 additions & 0 deletions package_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

[ $(uname) = Linux ] || {
echo "$0 must be run from linux" 2>&1
exit 1
}

NODE_MODULES=node_modules
YARNCACHE=.yarncache

set -ex
[ -d ${NODE_MODULES} ] && rm -rf ${NODE_MODULES}
[ -d ${YARNCACHE} ] && rm -rf ${YARNCACHE}
mkdir -p ${YARNCACHE}

# prepare directory with package files
yarn install --cache-folder ${YARNCACHE}
yarn rebuild-natives
yarn package-linux

77 changes: 77 additions & 0 deletions package_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh

# submit a package to be notarized
# returns: notarization uuid
notary_submit() {
xcrun altool -f release/decrediton-${VERSION}.zip \
--notarize-app \
--primary-bundle-id org.Electron.Decrediton \
--asc-provider ${IDENTITY} \
-p @keychain:${KEYCHAIN} 2>&1 \
| perl -ne 'print if s/^RequestUUID = //'
}

# check notarization status after successful submission
# arg 1: uuid
# returns: altool output
notary_status() {
local _uuid=$1
xcrun altool --notarization-info ${_uuid} -p @keychain:${KEYCHAIN} 2>&1
}

[ $(uname) = Darwin ] || {
echo "$0 must be run from darwin" 2>&1
exit 1
}
[ $# = 3 ] || {
echo "usage: $0 version identity arch" 2>&1
exit 2
}

VERSION=$1
IDENTITY=$2
ARCH=$3
KEYCHAIN=${KEYCHAIN:-signer}
NODE_MODULES=node_modules
YARNCACHE=.yarncache

set -ex
[ -d ${NODE_MODULES} ] && rm -rf ${NODE_MODULES}
[ -d ${YARNCACHE} ] && rm -rf ${YARNCACHE}
mkdir -p ${YARNCACHE}

# prepare directory with package files
yarn install --cache-folder ${YARNCACHE}
yarn rebuild-natives
yarn package-mac-${ARCH}

# submit notarization
_uuid=$(notary_submit)

# poll notarization status until no longer in-progress
set +ex
while :; do
sleep 60
_date=$(date)
_output=$(notary_status ${_uuid})
_status=$(echo "${_output}" | perl -ne 'print if s/^\s*Status: //')
echo "check at ${_date}: Status: ${_status}"
case ${_status} in
"in progress")
continue
;;
"success")
# move on to stapling
break
;;
"")
echo "warn: unknown status -- full output:\n${_output}" 2>&1
continue
;;
*)
echo "${_output}" 2>&1
exit 1
;;
esac
done
set -ex
21 changes: 21 additions & 0 deletions package_win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

[ $# = 2 ] || {
echo "usage: $0 version link pass" 2>&1
exit 2
}

LINK=$1
PASS=$2
NODE_MODULES=node_modules
YARNCACHE=.yarncache

set -ex
[ -d ${NODE_MODULES} ] && rm -rf ${NODE_MODULES}
[ -d ${YARNCACHE} ] && rm -rf ${YARNCACHE}
mkdir -p ${YARNCACHE}

# prepare directory with package files
yarn install --cache-folder ${YARNCACHE}
yarn rebuild-natives
set WIN_CSC_LINK=${LINK} && set WIN_CSC_KEY_PASSWORD=${PASS} && yarn package-win

0 comments on commit b16a648

Please sign in to comment.