2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
2017-11-17 07:16:05 +01:00
|
|
|
set -eu
|
2016-11-22 07:00:12 +01:00
|
|
|
|
2021-06-11 00:35:35 +02:00
|
|
|
# shellcheck source=lib/git-tools.bash
|
|
|
|
. "$(dirname "$0")"/lib/git-tools.bash
|
|
|
|
|
2016-11-22 07:00:12 +01:00
|
|
|
usage() {
|
2020-04-24 22:26:32 +02:00
|
|
|
echo "Usage: $0 <ZULIP_VERSION>" >&2
|
2016-11-22 07:00:12 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2020-04-24 22:26:32 +02:00
|
|
|
args="$(getopt -o '' -l 'help' -n "$0" -- "$@")"
|
2016-11-22 07:00:12 +01:00
|
|
|
eval "set -- $args"
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
2020-10-15 04:55:57 +02:00
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*) usage ;;
|
2016-11-22 07:00:12 +01:00
|
|
|
esac
|
|
|
|
done
|
2013-10-29 20:04:55 +01:00
|
|
|
|
2016-11-22 07:00:12 +01:00
|
|
|
if [ -z "${1:-}" ]; then
|
|
|
|
usage
|
2013-11-13 22:50:40 +01:00
|
|
|
fi
|
2017-11-17 07:16:05 +01:00
|
|
|
|
2013-11-13 22:50:40 +01:00
|
|
|
version="$1"
|
|
|
|
prefix="zulip-server-$version"
|
|
|
|
|
2021-06-11 00:35:35 +02:00
|
|
|
require_clean_work_tree 'build a release tarball'
|
|
|
|
|
2017-11-17 07:16:05 +01:00
|
|
|
set -x
|
|
|
|
GITID=$(git rev-parse HEAD)
|
|
|
|
|
2020-06-08 21:52:13 +02:00
|
|
|
umask 022
|
|
|
|
|
2022-06-25 00:59:18 +02:00
|
|
|
OUTPUT_DIR=${OUTPUT_DIR:-$(mktemp -d)}
|
|
|
|
TARBALL=$OUTPUT_DIR/$prefix.tar
|
2017-10-12 06:20:06 +02:00
|
|
|
BASEDIR=$(pwd)
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
git archive -o "$TARBALL" "--prefix=$prefix/" HEAD
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2022-06-25 00:59:18 +02:00
|
|
|
cd "$OUTPUT_DIR"
|
2017-10-12 06:20:06 +02:00
|
|
|
tar -xf "$TARBALL"
|
2018-08-03 02:14:48 +02:00
|
|
|
while read -r i; do
|
2022-06-25 00:59:18 +02:00
|
|
|
rm -r --interactive=never "${OUTPUT_DIR:?}/$prefix/$i"
|
|
|
|
done <"$OUTPUT_DIR/$prefix/tools/release-tarball-exclude.txt"
|
2017-10-12 06:20:06 +02:00
|
|
|
tar -cf "$TARBALL" "$prefix"
|
|
|
|
rm -rf "$prefix"
|
2013-11-13 00:46:35 +01:00
|
|
|
|
2017-08-16 05:06:53 +02:00
|
|
|
if tar -tf "$TARBALL" | grep -q -e ^zerver/tests; then
|
2017-07-29 06:13:51 +02:00
|
|
|
set +x
|
2017-10-12 06:20:06 +02:00
|
|
|
echo "BUG: Excluded files remain in tarball!"
|
|
|
|
exit 1
|
2013-11-13 00:46:35 +01:00
|
|
|
fi
|
2017-10-12 06:20:06 +02:00
|
|
|
cd "$BASEDIR"
|
2016-11-22 07:00:12 +01:00
|
|
|
|
2013-11-12 17:13:19 +01:00
|
|
|
# Check out a temporary full copy of the index to generate static files
|
2022-06-25 00:59:18 +02:00
|
|
|
git checkout-index -f -a --prefix "$OUTPUT_DIR/$prefix/"
|
2019-04-21 05:51:20 +02:00
|
|
|
|
2020-10-23 02:43:28 +02:00
|
|
|
# Add the Git version information file
|
2022-11-15 16:49:17 +01:00
|
|
|
if [[ "$version" =~ ^[0-9]+\.[0-9]+(-[0-9a-z]+)?$ ]]; then
|
2022-11-15 16:31:43 +01:00
|
|
|
# We override the merge-base, to avoid having to push the commits before building the tarball.
|
|
|
|
OVERRIDE_MERGE_BASE="$version" ./tools/cache-zulip-git-version
|
2022-06-24 02:38:39 +02:00
|
|
|
generated_version=$(head -n1 zulip-git-version)
|
|
|
|
if [ "$generated_version" != "$version" ]; then
|
|
|
|
echo "Version $version looks like a release version, but is not tagged yet! Got $generated_version"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-11-15 16:31:43 +01:00
|
|
|
else
|
|
|
|
./tools/cache-zulip-git-version
|
2022-06-24 02:38:39 +02:00
|
|
|
fi
|
2022-06-25 00:59:18 +02:00
|
|
|
mv zulip-git-version "$OUTPUT_DIR/$prefix/"
|
2019-04-21 05:51:20 +02:00
|
|
|
|
2022-06-25 00:59:18 +02:00
|
|
|
cd "$OUTPUT_DIR/$prefix"
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2019-07-21 00:40:34 +02:00
|
|
|
ln -s "$BASEDIR/zulip-py3-venv" .
|
|
|
|
|
2016-07-09 09:08:41 +02:00
|
|
|
# create var/log directory in the new temporary checkout
|
|
|
|
mkdir -p "var/log"
|
|
|
|
|
2015-08-21 01:27:35 +02:00
|
|
|
# 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
|
2017-09-29 02:30:17 +02:00
|
|
|
# sort of environment hack so that we don't need to create this dummy
|
|
|
|
# secrets file.
|
2020-10-15 04:55:57 +02:00
|
|
|
cat >>zproject/prod_settings_template.py <<EOF
|
2013-11-12 20:37:23 +01:00
|
|
|
DEBUG = False
|
2015-08-21 01:27:35 +02:00
|
|
|
EOF
|
2020-10-15 04:55:57 +02:00
|
|
|
cat >>zproject/dev-secrets.conf <<EOF
|
2015-08-21 01:27:35 +02:00
|
|
|
[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'
|
2013-11-12 20:37:23 +01:00
|
|
|
EOF
|
|
|
|
|
2020-04-24 22:26:32 +02:00
|
|
|
./tools/update-prod-static
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2020-08-11 01:47:49 +02:00
|
|
|
# We don't need duplicate copies of emoji with hashed paths, and they would break Markdown
|
2016-12-28 05:07:10 +01:00
|
|
|
find prod-static/serve/generated/emoji/images/emoji/ -regex '.*\.[0-9a-f]+\.png' -delete
|
2013-11-14 16:36:29 +01:00
|
|
|
|
2020-10-15 04:55:57 +02:00
|
|
|
echo "$GITID" >build_id
|
|
|
|
echo "$version" >version
|
2017-07-29 06:15:33 +02:00
|
|
|
|
2022-06-25 00:59:18 +02:00
|
|
|
cd "$OUTPUT_DIR"
|
2013-11-12 17:13:19 +01:00
|
|
|
|
2023-04-05 11:19:58 +02:00
|
|
|
tar --append -f "$TARBALL" "$prefix/prod-static" "$prefix/build_id" "$prefix/version" "$prefix/zulip-git-version" "$prefix/locale" "$prefix/staticfiles.json" "$prefix/webpack-stats-production.json"
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
rm -rf "$prefix"
|
2013-11-12 17:13:19 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
gzip "$TARBALL"
|
2017-07-29 06:13:51 +02:00
|
|
|
|
|
|
|
set +x
|
2022-06-25 00:59:18 +02:00
|
|
|
TARBALL="$TARBALL.gz"
|
|
|
|
|
|
|
|
echo "Generated $TARBALL"
|