From 9fe1982207596697b64589ec668507aa00a7ab74 Mon Sep 17 00:00:00 2001 From: Dominic Cooney Date: Thu, 30 Jan 2025 15:38:15 +0900 Subject: [PATCH 1/7] push-git-tag-for-next-release --- jetbrains/scripts/next-release.sh | 2 +- .../scripts/push-git-tag-for-next-release.sh | 61 ++++++++++++++----- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/jetbrains/scripts/next-release.sh b/jetbrains/scripts/next-release.sh index e373b700f4ea..f62fc8a02fa5 100755 --- a/jetbrains/scripts/next-release.sh +++ b/jetbrains/scripts/next-release.sh @@ -7,7 +7,7 @@ if [ "$#" -ne 1 ]; then exit 1 fi -LAST_MAJOR_MINOR_ZERO_RELEASE=$(git tag -l | grep "jb-v\d*\\.\d*\\.\d*" | uniq | sort -V | tail -1 | sed 's/-nightly//' | sed 's/-experimental//') +LAST_MAJOR_MINOR_ZERO_RELEASE=$(git tag -l | grep -E 'jb-v[0-9]+\.[0-9]+\.[0-9]+' | uniq | sort -V | tail -1 | sed 's/-nightly//' | sed 's/-experimental//') MAJOR=$(echo $LAST_MAJOR_MINOR_ZERO_RELEASE | sed 's/jb-v//' | cut -d. -f1) MINOR=$(echo $LAST_MAJOR_MINOR_ZERO_RELEASE | sed 's/jb-v//' | cut -d. -f2) PATCH=$(echo $LAST_MAJOR_MINOR_ZERO_RELEASE | sed 's/jb-v//' | cut -d. -f3) diff --git a/jetbrains/scripts/push-git-tag-for-next-release.sh b/jetbrains/scripts/push-git-tag-for-next-release.sh index 4cc2ac54f833..8b2ad4bd1f46 100755 --- a/jetbrains/scripts/push-git-tag-for-next-release.sh +++ b/jetbrains/scripts/push-git-tag-for-next-release.sh @@ -3,6 +3,19 @@ # No arguments needed, the version is automatically computed. set -eux +usage() { + echo "Usage: $0 --major|--minor|--patch [ --nightly|--experimental ] [ --dry-run ]" + exit 1 +} + +execute() { + if [ "$DRY_RUN" -eq 0 ]; then + echo "DRY RUN: $*" + else + "$@" + fi +} + # Check if the current branch is 'main' CURRENT_BRANCH=$(git symbolic-ref --short HEAD) if [ "$CURRENT_BRANCH" != "main" ]; then @@ -21,25 +34,44 @@ if ! git diff-index --quiet HEAD --; then exit 1 fi -# Check the number of arguments -if [ "$#" -ne 2 ]; then - echo "Usage: $0 [--major | --minor | --patch] [ --nightly | --experimental ]" - exit 1 -fi +VERSION_INCREMENT="" +DRY_RUN=0 -CHANNEL="${2#--}" -if [ "$CHANNEL" != "nightly" ] && [ "$CHANNEL" != "experimental" ]; then - echo "Invalid argument. Usage: $0 [--major | --minor | --patch] [ --nightly | --experimental ]" - exit 1 +while [[ $# -gt 0 ]]; do + case $1 in + --major|--minor|--patch) + VERSION_INCREMENT="$1" + shift + ;; + --nightly|--experimental) + CHANNEL="$1" + shift + ;; + --dry-run) + DRY_RUN=1 + shift + ;; + *) + echo "Unknown option: $1" + usage + ;; + esac +done + +# Check one of --major, --minor or --patch was specified. +if [ -z "$VERSION_INCREMENT" ]; then + usage fi +# Fetch git tags so we can compute an accurate next version. +git fetch origin +refs/tags/jb-v*:refs/tags/jb-v* + SCRIPT_DIR="$(dirname "$0")" SCRIPT_DIR="$(readlink -f "$SCRIPT_DIR")" -NEXT_RELEASE_ARG="$1" -NEXT_VERSION="$(bash "$SCRIPT_DIR/next-release.sh" $NEXT_RELEASE_ARG)" +NEXT_VERSION="$(bash "$SCRIPT_DIR/next-release.sh" $VERSION_INCREMENT)" # Check the argument and take appropriate action -if [ "$NEXT_RELEASE_ARG" == "--major" ]; then +if [ "$VERSION_INCREMENT" == "--major" ]; then read -p "[WARNING] Upgrade of the major version in a special event, do you want to proceed? (y/N): " choice if [ "$choice" != "y" ]; then echo "Aborted." @@ -56,7 +88,8 @@ else exit 1 fi -bash "$SCRIPT_DIR/verify-release.sh" +execute bash "$SCRIPT_DIR/verify-release.sh" TAG="jb-v$NEXT_VERSION-$CHANNEL" echo "$TAG" -git tag -a "$TAG" -m "$TAG" && git push origin "$TAG" + +execute git tag -a "$TAG" -m "$TAG" && execute git push origin "$TAG" From f7ff9ac5d3ae942a130184fd693702aac4841aa5 Mon Sep 17 00:00:00 2001 From: Dominic Cooney Date: Thu, 30 Jan 2025 15:42:36 +0900 Subject: [PATCH 2/7] Do not leave a trailing dash in the tag. --- .../scripts/push-git-tag-for-next-release.sh | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/jetbrains/scripts/push-git-tag-for-next-release.sh b/jetbrains/scripts/push-git-tag-for-next-release.sh index 8b2ad4bd1f46..3e77d1f58076 100755 --- a/jetbrains/scripts/push-git-tag-for-next-release.sh +++ b/jetbrains/scripts/push-git-tag-for-next-release.sh @@ -8,14 +8,6 @@ usage() { exit 1 } -execute() { - if [ "$DRY_RUN" -eq 0 ]; then - echo "DRY RUN: $*" - else - "$@" - fi -} - # Check if the current branch is 'main' CURRENT_BRANCH=$(git symbolic-ref --short HEAD) if [ "$CURRENT_BRANCH" != "main" ]; then @@ -35,6 +27,7 @@ if ! git diff-index --quiet HEAD --; then fi VERSION_INCREMENT="" +CHANNEL="" DRY_RUN=0 while [[ $# -gt 0 ]]; do @@ -44,7 +37,7 @@ while [[ $# -gt 0 ]]; do shift ;; --nightly|--experimental) - CHANNEL="$1" + CHANNEL="${1:1}" # Trim one of the leading -s to make a version suffix like -nightly. shift ;; --dry-run) @@ -58,6 +51,14 @@ while [[ $# -gt 0 ]]; do esac done +execute() { + if [ "$DRY_RUN" -eq 0 ]; then + echo "DRY RUN: $*" + else + "$@" + fi +} + # Check one of --major, --minor or --patch was specified. if [ -z "$VERSION_INCREMENT" ]; then usage @@ -80,7 +81,7 @@ if [ "$VERSION_INCREMENT" == "--major" ]; then fi # shellcheck disable=SC2162 -read -p "Confirm that you want to run the release v$NEXT_VERSION-$CHANNEL (y/N): " choice +read -p "Confirm that you want to run the release v$NEXT_VERSION$CHANNEL (y/N): " choice if [ "$choice" == "y" ]; then echo "Running release..." else @@ -89,7 +90,7 @@ else fi execute bash "$SCRIPT_DIR/verify-release.sh" -TAG="jb-v$NEXT_VERSION-$CHANNEL" +TAG="jb-v$NEXT_VERSION$CHANNEL" echo "$TAG" execute git tag -a "$TAG" -m "$TAG" && execute git push origin "$TAG" From ce78b213add71a08aa204bbef3b9c03e833c8462 Mon Sep 17 00:00:00 2001 From: Dominic Cooney Date: Thu, 30 Jan 2025 15:50:44 +0900 Subject: [PATCH 3/7] Reorganize, fix dry run branching. --- .../scripts/push-git-tag-for-next-release.sh | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/jetbrains/scripts/push-git-tag-for-next-release.sh b/jetbrains/scripts/push-git-tag-for-next-release.sh index 3e77d1f58076..413100a187f5 100755 --- a/jetbrains/scripts/push-git-tag-for-next-release.sh +++ b/jetbrains/scripts/push-git-tag-for-next-release.sh @@ -1,24 +1,19 @@ #!/usr/bin/env bash -# Run this script to cut a new release. -# No arguments needed, the version is automatically computed. -set -eux +# Run this script to push a tag that will trigger CI to publish a new release. +set -eu usage() { echo "Usage: $0 --major|--minor|--patch [ --nightly|--experimental ] [ --dry-run ]" exit 1 } -# Check if the current branch is 'main' -CURRENT_BRANCH=$(git symbolic-ref --short HEAD) -if [ "$CURRENT_BRANCH" != "main" ]; then - echo "Warning: You are not on the 'main' branch. You are on '$CURRENT_BRANCH'." - # shellcheck disable=SC2162 - read -p "Are you sure you want to proceed? (y/N): " proceed - if [ "$proceed" != "y" ]; then - echo "Aborted." - exit 1 +execute() { + if [ "$DRY_RUN" -eq 1 ]; then + echo "DRY RUN: $*" + else + "$@" fi -fi +} # Check if the working tree is clean if ! git diff-index --quiet HEAD --; then @@ -51,19 +46,23 @@ while [[ $# -gt 0 ]]; do esac done -execute() { - if [ "$DRY_RUN" -eq 0 ]; then - echo "DRY RUN: $*" - else - "$@" - fi -} - # Check one of --major, --minor or --patch was specified. if [ -z "$VERSION_INCREMENT" ]; then usage fi +# Check if the current branch is 'main' +CURRENT_BRANCH=$(git symbolic-ref --short HEAD) +if [ "$CURRENT_BRANCH" != "main" ]; then + echo "Warning: You are not on the 'main' branch. You are on '$CURRENT_BRANCH'." + # shellcheck disable=SC2162 + read -p "Are you sure you want to proceed? (y/N): " proceed + if [ "$proceed" != "y" ]; then + echo "Aborted." + exit 1 + fi +fi + # Fetch git tags so we can compute an accurate next version. git fetch origin +refs/tags/jb-v*:refs/tags/jb-v* From 14a5a0bf007d2f78c7125b83a3cbd78814dae8de Mon Sep 17 00:00:00 2001 From: Dominic Cooney Date: Thu, 30 Jan 2025 15:55:57 +0900 Subject: [PATCH 4/7] Make the confirmation message less alarming for dry runs. --- jetbrains/scripts/push-git-tag-for-next-release.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/jetbrains/scripts/push-git-tag-for-next-release.sh b/jetbrains/scripts/push-git-tag-for-next-release.sh index 413100a187f5..d8fb6914d2cc 100755 --- a/jetbrains/scripts/push-git-tag-for-next-release.sh +++ b/jetbrains/scripts/push-git-tag-for-next-release.sh @@ -8,10 +8,10 @@ usage() { } execute() { - if [ "$DRY_RUN" -eq 1 ]; then - echo "DRY RUN: $*" - else + if [ -z "$DRY_RUN" ]; then "$@" + else + echo "DRY RUN: $*" fi } @@ -23,7 +23,7 @@ fi VERSION_INCREMENT="" CHANNEL="" -DRY_RUN=0 +DRY_RUN="" while [[ $# -gt 0 ]]; do case $1 in @@ -36,7 +36,7 @@ while [[ $# -gt 0 ]]; do shift ;; --dry-run) - DRY_RUN=1 + DRY_RUN="true" shift ;; *) @@ -64,6 +64,7 @@ if [ "$CURRENT_BRANCH" != "main" ]; then fi # Fetch git tags so we can compute an accurate next version. +echo Fetching git tags to compute next version... git fetch origin +refs/tags/jb-v*:refs/tags/jb-v* SCRIPT_DIR="$(dirname "$0")" @@ -80,7 +81,7 @@ if [ "$VERSION_INCREMENT" == "--major" ]; then fi # shellcheck disable=SC2162 -read -p "Confirm that you want to run the release v$NEXT_VERSION$CHANNEL (y/N): " choice +read -p "Confirm that you want to ${DRY_RUN:+"DRY "}run the release v$NEXT_VERSION$CHANNEL (y/N): " choice if [ "$choice" == "y" ]; then echo "Running release..." else From 3dc5d04761d2898ff7703164560f93fd632fb2cf Mon Sep 17 00:00:00 2001 From: Dominic Cooney Date: Thu, 30 Jan 2025 16:36:18 +0900 Subject: [PATCH 5/7] Update docs. --- jetbrains/CONTRIBUTING.md | 60 ++++++--------------------------------- 1 file changed, 9 insertions(+), 51 deletions(-) diff --git a/jetbrains/CONTRIBUTING.md b/jetbrains/CONTRIBUTING.md index bf4ddeaae184..610d39bf4a25 100644 --- a/jetbrains/CONTRIBUTING.md +++ b/jetbrains/CONTRIBUTING.md @@ -148,70 +148,28 @@ Take the steps below _before_ [running JetBrains plugin with agent](#developing- ## Publishing a New Release -### Historical context -We used to publish both stable and nightly channel versions at once. -In that approach QA testing and JB approval happened in parallel. -However, it consumed a lot of CI time and JB time for the releases that did not pass our QA -(and did not go public eventually). Hence, we decided to use a sequential process. -We trigger the stable channel release only after the nightly channel release passes QA. - -```mermaid -graph TD; - Title --> nightly["Nightly Release / Experimental Release"]; - Title["JetBrains Plugin Release"] --> stable["Stable Release"]; - stable --> trigger_stable["Manually trigger 'Stable Release' workflow in GitHub Actions"]; - release_stable --> marketplace_approval["Wait for JetBrains approval"]; - marketplace_approval --> |Automated approval, up to 48hr| unhide["unhide"]; - unhide --> available_to_end_users_stable["Available for download"]; - marketplace_approval --> |Manual quick-approve| slack_approval["Request JetBrains Marketplace team to manually approve it via Slack"]; - slack_approval --> unhide["Unhide the approved release (requires admin access)"]; - nightly --> push_tag["Run 'push-git-tag-for-next-release.sh'"]; - trigger_stable --> release_stable["Wait for 'Stable Release' workflow to complete"]; - push_tag --> release_nightly["Wait for 'Nightly Release' / 'Experimental Release' workflow to complete"]; - release_nightly --> available_to_end_users_nightly["Available for download"]; -``` - -We aim to cut a new release to "nightly" mid week, every week. If QA or dogfood find issues we backport fixes and -do updated nightly releases. At the end of a week, we re-cut the best build as "stable". - -### 1. Push a git tag & publish a nightly release - -Use the following command for a **patch** release: - -```shell -./scripts/push-git-tag-for-next-release.sh --patch -``` - -Or this one for a **minor** release: +See [Cody Client Releases.](https://sourcegraph.notion.site/Cody-Client-Releases-82244a6d1d90420d839f432b8cc00cd8?pvs=74) -```shell -./scripts/push-git-tag-for-next-release.sh --minor -``` +### Publishing an experimental release -Or this one for a **major** release -(note it should be user only on special occasions): +Use the following command for a **experimental** releases: ```shell -./scripts/push-git-tag-for-next-release.sh --major +./scripts/push-git-tag-for-next-release.sh --patch --experimental ``` This script runs `verify-release.sh`, which takes a long time to run with a clean cache, which is why we don't run it in CI. When you have a local cache of IDEA installations then this script can run decently fast (~1-2min). -After successfully pushing the new tag (for example: `v6.0.15`), we are now able to publish. - -Wait for the `Release to Marketplace` GitHub workflow to complete. - -### 2. Publish a stable release +After successfully pushing the new tag (for example: `jb-v7.66.3-experimental`), we are now able to publish. Wait for the `release-jetbrains-experimental` GitHub workflow to complete. -Go to [Stable Release workflow](https://github.com/sourcegraph/cody/actions/workflows/stable-release.yml), -click `Run workflow` and select the tag that has been pushed before (and tested by QA team), run it. +### Expediting Stable Releases It can take up to 48hr for stable releases to get approved by the JetBrains Marketplace team. It's possible to expedite this process by posting a message in the `#marketplace` channel in the [JetBrains Slack workspace](https://plugins.jetbrains.com/slack/). -### 3. Publish a New Release on GitHub +### Release Notes on GitHub For every stable release, create a GitHub release summarizing the changes. @@ -225,10 +183,10 @@ to [our first release](https://github.com/sourcegraph/jetbrains/releases/tag/v5. It's also optional create GitHub releases for nightly builds where it makes sense. -### 4. Announce the New Release on our internal Slack channel +### Announce the New Release on our internal Slack channel It is mandatory to post about both stable and nightly releases on our internal -`#team-cody-clients` Slack channel. You can refer to past posts in the channel's +`#team-cody-core` Slack channel. You can refer to past posts in the channel's history for examples. ## Enabling web view debugging From 6b1ae1e04e609266c5f519bfd24e002f0dd02fbb Mon Sep 17 00:00:00 2001 From: Dominic Cooney Date: Thu, 30 Jan 2025 16:36:30 +0900 Subject: [PATCH 6/7] Teach next-release.sh about release branches. --- jetbrains/scripts/next-release.sh | 17 +++++++++-- .../scripts/push-git-tag-for-next-release.sh | 29 ++++++++++--------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/jetbrains/scripts/next-release.sh b/jetbrains/scripts/next-release.sh index f62fc8a02fa5..42e36e75dd99 100755 --- a/jetbrains/scripts/next-release.sh +++ b/jetbrains/scripts/next-release.sh @@ -1,13 +1,24 @@ #!/usr/bin/env bash set -eu +# Note: This script requires you to fetch version tags. +# git fetch origin +refs/tags/jb-v*:refs/tags/jb-v* + # Check the number of arguments -if [ "$#" -ne 1 ]; then - echo "Usage: $0 [--major | --minor | --patch]" +if [ "$#" -ne 2 ]; then + echo "Usage: $0 < --major|--minor|--patch > " exit 1 fi -LAST_MAJOR_MINOR_ZERO_RELEASE=$(git tag -l | grep -E 'jb-v[0-9]+\.[0-9]+\.[0-9]+' | uniq | sort -V | tail -1 | sed 's/-nightly//' | sed 's/-experimental//') +MERGE_BASE="$2" + +LAST_MAJOR_MINOR_ZERO_RELEASE=$(git tag -l 'jb-v*' --contains "$MERGE_BASE" | sort -V | tail -1 | sed 's/-nightly//' | sed 's/-experimental//') + +if [ -z "$LAST_MAJOR_MINOR_ZERO_RELEASE" ]; then + # This is a new release branch. + LAST_MAJOR_MINOR_ZERO_RELEASE=$(git tag -l | grep -E 'jb-v[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -1 | sed 's/-nightly//' | sed 's/-experimental//') +fi + MAJOR=$(echo $LAST_MAJOR_MINOR_ZERO_RELEASE | sed 's/jb-v//' | cut -d. -f1) MINOR=$(echo $LAST_MAJOR_MINOR_ZERO_RELEASE | sed 's/jb-v//' | cut -d. -f2) PATCH=$(echo $LAST_MAJOR_MINOR_ZERO_RELEASE | sed 's/jb-v//' | cut -d. -f3) diff --git a/jetbrains/scripts/push-git-tag-for-next-release.sh b/jetbrains/scripts/push-git-tag-for-next-release.sh index d8fb6914d2cc..0dd2ad5c066b 100755 --- a/jetbrains/scripts/push-git-tag-for-next-release.sh +++ b/jetbrains/scripts/push-git-tag-for-next-release.sh @@ -51,25 +51,28 @@ if [ -z "$VERSION_INCREMENT" ]; then usage fi -# Check if the current branch is 'main' -CURRENT_BRANCH=$(git symbolic-ref --short HEAD) -if [ "$CURRENT_BRANCH" != "main" ]; then - echo "Warning: You are not on the 'main' branch. You are on '$CURRENT_BRANCH'." - # shellcheck disable=SC2162 - read -p "Are you sure you want to proceed? (y/N): " proceed - if [ "$proceed" != "y" ]; then - echo "Aborted." - exit 1 - fi -fi - # Fetch git tags so we can compute an accurate next version. echo Fetching git tags to compute next version... git fetch origin +refs/tags/jb-v*:refs/tags/jb-v* +MERGE_BASE=$(git merge-base HEAD origin/main) +echo "Your current commit:" +git show -s --format=oneline HEAD +echo "Your branch base:" +git show -s --format=oneline "$MERGE_BASE" +echo "Other releases from this branch:" +git tag --list 'jb-v*' --contains "$MERGE_BASE" + +# shellcheck disable=SC2162 +read -p "Are you sure you want to proceed? (y/N): " proceed +if [ "$proceed" != "y" ]; then + echo "Aborted." + exit 1 +fi + SCRIPT_DIR="$(dirname "$0")" SCRIPT_DIR="$(readlink -f "$SCRIPT_DIR")" -NEXT_VERSION="$(bash "$SCRIPT_DIR/next-release.sh" $VERSION_INCREMENT)" +NEXT_VERSION="$(bash "$SCRIPT_DIR/next-release.sh" $VERSION_INCREMENT "$MERGE_BASE")" # Check the argument and take appropriate action if [ "$VERSION_INCREMENT" == "--major" ]; then From 42703aa94a3eeeb8478ad2ad70168d149311e4e6 Mon Sep 17 00:00:00 2001 From: Dominic Cooney Date: Thu, 30 Jan 2025 17:21:57 +0900 Subject: [PATCH 7/7] Smarter branch analysis. --- jetbrains/scripts/next-release.sh | 4 ++-- jetbrains/scripts/push-git-tag-for-next-release.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jetbrains/scripts/next-release.sh b/jetbrains/scripts/next-release.sh index 42e36e75dd99..5ce16ca51f3a 100755 --- a/jetbrains/scripts/next-release.sh +++ b/jetbrains/scripts/next-release.sh @@ -6,13 +6,13 @@ set -eu # Check the number of arguments if [ "$#" -ne 2 ]; then - echo "Usage: $0 < --major|--minor|--patch > " + echo "Usage: $0 --major|--minor|--patch " exit 1 fi MERGE_BASE="$2" -LAST_MAJOR_MINOR_ZERO_RELEASE=$(git tag -l 'jb-v*' --contains "$MERGE_BASE" | sort -V | tail -1 | sed 's/-nightly//' | sed 's/-experimental//') +LAST_MAJOR_MINOR_ZERO_RELEASE=$(git rev-list "$MERGE_BASE~1"..HEAD | xargs -I{} git tag -l --points-at {} jb-v* | sort -V | tail -1 | sed 's/-nightly//' | sed 's/-experimental//') if [ -z "$LAST_MAJOR_MINOR_ZERO_RELEASE" ]; then # This is a new release branch. diff --git a/jetbrains/scripts/push-git-tag-for-next-release.sh b/jetbrains/scripts/push-git-tag-for-next-release.sh index 0dd2ad5c066b..c2e06526e7cc 100755 --- a/jetbrains/scripts/push-git-tag-for-next-release.sh +++ b/jetbrains/scripts/push-git-tag-for-next-release.sh @@ -61,7 +61,7 @@ git show -s --format=oneline HEAD echo "Your branch base:" git show -s --format=oneline "$MERGE_BASE" echo "Other releases from this branch:" -git tag --list 'jb-v*' --contains "$MERGE_BASE" +git rev-list "$MERGE_BASE~1"..HEAD | xargs -I{} git tag -l --points-at {} jb-v* # shellcheck disable=SC2162 read -p "Are you sure you want to proceed? (y/N): " proceed