mirror of https://github.com/zulip/zulip.git
92 lines
2.5 KiB
Bash
Executable File
92 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
set -x
|
|
|
|
GITID=$(git rev-parse HEAD)
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: $0 <ZULIP_VERSION>"
|
|
exit 1
|
|
fi
|
|
version="$1"
|
|
prefix="zulip-server-$version"
|
|
|
|
if [ "$(uname)" = "Darwin" ]; then
|
|
TMPDIR=/tmp/voyager-build
|
|
rm -Rf "$TMPDIR"
|
|
mkdir -p "$TMPDIR"
|
|
else
|
|
TMPDIR=$(mktemp -d)
|
|
fi
|
|
|
|
if ! git diff --exit-code >/dev/null; then
|
|
set +x
|
|
echo; echo "\033[31mWARNING: tarballs builds are based on a commit hash so your changes will not be included\033[0m"; echo
|
|
set -x
|
|
fi
|
|
|
|
TMP_CHECKOUT=$TMPDIR/$prefix/
|
|
TARBALL=$TMPDIR/$prefix.tar
|
|
|
|
# .gitattributes lists the files that are not exported
|
|
git archive -o "$TARBALL" "--prefix=$prefix/" HEAD
|
|
|
|
|
|
if tar -tf "$TARBALL" | grep -q -e zilencer -e zproject/local_settings.py -e puppet/zulip_internal; then
|
|
echo "Excluded files remain in tarball!";
|
|
echo "Versions of git 1.8.1.1 - 1.8.1.6 have broken .gitattributes syntax";
|
|
exit 1;
|
|
else
|
|
echo "Check for excluded files passed";
|
|
fi
|
|
|
|
# Check out a temporary full copy of the index to generate static files
|
|
git checkout-index -f -a --prefix "$TMP_CHECKOUT"
|
|
cd "$TMP_CHECKOUT"
|
|
|
|
# Use default settings so there is no chance of leaking secrets
|
|
cp zproject/local_settings_template.py zproject/local_settings.py
|
|
|
|
# Some settings need to be updated for update-prod-static to work
|
|
#
|
|
# TODO: Would be much better to instead run the below tools with some
|
|
# sort of environment hack to make settings.VOYAGER=True so that we
|
|
# don't need to create this dummy secrets file.
|
|
cat >> zproject/local_settings_template.py <<EOF
|
|
DEBUG = False
|
|
EOF
|
|
cat >> zproject/dev-secrets.conf <<EOF
|
|
[secrets]
|
|
local_database_password = ''
|
|
secret_key = 'not_used_here'
|
|
shared_secret = 'not_used_here'
|
|
avatar_salt = 'not_used_here'
|
|
rabbitmq_password = 'not_used_here'
|
|
initial_password_salt = 'not_used_here'
|
|
EOF
|
|
|
|
# update-prod-static generates the prod-static directory.
|
|
# See COLLECTSTATIC in settings.py
|
|
set +x
|
|
echo; echo "\033[33mRunning update-prod-static; check ${TMP_CHECKOUT}update-prod-static.log if it fails\033[0m"; echo
|
|
set -x
|
|
|
|
./tools/update-prod-static
|
|
echo "$GITID" > build_id
|
|
echo "$version" > version
|
|
mv update-prod-static.log ..
|
|
|
|
rm -f zproject/dev-secrets.conf
|
|
|
|
# We don't need duplicate copies of emoji with hashed paths, and they would break bugdown
|
|
find prod-static/serve/third/gemoji/images/emoji/ -regex '.*\.[0-9a-f]+\.png' -delete
|
|
|
|
cd "$TMPDIR"
|
|
|
|
tar --append -f "$TARBALL" "$prefix/prod-static" "$prefix/build_id" "$prefix/version" "$prefix/locale"
|
|
|
|
rm -rf "$prefix"
|
|
|
|
gzip "$TARBALL"
|
|
echo "Generated $TARBALL.gz"
|