2016-12-01 20:33:42 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
usage() {
|
2019-10-11 13:01:50 +02:00
|
|
|
echo "Usage: $0 -v <version> -d <config directory> [-n]"
|
2016-12-01 20:33:42 +01:00
|
|
|
echo
|
|
|
|
echo "version: commit-ish to check out and build"
|
2019-10-11 13:01:50 +02:00
|
|
|
echo "config directory: a path to a directory containing"
|
|
|
|
echo "config.json, a json config file to ship with the build"
|
|
|
|
echo "and env.sh, a file to source environment variables"
|
|
|
|
echo "from."
|
2016-12-01 20:33:42 +01:00
|
|
|
echo "-n: build with no config file."
|
|
|
|
echo
|
2019-10-11 13:01:50 +02:00
|
|
|
echo "The update_base_url value from config.json is used to set up auto-update."
|
|
|
|
echo
|
|
|
|
echo "Environment variables:"
|
|
|
|
echo " OSSLSIGNCODE_SIGNARGS: Arguments to pass to osslsigncode when signing"
|
|
|
|
echo " NOTARIZE_APPLE_ID: Apple ID to use for notarisation. The password for"
|
|
|
|
echo " this account must be set in NOTARIZE_CREDS in the keychain."
|
2016-12-01 20:33:42 +01:00
|
|
|
}
|
|
|
|
|
2019-10-11 13:01:50 +02:00
|
|
|
confdir=
|
2016-12-01 20:33:42 +01:00
|
|
|
version=
|
|
|
|
skipcfg=0
|
2019-10-11 13:01:50 +02:00
|
|
|
while getopts "d:v:n" opt; do
|
2016-12-01 20:33:42 +01:00
|
|
|
case $opt in
|
2019-10-11 13:01:50 +02:00
|
|
|
d)
|
|
|
|
confdir=$OPTARG
|
2016-12-01 20:33:42 +01:00
|
|
|
;;
|
|
|
|
v)
|
|
|
|
version=$OPTARG
|
|
|
|
;;
|
|
|
|
n)
|
|
|
|
skipcfg=1
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
echo "Invalid option: -$OPTARG" >&2
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$version" ]; then
|
|
|
|
echo "No version supplied"
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2019-10-11 13:01:50 +02:00
|
|
|
conffile="$confdir/config.json"
|
|
|
|
|
2016-12-01 20:33:42 +01:00
|
|
|
if [ -z "$conffile" ] && [ "$skipcfg" = 0 ]; then
|
|
|
|
echo "No config file given. Use -c to supply a config file or"
|
|
|
|
echo "-n to build with no config file (and no auto update)."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$conffile" ]; then
|
|
|
|
update_base_url=`jq -r .update_base_url $conffile`
|
|
|
|
|
|
|
|
if [ -z "$update_base_url" ]; then
|
|
|
|
echo "No update URL supplied. Use update_base_url: null if you really"
|
|
|
|
echo "want a build with no auto-update."
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
# Make sure the base URL ends in a slash if it doesn't already
|
|
|
|
update_base_url=`echo $update_base_url | sed -e 's#\([^\/]\)$#\1\/#'`
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f package.json ]; then
|
|
|
|
echo "No package.json found. This script must be run from"
|
2017-05-11 18:49:31 +02:00
|
|
|
echo "the riot-web directory."
|
2016-12-01 20:33:42 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2019-10-11 13:01:50 +02:00
|
|
|
[ -f "$confdir/env.sh" ] && . "$confdir/env.sh"
|
|
|
|
|
2019-10-10 16:32:17 +02:00
|
|
|
if [ -z "$NOTARIZE_APPLE_ID" ]; then
|
|
|
|
echo "NOTARIZE_APPLE_ID is not set"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2019-10-11 13:01:50 +02:00
|
|
|
osslsigncode -h 2> /dev/null
|
2019-10-18 11:08:43 +02:00
|
|
|
if [ $? -ne 255 ]; then # osslsigncode exits with 255 after printing usage...
|
2019-10-11 13:01:50 +02:00
|
|
|
echo "osslsigncode not found"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2019-10-10 16:32:17 +02:00
|
|
|
# Test that altool can get its credentials for notarising the mac app
|
|
|
|
xcrun altool -u "$NOTARIZE_APPLE_ID" -p '@keychain:NOTARIZE_CREDS' --list-apps || exit
|
|
|
|
|
2019-10-11 13:01:50 +02:00
|
|
|
# Get the token password: we'll need it later, but get it now so we fail early if it's not there
|
|
|
|
token_password=`security find-generic-password -s riot_signing_token -w`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "riot_signing_token not found in keychain"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2016-12-01 20:33:42 +01:00
|
|
|
echo "Building $version using Update base URL $update_base_url"
|
|
|
|
|
|
|
|
projdir=`pwd`
|
|
|
|
builddir=`mktemp -d 2>/dev/null || mktemp -d -t 'buildtmp'`
|
|
|
|
pushd "$builddir"
|
2016-12-09 19:29:54 +01:00
|
|
|
|
2016-12-01 20:33:42 +01:00
|
|
|
git clone "$projdir" .
|
|
|
|
git checkout "$version"
|
|
|
|
|
2016-12-09 21:23:19 +01:00
|
|
|
# Figure out what version we're building
|
|
|
|
vername=`jq -r .version package.json`
|
|
|
|
|
2016-12-01 20:33:42 +01:00
|
|
|
if [ -n "$conffile" ]; then
|
|
|
|
popd
|
|
|
|
cp "$conffile" "$builddir/"
|
|
|
|
pushd "$builddir"
|
|
|
|
fi
|
|
|
|
|
2019-09-27 13:48:28 +02:00
|
|
|
# We use Git branch / commit dependencies for some packages, and Yarn seems
|
|
|
|
# to have a hard time getting that right. See also
|
|
|
|
# https://github.com/yarnpkg/yarn/issues/4734. As a workaround, we clean the
|
|
|
|
# global cache here to ensure we get the right thing.
|
|
|
|
yarn cache clean
|
2019-03-12 12:06:57 +01:00
|
|
|
yarn install
|
|
|
|
yarn build:electron
|
2016-12-01 20:33:42 +01:00
|
|
|
|
|
|
|
popd
|
|
|
|
|
2017-05-10 14:36:27 +02:00
|
|
|
distdir="$builddir/electron_app/dist"
|
|
|
|
pubdir="$projdir/electron_app/pub"
|
2016-12-01 20:33:42 +01:00
|
|
|
rm -r "$pubdir" || true
|
|
|
|
mkdir -p "$pubdir"
|
2017-09-06 15:37:57 +02:00
|
|
|
rm -r "$projdir/electron_app/dist" || true
|
2019-11-27 14:02:14 +01:00
|
|
|
mkdir -p "$projdir/electron_app/dist"
|
2016-12-01 20:33:42 +01:00
|
|
|
|
|
|
|
# Install packages: what the user downloads the first time,
|
|
|
|
# (DMGs for mac, exe installer for windows)
|
|
|
|
mkdir -p "$pubdir/install/macos"
|
2018-10-16 11:26:04 +02:00
|
|
|
cp $distdir/*.dmg "$pubdir/install/macos/"
|
2016-12-01 20:33:42 +01:00
|
|
|
|
2016-12-05 15:08:27 +01:00
|
|
|
mkdir -p "$pubdir/install/win32/ia32/"
|
2019-11-27 13:44:40 +01:00
|
|
|
cp $distdir/squirrel-windows-ia32/*.exe "$pubdir/install/win32/ia32/"
|
2016-12-05 15:08:27 +01:00
|
|
|
|
|
|
|
mkdir -p "$pubdir/install/win32/x64/"
|
2019-11-27 13:44:40 +01:00
|
|
|
cp $distdir/squirrel-windows/*.exe "$pubdir/install/win32/x64/"
|
2016-12-01 20:33:42 +01:00
|
|
|
|
2016-12-05 15:08:27 +01:00
|
|
|
# Packages for auto-update
|
2016-12-01 20:33:42 +01:00
|
|
|
mkdir -p "$pubdir/update/macos"
|
2018-10-16 11:26:04 +02:00
|
|
|
cp $distdir/*-mac.zip "$pubdir/update/macos/"
|
2016-12-09 19:29:54 +01:00
|
|
|
echo "$vername" > "$pubdir/update/macos/latest"
|
2016-12-01 20:33:42 +01:00
|
|
|
|
2016-12-05 15:08:27 +01:00
|
|
|
mkdir -p "$pubdir/update/win32/ia32/"
|
2019-02-14 13:54:26 +01:00
|
|
|
cp $distdir/squirrel-windows-ia32/*.nupkg "$pubdir/update/win32/ia32/"
|
|
|
|
cp $distdir/squirrel-windows-ia32/RELEASES "$pubdir/update/win32/ia32/"
|
2016-12-05 15:08:27 +01:00
|
|
|
|
|
|
|
mkdir -p "$pubdir/update/win32/x64/"
|
2019-02-14 13:54:26 +01:00
|
|
|
cp $distdir/squirrel-windows/*.nupkg "$pubdir/update/win32/x64/"
|
|
|
|
cp $distdir/squirrel-windows/RELEASES "$pubdir/update/win32/x64/"
|
2016-12-05 15:08:27 +01:00
|
|
|
|
2019-03-07 12:12:43 +01:00
|
|
|
# Move the deb to the main project dir's dist folder
|
|
|
|
# (just the 64 bit one - the 32 bit one still gets built because
|
|
|
|
# it's one arch argument for all platforms and we still want 32 bit
|
|
|
|
# windows, but 32 bit linux is unsupported as of electron 4 and no
|
|
|
|
# longer appears to work).
|
|
|
|
cp $distdir/*_amd64.deb "$projdir/electron_app/dist/"
|
2016-12-01 20:33:42 +01:00
|
|
|
|
|
|
|
rm -rf "$builddir"
|
|
|
|
|
2019-10-11 13:01:50 +02:00
|
|
|
echo "$pubdir can now be hosted on your web server."
|
2017-05-10 14:36:27 +02:00
|
|
|
echo "deb archives are in electron_app/dist/ - these should be added into your debian repository"
|