2022-06-25 02:54:09 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
|
|
|
|
if [ -z "${1:-}" ]; then
|
|
|
|
echo "Usage: $0 version"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
fail() {
|
|
|
|
echo "$1"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
version="$1"
|
|
|
|
|
|
|
|
# Check version is a form we expect
|
|
|
|
[[ "$version" =~ ^[0-9]+\.[0-9]+$ ]] \
|
|
|
|
|| fail "Version $version does not look like a full release!"
|
|
|
|
|
|
|
|
# Check we're on `main` or `\d+\.x`
|
|
|
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
[ "$branch" == "main" ] || [[ "$branch" =~ ^[0-9]+\.x$ ]] \
|
|
|
|
|| fail "Current branch '$branch' is not 'main' or a release branch"
|
|
|
|
|
|
|
|
is_major_release=
|
|
|
|
if [[ "$version" =~ ^[0-9]+\.0$ ]]; then
|
|
|
|
[ "$branch" == "main" ] \
|
2022-11-15 17:06:59 +01:00
|
|
|
|| fail "Did not expect $version to be released from $branch, expected main"
|
2022-06-25 02:54:09 +02:00
|
|
|
is_major_release=1
|
|
|
|
else
|
2022-11-15 17:06:59 +01:00
|
|
|
expected_branch="$(echo "$version" | perl -ple 's/\..*/.x/')"
|
|
|
|
[ "$branch" == "$expected_branch" ] \
|
|
|
|
|| fail "Did not expect $version to be released from $branch, expected $expected_branch"
|
2022-06-25 02:54:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# shellcheck source=lib/git-tools.bash
|
|
|
|
. "$(dirname "$0")"/lib/git-tools.bash
|
|
|
|
require_clean_work_tree 'build and upload a release'
|
|
|
|
|
|
|
|
# Check the commit message
|
|
|
|
commit_msg=$(git rev-list --format=%B --max-count=1 HEAD | tail -n +2)
|
|
|
|
[ "$commit_msg" == "Release Zulip Server $version." ] \
|
|
|
|
|| fail "Expected commit message: Release Zulip Server $version."
|
|
|
|
|
|
|
|
# Provision
|
|
|
|
echo "Provisioning.."
|
|
|
|
if ! ./tools/provision >/dev/null; then
|
|
|
|
cat var/log/provision.log
|
|
|
|
fail "Provisioning failed!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check lint passes for the changelog
|
|
|
|
./tools/lint --skip gitlint docs/overview/changelog.md \
|
|
|
|
|| fail "Changelog does not pass lint"
|
|
|
|
|
|
|
|
# Check the date is correct for the release
|
|
|
|
release_line=$(grep -x -E -m 1 -o "### $version -- ([0-9-]+)" docs/overview/changelog.md) \
|
|
|
|
|| fail "docs/overview/changelog.md does not contain a line for $version"
|
2022-11-15 17:24:25 +01:00
|
|
|
expected_date="$(TZ=America/Los_Angeles date +%F)"
|
|
|
|
[ "$release_line" == "### $version -- $expected_date" ] \
|
|
|
|
|| fail "Date in docs/overview/changelog.md does not match '$expected_date'"
|
2022-06-25 02:54:09 +02:00
|
|
|
|
|
|
|
extract_version() {
|
|
|
|
setting="$1"
|
|
|
|
value=$(SETTING="$setting" perl -nle 'print $2 if /$ENV{SETTING} = (\"?)([^"]+)\1$/' version.py | head -n1)
|
|
|
|
[ -n "$value" ] || fail "Could not find $setting in version.py"
|
|
|
|
echo "$value"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check ZULIP_VERSION and LATEST_RELEASE_VERSION are set appropriately
|
|
|
|
[ "$(extract_version "ZULIP_VERSION")" == "$version" ] \
|
|
|
|
|| fail "ZULIP_VERSION in version.py does not match $version"
|
|
|
|
[ "$(extract_version "LATEST_RELEASE_VERSION")" == "$version" ] \
|
|
|
|
|| fail "LATEST_RELEASE_VERSION in version.py does not match $version"
|
|
|
|
|
|
|
|
if [ -n "$is_major_release" ]; then
|
|
|
|
[ "$(extract_version "LATEST_MAJOR_VERSION")" == "$version" ] \
|
|
|
|
|| fail "LATEST_MAJOR_VERSION in version.py does not match $version"
|
|
|
|
|
|
|
|
# Check that there is an API version bump, which is documented
|
|
|
|
changed_api_level=$(git diff-tree -G API_FEATURE_LEVEL HEAD -- version.py)
|
|
|
|
[ -n "$changed_api_level" ] || fail "$version did not adjust API_FEATURE_LEVEL in version.py"
|
|
|
|
feature_level="$(extract_version "API_FEATURE_LEVEL")"
|
|
|
|
grep -q -F -x "**Feature level $feature_level**" templates/zerver/api/changelog.md \
|
|
|
|
|| fail "Feature level $feature_level is not documented in templates/zerver/api/changelog.md"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check we are auth'd to Github, so we can upload the release
|
|
|
|
type gh >/dev/null 2>&1 \
|
|
|
|
|| fail "The 'gh' CLI tool is not installed; see https://cli.github.com/"
|
|
|
|
gh auth status \
|
|
|
|
|| fail "Not authenticated to github"
|
|
|
|
|
|
|
|
# Extract the changelog, print it
|
|
|
|
changelog=$(VERSION="$version" perl -nle '$v=quotemeta($ENV{VERSION}); print if $rc = /^### $v/ .. /^#{1,3} (?!$v)/ and $rc !~ /E0/' docs/overview/changelog.md)
|
|
|
|
echo "$changelog"
|
|
|
|
|
|
|
|
echo -e "\n\n(pausing for 15s, ^C to cancel)"
|
|
|
|
sleep 15
|
|
|
|
|
|
|
|
git tag "$version"
|
|
|
|
|
|
|
|
# Commits need to be pushed to the remote so that "branched from" is correct
|
|
|
|
remote="$(git config zulip.zulipRemote)" || remote=upstream
|
|
|
|
git push "$remote" "$branch:$branch"
|
|
|
|
|
2022-07-20 00:59:00 +02:00
|
|
|
OUTPUT_DIR=$(mktemp -d)
|
|
|
|
export OUTPUT_DIR
|
2022-06-25 02:54:09 +02:00
|
|
|
|
|
|
|
./tools/build-release-tarball "$version"
|
|
|
|
|
2022-08-23 07:39:54 +02:00
|
|
|
TARBALL="$OUTPUT_DIR/zulip-server-$version.tar.gz"
|
2022-06-25 02:54:09 +02:00
|
|
|
if ! [ -f "$TARBALL" ]; then
|
|
|
|
echo "Did not find expected $TARBALL!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
./tools/upload-release "$TARBALL"
|
|
|
|
|
2022-08-25 02:03:02 +02:00
|
|
|
git push "$remote" "$version"
|
2022-06-25 02:54:09 +02:00
|
|
|
|
|
|
|
# Upload to Github
|
|
|
|
gh release create "$version" \
|
|
|
|
--title "Zulip Server $version" \
|
|
|
|
--notes-file <(echo "$changelog") \
|
|
|
|
"$TARBALL"
|