From 09424edc3510b3b6004f93f7c7f3c5e173a4c5fa Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Mon, 30 Sep 2024 16:17:21 -0400 Subject: [PATCH] ci: Add script/determine-release-channel (#18476) - Refactor duplicated inline script from ci.yml to `script/determine-release-channel` - Remove references to non-existent '-nightly' release tags Release Notes: - N/A --- .github/workflows/ci.yml | 77 ++++---------------------------- script/bump-zed-patch-version | 5 +-- script/determine-release-channel | 32 +++++++++++++ 3 files changed, 42 insertions(+), 72 deletions(-) create mode 100755 script/determine-release-channel diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07e5499d5e..ca0d8bb910 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -192,29 +192,12 @@ jobs: - name: Determine version and release channel if: ${{ startsWith(github.ref, 'refs/tags/v') }} run: | - set -eu + # This exports RELEASE_CHANNEL into env (GITHUB_ENV) + script/determine-release-channel - version=$(script/get-crate-version zed) - channel=$(cat crates/zed/RELEASE_CHANNEL) - echo "Publishing version: ${version} on release channel ${channel}" - echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV - - expected_tag_name="" - case ${channel} in - stable) - expected_tag_name="v${version}";; - preview) - expected_tag_name="v${version}-pre";; - nightly) - expected_tag_name="v${version}-nightly";; - *) - echo "can't publish a release on channel ${channel}" - exit 1;; - esac - if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then - echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}" - exit 1 - fi + - name: Draft release notes + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | mkdir -p target/ # Ignore any errors that occur while drafting release notes to not fail the build. script/draft-release-notes "$version" "$channel" > target/release-notes.md || true @@ -289,29 +272,8 @@ jobs: - name: Determine version and release channel if: ${{ startsWith(github.ref, 'refs/tags/v') }} run: | - set -eu - - version=$(script/get-crate-version zed) - channel=$(cat crates/zed/RELEASE_CHANNEL) - echo "Publishing version: ${version} on release channel ${channel}" - echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV - - expected_tag_name="" - case ${channel} in - stable) - expected_tag_name="v${version}";; - preview) - expected_tag_name="v${version}-pre";; - nightly) - expected_tag_name="v${version}-nightly";; - *) - echo "can't publish a release on channel ${channel}" - exit 1;; - esac - if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then - echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}" - exit 1 - fi + # This exports RELEASE_CHANNEL into env (GITHUB_ENV) + script/determine-release-channel - name: Create Linux .tar.gz bundle run: script/bundle-linux @@ -357,29 +319,8 @@ jobs: - name: Determine version and release channel if: ${{ startsWith(github.ref, 'refs/tags/v') }} run: | - set -eu - - version=$(script/get-crate-version zed) - channel=$(cat crates/zed/RELEASE_CHANNEL) - echo "Publishing version: ${version} on release channel ${channel}" - echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV - - expected_tag_name="" - case ${channel} in - stable) - expected_tag_name="v${version}";; - preview) - expected_tag_name="v${version}-pre";; - nightly) - expected_tag_name="v${version}-nightly";; - *) - echo "can't publish a release on channel ${channel}" - exit 1;; - esac - if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then - echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}" - exit 1 - fi + # This exports RELEASE_CHANNEL into env (GITHUB_ENV) + script/determine-release-channel - name: Create and upload Linux .tar.gz bundle run: script/bundle-linux diff --git a/script/bump-zed-patch-version b/script/bump-zed-patch-version index e00e747aa3..b52feff72f 100755 --- a/script/bump-zed-patch-version +++ b/script/bump-zed-patch-version @@ -9,11 +9,8 @@ case $channel in preview) tag_suffix="-pre" ;; - nightly) - tag_suffix="-nightly" - ;; *) - echo "this must be run on either of stable|preview|nightly release branches" >&2 + echo "this must be run on either of stable|preview release branches" >&2 exit 1 ;; esac diff --git a/script/determine-release-channel b/script/determine-release-channel new file mode 100755 index 0000000000..ae49fbf1e5 --- /dev/null +++ b/script/determine-release-channel @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ -z "${GITHUB_ACTIONS-}" ]; then + echo "Error: This script must be run in a GitHub Actions environment" + exit 1 +elif [ -z "${GITHUB_REF-}" ]; then + # This should be the release tag 'v0.x.x' + echo "Error: GITHUB_REF is not set" + exit 1 +fi + +version=$(script/get-crate-version zed) +channel=$(cat crates/zed/RELEASE_CHANNEL) +echo "Publishing version: ${version} on release channel ${channel}" +echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV + +expected_tag_name="" +case ${channel} in +stable) + expected_tag_name="v${version}";; +preview) + expected_tag_name="v${version}-pre";; +*) + echo "can't publish a release on channel ${channel}" + exit 1;; +esac +if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then + echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}" + exit 1 +fi