123 lines · 3.7 KB · Text
RawDownload
#!/usr/bin/env bash set -eu # Ensure cargo-edit is installedwhich 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  echo "can't bump versions with uncommitted changes"  exit 1fiif [[ $(git rev-parse --abbrev-ref HEAD) != "main" ]]; then  echo "this command must be run on main"  exit 1figit pull -q --ff-only origin main # Parse the current versionversion=$(script/get-crate-version zed)major=$(echo $version | cut -d. -f1)minor=$(echo $version | cut -d. -f2)patch=$(echo $version | cut -d. -f3)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"preview_tag_name="v${major}.${minor}.${patch}-pre"bump_main_branch_name="set-minor-version-to-${major}.${next_minor}" git fetch origin ${prev_minor_branch_name}:${prev_minor_branch_name}git fetch origin --tagscargo check -q function cleanup {  git checkout -q main}trap cleanup EXIT echo "Checking invariants before taking any actions..."if [[ $(cat crates/zed/RELEASE_CHANNEL) != dev && $(cat crates/zed/RELEASE_CHANNEL) != nightly ]]; then  echo "release channel on main should be dev or nightly"  exit 1fiif git show-ref --quiet refs/tags/${preview_tag_name}; then  echo "tag ${preview_tag_name} already exists"  exit 1fiif git show-ref --quiet refs/heads/${minor_branch_name}; then  echo "branch ${minor_branch_name} already exists"  exit 1fiif ! git show-ref --quiet refs/heads/${prev_minor_branch_name}; then  echo "previous branch ${minor_branch_name} doesn't exist"  exit 1fiif [[ $(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 1fi echo "Promoting existing branch ${prev_minor_branch_name} to stable..."git checkout -q ${prev_minor_branch_name}git clean -q -dffstable_tag_name="v$(script/get-crate-version zed)"if git show-ref --quiet refs/tags/${stable_tag_name}; then  echo "tag ${stable_tag_name} already exists"  exit 1fiold_prev_minor_sha=$(git rev-parse HEAD)echo -n stable > crates/zed/RELEASE_CHANNELgit commit -q --all --message "${prev_minor_branch_name} stable"git tag ${stable_tag_name} echo "Creating new preview branch ${minor_branch_name}..."git checkout -q maingit checkout -q -b ${minor_branch_name}echo -n preview > crates/zed/RELEASE_CHANNELgit commit -q --all --message "${minor_branch_name} preview"git tag ${preview_tag_name} echo "Preparing main for version ${next_minor_branch_name}..."git checkout -q maingit clean -q -dffgit checkout -q -b ${bump_main_branch_name}cargo set-version --package zed --bump minorcargo check -q git commit -q --all --message "${next_minor_branch_name} dev" git checkout -q main cat <<MESSAGEPrepared new Zed versions locally. You will need to push the branches and open a PR for the change to main. # To push and open a PR to update main:     git push -u origin \\      ${preview_tag_name} \\      ${stable_tag_name} \\      ${minor_branch_name} \\      ${prev_minor_branch_name} \\      ${bump_main_branch_name}     echo -e "Release Notes:\n\n- N/A" | gh pr create \\      --title "Bump Zed to v${major}.${next_minor}" \\      --body-file "-" \\      --base main \\      --head ${bump_main_branch_name} \\      --web # To undo this push:     git push -f . \\      :${preview_tag_name} \\      :${stable_tag_name} \\      :${minor_branch_name} \\      :${bump_main_branch_name} \\      ${old_prev_minor_sha}:${prev_minor_branch_name} MESSAGE