2016-12-01 14:33:42 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "Usage: $0 -v <version> -c <config file> [-n]"
|
|
|
|
echo
|
|
|
|
echo "version: commit-ish to check out and build"
|
|
|
|
echo "config file: a path to a json config file to"
|
|
|
|
echo "ship with the build. In addition, update_base_url:"
|
|
|
|
echo "from this file is used to set up auto-update."
|
|
|
|
echo "-n: build with no config file."
|
|
|
|
echo
|
|
|
|
echo "Values may also be passed as environment variables"
|
|
|
|
}
|
|
|
|
|
|
|
|
conffile=
|
|
|
|
version=
|
|
|
|
skipcfg=0
|
|
|
|
while getopts "c:v:n" opt; do
|
|
|
|
case $opt in
|
|
|
|
c)
|
|
|
|
conffile=$OPTARG
|
|
|
|
;;
|
|
|
|
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
|
|
|
|
|
|
|
|
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 12:49:31 -04:00
|
|
|
echo "the riot-web directory."
|
2016-12-01 14:33:42 -05:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
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 13:29:54 -05:00
|
|
|
|
2016-12-01 14:33:42 -05:00
|
|
|
git clone "$projdir" .
|
|
|
|
git checkout "$version"
|
|
|
|
|
2016-12-09 15:23:19 -05:00
|
|
|
# Figure out what version we're building
|
|
|
|
vername=`jq -r .version package.json`
|
|
|
|
|
2016-12-01 14:33:42 -05:00
|
|
|
if [ -n "$conffile" ]; then
|
|
|
|
popd
|
|
|
|
cp "$conffile" "$builddir/"
|
|
|
|
pushd "$builddir"
|
|
|
|
fi
|
|
|
|
|
2019-09-27 07:48:28 -04: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 07:06:57 -04:00
|
|
|
yarn install
|
|
|
|
yarn build:electron
|
2016-12-01 14:33:42 -05:00
|
|
|
|
|
|
|
popd
|
|
|
|
|
2017-05-10 08:36:27 -04:00
|
|
|
distdir="$builddir/electron_app/dist"
|
|
|
|
pubdir="$projdir/electron_app/pub"
|
2016-12-01 14:33:42 -05:00
|
|
|
rm -r "$pubdir" || true
|
|
|
|
mkdir -p "$pubdir"
|
2017-09-06 09:37:57 -04:00
|
|
|
rm -r "$projdir/electron_app/dist" || true
|
2017-09-06 08:28:21 -04:00
|
|
|
mkdir -p "$projdir/electron_app/dist/unsigned/"
|
2016-12-01 14:33:42 -05: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 05:26:04 -04:00
|
|
|
cp $distdir/*.dmg "$pubdir/install/macos/"
|
2016-12-01 14:33:42 -05:00
|
|
|
|
2017-09-06 08:28:21 -04:00
|
|
|
# Windows installers go to the dist dir because they need signing
|
2016-12-05 09:08:27 -05:00
|
|
|
mkdir -p "$pubdir/install/win32/ia32/"
|
2019-02-14 08:13:53 -05:00
|
|
|
mkdir -p "$projdir/electron_app/dist/unsigned/ia32/"
|
2019-02-14 08:05:49 -05:00
|
|
|
cp $distdir/squirrel-windows-ia32/*.exe "$projdir/electron_app/dist/unsigned/ia32/"
|
2016-12-05 09:08:27 -05:00
|
|
|
|
|
|
|
mkdir -p "$pubdir/install/win32/x64/"
|
2019-02-14 08:13:53 -05:00
|
|
|
mkdir -p "$projdir/electron_app/dist/unsigned/x64/"
|
2019-02-14 08:05:49 -05:00
|
|
|
cp $distdir/squirrel-windows/*.exe "$projdir/electron_app/dist/unsigned/x64/"
|
2016-12-01 14:33:42 -05:00
|
|
|
|
2016-12-05 09:08:27 -05:00
|
|
|
# Packages for auto-update
|
2016-12-01 14:33:42 -05:00
|
|
|
mkdir -p "$pubdir/update/macos"
|
2018-10-16 05:26:04 -04:00
|
|
|
cp $distdir/*-mac.zip "$pubdir/update/macos/"
|
2016-12-09 13:29:54 -05:00
|
|
|
echo "$vername" > "$pubdir/update/macos/latest"
|
2016-12-01 14:33:42 -05:00
|
|
|
|
2016-12-05 09:08:27 -05:00
|
|
|
mkdir -p "$pubdir/update/win32/ia32/"
|
2019-02-14 07:54:26 -05:00
|
|
|
cp $distdir/squirrel-windows-ia32/*.nupkg "$pubdir/update/win32/ia32/"
|
|
|
|
cp $distdir/squirrel-windows-ia32/RELEASES "$pubdir/update/win32/ia32/"
|
2016-12-05 09:08:27 -05:00
|
|
|
|
|
|
|
mkdir -p "$pubdir/update/win32/x64/"
|
2019-02-14 07:54:26 -05:00
|
|
|
cp $distdir/squirrel-windows/*.nupkg "$pubdir/update/win32/x64/"
|
|
|
|
cp $distdir/squirrel-windows/RELEASES "$pubdir/update/win32/x64/"
|
2016-12-05 09:08:27 -05:00
|
|
|
|
2019-03-07 06:12:43 -05: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 14:33:42 -05:00
|
|
|
|
|
|
|
rm -rf "$builddir"
|
|
|
|
|
2017-09-06 08:28:21 -04:00
|
|
|
echo "Unsigned Windows installers have been placed in electron_app/dist/unsigned/ - sign them,"
|
|
|
|
echo "or just copy them to "$pubdir/install/win32/\<arch\>/""
|
|
|
|
echo "Once you've done this, $pubdir can be hosted on your web server."
|
2017-05-10 08:36:27 -04:00
|
|
|
echo "deb archives are in electron_app/dist/ - these should be added into your debian repository"
|