zed/script/bump-zed-minor-versions

116 lines
3.3 KiB
Plaintext
Raw Permalink Normal View History

2022-10-26 22:19:49 +03:00
#!/bin/bash
set -eu
# Ensure cargo-edit is installed
which cargo-set-version > /dev/null || cargo install cargo-edit
# Ensure we're in a clean state on an up-to-date `main` branch.
if [[ -n $(git status --short --untracked-files=no) ]]; then
2022-10-27 22:00:45 +03:00
echo "can't bump versions with uncommitted changes"
2022-10-26 22:19:49 +03:00
exit 1
fi
if [[ $(git rev-parse --abbrev-ref HEAD) != "main" ]]; then
2022-10-27 22:00:45 +03:00
echo "this command must be run on main"
2022-10-26 22:19:49 +03:00
exit 1
fi
git pull -q --ff-only origin main
# Parse the current version
2022-10-26 22:19:49 +03:00
version=$(script/get-crate-version zed)
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
patch=$(echo $version | cut -d. -f3)
2022-10-26 22:19:49 +03:00
prev_minor=$(expr $minor - 1)
next_minor=$(expr $minor + 1)
minor_branch_name="v${major}.${minor}.x"
prev_minor_branch_name="v${major}.${prev_minor}.x"
next_minor_branch_name="v${major}.${next_minor}.x"
2022-10-27 22:00:45 +03:00
preview_tag_name="v${major}.${minor}.${patch}-pre"
git fetch origin ${prev_minor_branch_name}:${prev_minor_branch_name}
git fetch origin --tags
cargo check -q
function cleanup {
git checkout -q main
}
trap cleanup EXIT
echo "Checking invariants before taking any actions..."
if [[ $patch != 0 ]]; then
echo "patch version on main should be zero"
exit 1
fi
if [[ $(cat crates/zed/RELEASE_CHANNEL) != dev ]]; then
echo "release channel on main should be dev"
exit 1
fi
if git show-ref --quiet refs/tags/${preview_tag_name}; then
echo "tag ${preview_tag_name} already exists"
exit 1
fi
if git show-ref --quiet refs/heads/${minor_branch_name}; then
echo "branch ${minor_branch_name} already exists"
exit 1
fi
if ! git show-ref --quiet refs/heads/${prev_minor_branch_name}; then
echo "previous branch ${minor_branch_name} doesn't exist"
exit 1
fi
if [[ $(git show ${prev_minor_branch_name}:crates/zed/RELEASE_CHANNEL) != preview ]]; then
echo "release channel on branch ${prev_minor_branch_name} should be preview"
exit 1
fi
2022-10-26 22:19:49 +03:00
echo "Promoting existing branch ${prev_minor_branch_name} to stable..."
git checkout -q ${prev_minor_branch_name}
git clean -q -dff
stable_tag_name="v$(script/get-crate-version zed)"
if git show-ref --quiet refs/tags/${stable_tag_name}; then
echo "tag ${preview_tag_name} already exists"
exit 1
fi
2022-10-26 22:19:49 +03:00
old_prev_minor_sha=$(git rev-parse HEAD)
echo -n stable > crates/zed/RELEASE_CHANNEL
2022-10-27 22:00:45 +03:00
git commit -q --all --message "${prev_minor_branch_name} stable"
2022-10-26 22:19:49 +03:00
git tag ${stable_tag_name}
echo "Creating new preview branch ${minor_branch_name}..."
git checkout -q main
2022-10-26 22:19:49 +03:00
git checkout -q -b ${minor_branch_name}
echo -n preview > crates/zed/RELEASE_CHANNEL
2022-10-27 22:00:45 +03:00
git commit -q --all --message "${minor_branch_name} preview"
2022-10-26 22:19:49 +03:00
git tag ${preview_tag_name}
echo "Preparing main for version ${next_minor_branch_name}..."
git checkout -q main
git clean -q -dff
old_main_sha=$(git rev-parse HEAD)
cargo set-version --package zed --bump minor
cargo check -q
2022-10-27 22:00:45 +03:00
git commit -q --all --message "${next_minor_branch_name} dev"
2022-10-26 22:19:49 +03:00
cat <<MESSAGE
2022-10-27 22:00:45 +03:00
Prepared new Zed versions locally.
2022-10-26 22:19:49 +03:00
To push this:
2022-10-26 22:19:49 +03:00
git push origin \\
${preview_tag_name} \\
${stable_tag_name} \\
${minor_branch_name} \\
${prev_minor_branch_name} \\
main
To undo this:
2022-10-27 22:00:45 +03:00
git reset --hard ${old_main_sha} && git push -f . \\
2022-10-26 22:19:49 +03:00
:${preview_tag_name} \\
:${stable_tag_name} \\
:${minor_branch_name} \\
2022-10-27 22:00:45 +03:00
${old_prev_minor_sha}:${prev_minor_branch_name}
2022-10-26 22:19:49 +03:00
MESSAGE