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
|
2022-11-15 16:49:17 +01:00
|
|
|
[[ "$version" =~ ^[0-9]+\.[0-9]+(-[a-z0-9]+)?$ ]] \
|
2022-06-25 02:54:09 +02:00
|
|
|
|| 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)
|
2022-11-15 16:49:17 +01:00
|
|
|
[ "$branch" == "main" ] || [[ "$branch" =~ ^[0-9]+\.x$ ]] || [ "$branch" == "${version}-branch" ] \
|
2022-06-25 02:54:09 +02:00
|
|
|
|| fail "Current branch '$branch' is not 'main' or a release branch"
|
|
|
|
|
2022-11-15 16:49:17 +01:00
|
|
|
is_prerelease=
|
|
|
|
if [[ "$version" =~ -[0-9a-z]+$ ]]; then
|
|
|
|
is_prerelease=1
|
|
|
|
fi
|
|
|
|
|
2022-06-25 02:54:09 +02:00
|
|
|
is_major_release=
|
2023-07-06 20:56:34 +02:00
|
|
|
if [[ "$version" =~ ^[0-9]+\.0(-[0-9a-z]+)?$ ]]; then
|
2022-06-25 02:54:09 +02:00
|
|
|
[ "$branch" == "main" ] \
|
2022-11-15 17:06:59 +01:00
|
|
|
|| fail "Did not expect $version to be released from $branch, expected main"
|
2023-07-06 20:56:34 +02:00
|
|
|
if [ -z "$is_prerelease" ]; then
|
|
|
|
is_major_release=1
|
2022-11-15 16:49:17 +01:00
|
|
|
fi
|
2023-07-06 20:56:34 +02:00
|
|
|
else
|
|
|
|
expected_branch="$(echo "$version" | perl -ple 's/\..*/.x/')"
|
2022-11-15 17:06:59 +01:00
|
|
|
[ "$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"
|
2023-01-24 02:42:35 +01:00
|
|
|
./tools/test-documentation --skip-external-links \
|
|
|
|
|| fail "Changelog links do not validate"
|
|
|
|
./tools/run-codespell docs/overview/changelog.md \
|
|
|
|
|| fail "Changelog does not pass spellcheck"
|
2022-06-25 02:54:09 +02:00
|
|
|
|
|
|
|
# Check the date is correct for the release
|
2023-06-27 19:55:25 +02:00
|
|
|
release_lines=$(grep -x -m 1 -A2 "### Zulip Server $version" docs/overview/changelog.md) \
|
2022-06-25 02:54:09 +02:00
|
|
|
|| fail "docs/overview/changelog.md does not contain a line for $version"
|
2023-06-27 19:55:25 +02:00
|
|
|
release_date_line=$(echo "$release_lines" | grep -x -E -m 1 '_Released ([0-9-]+)_') \
|
|
|
|
|| fail "docs/overview/changelog.md does not contain the release date for $version"
|
2022-11-15 17:24:25 +01:00
|
|
|
expected_date="$(TZ=America/Los_Angeles date +%F)"
|
2023-06-27 19:55:25 +02:00
|
|
|
[ "$release_date_line" == "_Released ${expected_date}_" ] \
|
2022-11-15 17:24:25 +01:00
|
|
|
|| 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"
|
2022-11-15 16:49:17 +01:00
|
|
|
|
|
|
|
if [ -z "$is_prerelease" ]; then
|
|
|
|
[ "$(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")"
|
2023-01-31 12:11:45 +01:00
|
|
|
grep -q -F -x "**Feature level $feature_level**" api_docs/changelog.md \
|
|
|
|
|| fail "Feature level $feature_level is not documented in api_docs/changelog.md"
|
2022-11-15 16:49:17 +01:00
|
|
|
fi
|
2022-06-25 02:54:09 +02:00
|
|
|
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
|
2023-07-06 20:51:57 +02:00
|
|
|
changelog_anchor="zulip-server-${version//./-}"
|
2024-03-19 23:17:02 +01:00
|
|
|
changelog=$(VERSION="$version" perl -nle '$v=quotemeta($ENV{VERSION}); print if $rc = /^### Zulip Server $v/ .. /^#{1,3} Zulip Server (?!$v)/ and $rc !~ /E0/' docs/overview/changelog.md)
|
2022-06-25 02:54:09 +02:00
|
|
|
echo "$changelog"
|
|
|
|
|
|
|
|
echo -e "\n\n(pausing for 15s, ^C to cancel)"
|
|
|
|
sleep 15
|
|
|
|
|
|
|
|
git tag "$version"
|
|
|
|
|
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-11-15 16:31:43 +01:00
|
|
|
# Push the commits
|
|
|
|
remote="$(git config zulip.zulipRemote)" || remote=upstream
|
|
|
|
git push "$remote" "$branch:$branch"
|
2022-08-25 02:03:02 +02:00
|
|
|
git push "$remote" "$version"
|
2022-06-25 02:54:09 +02:00
|
|
|
|
|
|
|
# Upload to Github
|
2022-11-15 16:49:17 +01:00
|
|
|
params=()
|
|
|
|
if [ -n "$is_prerelease" ]; then
|
|
|
|
params+=("--prerelease")
|
|
|
|
fi
|
2022-06-25 02:54:09 +02:00
|
|
|
gh release create "$version" \
|
|
|
|
--title "Zulip Server $version" \
|
2023-07-06 20:51:57 +02:00
|
|
|
--notes "[Complete release notes](https://zulip.readthedocs.io/en/latest/overview/changelog.html#${changelog_anchor})" \
|
2022-11-15 16:49:17 +01:00
|
|
|
"${params[@]}" \
|
2022-06-25 02:54:09 +02:00
|
|
|
"$TARBALL"
|