diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dab6b158c2..47a9426881 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,9 +79,30 @@ jobs: clean: false submodules: 'recursive' - - name: Validate version + - name: Determine version and release channel if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: script/validate-version + 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";; + *) + echo "can't publish a release on channel ${channel}" + exit 1;; + esac + if [[ $GITHUB_REFNAME != $expected_tag_name ]]; then + echo "invalid release tag ${GITHUB_REFNAME}. expected ${expected_tag_name}" + exit 1 + fi - name: Create app bundle run: script/bundle @@ -94,10 +115,11 @@ jobs: path: target/release/Zed.dmg - uses: softprops/action-gh-release@v1 - name: Upload app bundle to release if release tag - if: ${{ startsWith(github.ref, 'refs/tags/v') }} + name: Upload app bundle to release + if: ${{ github.env.RELEASE_CHANNEL }} with: draft: true + prerelease: ${{ github.env.RELEASE_CHANNEL == 'preview' }} files: target/release/Zed.dmg overwrite: true body: "" diff --git a/.github/workflows/publish_collab_image.yml b/.github/workflows/publish_collab_image.yml index 4c62859454..3421409287 100644 --- a/.github/workflows/publish_collab_image.yml +++ b/.github/workflows/publish_collab_image.yml @@ -28,17 +28,16 @@ jobs: clean: false submodules: 'recursive' - - name: Check that tag version matches package version + - name: Determine version run: | set -eu - package_version=$(cargo metadata --no-deps --format-version=1 | jq --raw-output '.packages[] | select(.name == "collab") | .version') - tag_version=$(echo $GITHUB_REF_NAME | sed -e 's/collab-v//') - if [[ $tag_version != $package_version ]]; then - echo "collab package version $package_version does not match git tag version $tag_version" + version=$(script/get-crate-version collab) + if [[ $GITHUB_REF_NAME != "collab-v${version}" ]]; then + echo "release tag ${GITHUB_REF_NAME} does not match version ${version}" exit 1 fi - echo "Publishing image version: $package_version" - echo "COLLAB_VERSION=$package_version" >> $GITHUB_ENV + echo "Publishing collab version: ${version}" + echo "COLLAB_VERSION=${version}" >> $GITHUB_ENV - name: Build docker image run: docker build . --tag registry.digitalocean.com/zed/collab:v${COLLAB_VERSION} diff --git a/Cargo.lock b/Cargo.lock index 96fc7b0055..f52d445f65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -959,6 +959,7 @@ dependencies = [ "rand 0.8.5", "rpc", "serde", + "settings", "smol", "sum_tree", "tempfile", diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rs index efe36ccab8..83dce7c9fe 100644 --- a/crates/auto_update/src/auto_update.rs +++ b/crates/auto_update/src/auto_update.rs @@ -1,13 +1,14 @@ mod update_notification; use anyhow::{anyhow, Context, Result}; -use client::{http::HttpClient, ZED_SECRET_CLIENT_TOKEN}; +use client::{http::HttpClient, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL}; use gpui::{ actions, platform::AppVersion, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task, WeakViewHandle, }; use lazy_static::lazy_static; use serde::Deserialize; +use settings::ReleaseChannel; use smol::{fs::File, io::AsyncReadExt, process::Command}; use std::{env, ffi::OsString, path::PathBuf, sync::Arc, time::Duration}; use update_notification::UpdateNotification; @@ -54,13 +55,9 @@ impl Entity for AutoUpdater { type Event = (); } -pub fn init( - db: project::Db, - http_client: Arc, - server_url: String, - cx: &mut MutableAppContext, -) { +pub fn init(db: project::Db, http_client: Arc, cx: &mut MutableAppContext) { if let Some(version) = (*ZED_APP_VERSION).or_else(|| cx.platform().app_version().ok()) { + let server_url = ZED_SERVER_URL.to_string(); let auto_updater = cx.add_model(|cx| { let updater = AutoUpdater::new(version, db.clone(), http_client, server_url.clone()); updater.start_polling(cx).detach(); @@ -177,9 +174,19 @@ impl AutoUpdater { this.current_version, ) }); + + let preview_param = cx.read(|cx| { + if cx.has_global::() { + if *cx.global::() == ReleaseChannel::Preview { + return "&preview=1"; + } + } + "" + }); + let mut response = client .get( - &format!("{server_url}/api/releases/latest?token={ZED_SECRET_CLIENT_TOKEN}&asset=Zed.dmg"), + &format!("{server_url}/api/releases/latest?token={ZED_SECRET_CLIENT_TOKEN}&asset=Zed.dmg{preview_param}"), Default::default(), true, ) diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index c9c783c659..74533fbc3b 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -35,9 +35,11 @@ tiny_http = "0.8" uuid = { version = "1.1.2", features = ["v4"] } url = "2.2" serde = { version = "*", features = ["derive"] } +settings = { path = "../settings" } tempfile = "3" [dev-dependencies] collections = { path = "../collections", features = ["test-support"] } gpui = { path = "../gpui", features = ["test-support"] } rpc = { path = "../rpc", features = ["test-support"] } +settings = { path = "../settings", features = ["test-support"] } diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 8f6d4aa10d..c4a3167f83 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -30,6 +30,7 @@ use postage::watch; use rand::prelude::*; use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, RequestMessage}; use serde::Deserialize; +use settings::ReleaseChannel; use std::{ any::TypeId, collections::HashMap, @@ -931,8 +932,9 @@ impl Client { self.establish_websocket_connection(credentials, cx) } - async fn get_rpc_url(http: Arc) -> Result { - let url = format!("{}/rpc", *ZED_SERVER_URL); + async fn get_rpc_url(http: Arc, is_preview: bool) -> Result { + let preview_param = if is_preview { "?preview=1" } else { "" }; + let url = format!("{}/rpc{preview_param}", *ZED_SERVER_URL); let response = http.get(&url, Default::default(), false).await?; // Normally, ZED_SERVER_URL is set to the URL of zed.dev website. @@ -967,6 +969,14 @@ impl Client { credentials: &Credentials, cx: &AsyncAppContext, ) -> Task> { + let is_preview = cx.read(|cx| { + if cx.has_global::() { + *cx.global::() == ReleaseChannel::Preview + } else { + false + } + }); + let request = Request::builder() .header( "Authorization", @@ -976,7 +986,7 @@ impl Client { let http = self.http.clone(); cx.background().spawn(async move { - let mut rpc_url = Self::get_rpc_url(http).await?; + let mut rpc_url = Self::get_rpc_url(http, is_preview).await?; let rpc_host = rpc_url .host_str() .zip(rpc_url.port_or_known_default()) @@ -1130,7 +1140,7 @@ impl Client { // Use the collab server's admin API to retrieve the id // of the impersonated user. - let mut url = Self::get_rpc_url(http.clone()).await?; + let mut url = Self::get_rpc_url(http.clone(), false).await?; url.set_path("/user"); url.set_query(Some(&format!("github_login={login}"))); let request = Request::get(url.as_str()) diff --git a/crates/collab/k8s/environments/preview.sh b/crates/collab/k8s/environments/preview.sh new file mode 100644 index 0000000000..4d9dd849e9 --- /dev/null +++ b/crates/collab/k8s/environments/preview.sh @@ -0,0 +1,3 @@ +ZED_ENVIRONMENT=preview +RUST_LOG=info +INVITE_LINK_PREFIX=https://zed.dev/invites/ diff --git a/crates/collab/k8s/manifest.template.yml b/crates/collab/k8s/manifest.template.yml index a271ad8399..1f0fafb170 100644 --- a/crates/collab/k8s/manifest.template.yml +++ b/crates/collab/k8s/manifest.template.yml @@ -11,7 +11,7 @@ metadata: name: collab annotations: service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443" - service.beta.kubernetes.io/do-loadbalancer-certificate-id: "40879815-9a6b-4bbb-8207-8f2c7c0218f9" + service.beta.kubernetes.io/do-loadbalancer-certificate-id: "08d9d8ce-761f-4ab3-bc78-4923ab5b0e33" spec: type: LoadBalancer selector: diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index d8f8e8926a..bad35c3271 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -54,6 +54,14 @@ pub struct FeatureFlags { pub experimental_themes: bool, } +#[derive(Copy, Clone, PartialEq, Eq, Default)] +pub enum ReleaseChannel { + #[default] + Dev, + Preview, + Stable, +} + impl FeatureFlags { pub fn keymap_files(&self) -> Vec<&'static str> { vec![] diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 75f0a62e3e..1cb580cb7d 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -123,8 +123,20 @@ env_logger = "0.9" serde_json = { version = "1.0", features = ["preserve_order"] } unindent = "0.1.7" -[package.metadata.bundle] -icon = ["app-icon@2x.png", "app-icon.png"] +[package.metadata.bundle-dev] +icon = ["resources/app-icon-preview@2x.png", "resources/app-icon-preview.png"] +identifier = "dev.zed.Zed-Dev" +name = "Zed Dev" +osx_minimum_system_version = "10.15.7" + +[package.metadata.bundle-preview] +icon = ["resources/app-icon-preview@2x.png", "resources/app-icon-preview.png"] +identifier = "dev.zed.Zed-Preview" +name = "Zed Preview" +osx_minimum_system_version = "10.15.7" + +[package.metadata.bundle-stable] +icon = ["resources/app-icon@2x.png", "resources/app-icon.png"] identifier = "dev.zed.Zed" name = "Zed" osx_minimum_system_version = "10.15.7" diff --git a/crates/zed/RELEASE_CHANNEL b/crates/zed/RELEASE_CHANNEL new file mode 100644 index 0000000000..90012116c0 --- /dev/null +++ b/crates/zed/RELEASE_CHANNEL @@ -0,0 +1 @@ +dev \ No newline at end of file diff --git a/crates/zed/build.rs b/crates/zed/build.rs index 30ea4677bc..9caa7776db 100644 --- a/crates/zed/build.rs +++ b/crates/zed/build.rs @@ -3,11 +3,14 @@ use std::process::Command; fn main() { println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7"); - if let Ok(api_key) = std::env::var("ZED_MIXPANEL_TOKEN") { - println!("cargo:rustc-env=ZED_MIXPANEL_TOKEN={api_key}"); + if let Ok(value) = std::env::var("ZED_MIXPANEL_TOKEN") { + println!("cargo:rustc-env=ZED_MIXPANEL_TOKEN={value}"); } - if let Ok(api_key) = std::env::var("ZED_AMPLITUDE_API_KEY") { - println!("cargo:rustc-env=ZED_AMPLITUDE_API_KEY={api_key}"); + if let Ok(value) = std::env::var("ZED_AMPLITUDE_API_KEY") { + println!("cargo:rustc-env=ZED_AMPLITUDE_API_KEY={value}"); + } + if let Ok(value) = std::env::var("ZED_PREVIEW_CHANNEL") { + println!("cargo:rustc-env=ZED_PREVIEW_CHANNEL={value}"); } if std::env::var("ZED_BUNDLE").ok().as_deref() == Some("true") { diff --git a/crates/zed/resources/app-icon-preview.png b/crates/zed/resources/app-icon-preview.png new file mode 100644 index 0000000000..a33124e4a0 Binary files /dev/null and b/crates/zed/resources/app-icon-preview.png differ diff --git a/crates/zed/resources/app-icon-preview@2x.png b/crates/zed/resources/app-icon-preview@2x.png new file mode 100644 index 0000000000..42dbeec599 Binary files /dev/null and b/crates/zed/resources/app-icon-preview@2x.png differ diff --git a/crates/zed/app-icon.png b/crates/zed/resources/app-icon.png similarity index 100% rename from crates/zed/app-icon.png rename to crates/zed/resources/app-icon.png diff --git a/crates/zed/app-icon@2x.png b/crates/zed/resources/app-icon@2x.png similarity index 100% rename from crates/zed/app-icon@2x.png rename to crates/zed/resources/app-icon@2x.png diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index c85a894415..9d0f8b33e8 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -39,7 +39,7 @@ use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJson use theme::ThemeRegistry; use util::{ResultExt, TryFutureExt}; use workspace::{self, AppState, ItemHandle, NewFile, OpenPaths, Workspace}; -use zed::{self, build_window_options, initialize_workspace, languages, menus}; +use zed::{self, build_window_options, initialize_workspace, languages, menus, RELEASE_CHANNEL}; fn main() { let http = http::client(); @@ -97,6 +97,7 @@ fn main() { let (settings_file_content, keymap_file) = cx.background().block(config_files).unwrap(); + cx.set_global(*RELEASE_CHANNEL); cx.set_global(HomeDir(zed::paths::HOME.to_path_buf())); //Setup settings global before binding actions @@ -158,7 +159,7 @@ fn main() { initialize_workspace, default_item_factory, }); - auto_update::init(db, http, client::ZED_SERVER_URL.clone(), cx); + auto_update::init(db, http, cx); workspace::init(app_state.clone(), cx); journal::init(app_state.clone(), cx); theme_selector::init(app_state.clone(), cx); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index d343e213d9..6536d83ce6 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -13,6 +13,7 @@ use collab_ui::{CollabTitlebarItem, ToggleCollaborationMenu}; use collections::VecDeque; pub use editor; use editor::{Editor, MultiBuffer}; +use lazy_static::lazy_static; use gpui::{ actions, @@ -28,7 +29,7 @@ use project_panel::ProjectPanel; use search::{BufferSearchBar, ProjectSearchBar}; use serde::Deserialize; use serde_json::to_string_pretty; -use settings::{keymap_file_json_schema, settings_file_json_schema, Settings}; +use settings::{keymap_file_json_schema, settings_file_json_schema, ReleaseChannel, Settings}; use std::{env, path::Path, str, sync::Arc}; use util::ResultExt; pub use workspace; @@ -69,6 +70,17 @@ actions!( const MIN_FONT_SIZE: f32 = 6.0; +lazy_static! { + static ref RELEASE_CHANNEL_NAME: String = + env::var("ZED_RELEASE_CHANNEL").unwrap_or(include_str!("../RELEASE_CHANNEL").to_string()); + pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME.as_str() { + "dev" => ReleaseChannel::Dev, + "preview" => ReleaseChannel::Preview, + "stable" => ReleaseChannel::Preview, + _ => panic!("invalid release channel {}", *RELEASE_CHANNEL_NAME), + }; +} + pub fn init(app_state: &Arc, cx: &mut gpui::MutableAppContext) { cx.add_action(about); cx.add_global_action(|_: &Hide, cx: &mut gpui::MutableAppContext| { @@ -377,9 +389,15 @@ fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) { } fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext) { + let app_name = match *cx.global::() { + ReleaseChannel::Dev => "Zed Dev", + ReleaseChannel::Preview => "Zed Preview", + ReleaseChannel::Stable => "Zed", + }; + let version = env!("CARGO_PKG_VERSION"); cx.prompt( gpui::PromptLevel::Info, - &format!("Zed {}", env!("CARGO_PKG_VERSION")), + &format!("{app_name} {version}"), &["OK"], ); } diff --git a/script/bump-app-version b/script/bump-app-version index 88433b6c70..a628eb8a6c 100755 --- a/script/bump-app-version +++ b/script/bump-app-version @@ -1,3 +1,18 @@ #!/bin/bash -exec script/lib/bump-version.sh zed v $@ +channel=$(cat crates/zed/RELEASE_CHANNEL) + +tag_suffix="" +case $channel; in + stable) + ;; + preview) + tag_suffix="-pre" + ;; + *) + echo "do this on a release branch where RELEASE_CHANNEL is either 'preview' or 'stable'" >&2 + exit 1 + ;; +esac + +exec script/lib/bump-version.sh zed v $tag_suffix $@ diff --git a/script/bump-collab-version b/script/bump-collab-version index 35f333f76a..cc8bb91dbf 100755 --- a/script/bump-collab-version +++ b/script/bump-collab-version @@ -1,3 +1,3 @@ #!/bin/bash -exec script/lib/bump-version.sh collab collab-v $@ +exec script/lib/bump-version.sh collab collab-v '' $@ diff --git a/script/bundle b/script/bundle index e69413bf93..d22ac430c5 100755 --- a/script/bundle +++ b/script/bundle @@ -5,8 +5,7 @@ set -e export ZED_BUNDLE=true export MACOSX_DEPLOYMENT_TARGET=10.15.7 -echo "Installing cargo bundle" -cargo install cargo-bundle --version 0.5.0 +which cargo-bundle > /dev/null || cargo install cargo-bundle --version 0.5.0 rustup target add wasm32-wasi # Deal with versions of macOS that don't include libstdc++ headers @@ -22,23 +21,32 @@ echo "Compiling cli binary for x86_64-apple-darwin" cargo build --release --package cli --target x86_64-apple-darwin echo "Creating application bundle" -(cd crates/zed && cargo bundle --release --target x86_64-apple-darwin) +pushd crates/zed +channel=$(cat RELEASE_CHANNEL) +cp Cargo.toml Cargo.toml.backup +sed \ + -i .backup \ + "s/package.metadata.bundle-${channel}/package.metadata.bundle/" \ + Cargo.toml +app_path=$(cargo bundle --release --target x86_64-apple-darwin | xargs) +mv Cargo.toml.backup Cargo.toml +popd echo "Creating fat binaries" lipo \ -create \ target/{x86_64-apple-darwin,aarch64-apple-darwin}/release/Zed \ -output \ - target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/MacOS/zed + "${app_path}/Contents/MacOS/zed" lipo \ -create \ target/{x86_64-apple-darwin,aarch64-apple-darwin}/release/cli \ -output \ - target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/MacOS/cli + "${app_path}/Contents/MacOS/cli" echo "Copying WebRTC.framework into the frameworks folder" -mkdir target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/Frameworks -cp -R target/x86_64-apple-darwin/release/WebRTC.framework target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/Frameworks/ +mkdir "${app_path}/Contents/Frameworks" +cp -R target/x86_64-apple-darwin/release/WebRTC.framework "${app_path}/Contents/Frameworks/" if [[ -n $MACOS_CERTIFICATE && -n $MACOS_CERTIFICATE_PASSWORD && -n $APPLE_NOTARIZATION_USERNAME && -n $APPLE_NOTARIZATION_PASSWORD ]]; then echo "Signing bundle with Apple-issued certificate" @@ -49,12 +57,12 @@ if [[ -n $MACOS_CERTIFICATE && -n $MACOS_CERTIFICATE_PASSWORD && -n $APPLE_NOTAR security import /tmp/zed-certificate.p12 -k zed.keychain -P $MACOS_CERTIFICATE_PASSWORD -T /usr/bin/codesign rm /tmp/zed-certificate.p12 security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_CERTIFICATE_PASSWORD zed.keychain - /usr/bin/codesign --force --deep --timestamp --options runtime --sign "Zed Industries, Inc." target/x86_64-apple-darwin/release/bundle/osx/Zed.app -v + /usr/bin/codesign --force --deep --timestamp --options runtime --sign "Zed Industries, Inc." "${app_path}" -v security default-keychain -s login.keychain else echo "One or more of the following variables are missing: MACOS_CERTIFICATE, MACOS_CERTIFICATE_PASSWORD, APPLE_NOTARIZATION_USERNAME, APPLE_NOTARIZATION_PASSWORD" echo "Performing an ad-hoc signature, but this bundle should not be distributed" - codesign --force --deep --sign - target/x86_64-apple-darwin/release/bundle/osx/Zed.app -v + codesign --force --deep --sign - "${app_path}" -v fi echo "Creating DMG" diff --git a/script/get-crate-version b/script/get-crate-version new file mode 100755 index 0000000000..b6346b32ec --- /dev/null +++ b/script/get-crate-version @@ -0,0 +1,17 @@ +#!/bin/bash + +set -eu + +if [[ $# < 1 ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +CRATE_NAME=$1 + +cargo metadata \ + --no-deps \ + --format-version=1 \ + | jq \ + --raw-output \ + ".packages[] | select(.name == \"${CRATE_NAME}\") | .version" \ No newline at end of file diff --git a/script/lib/bump-version.sh b/script/lib/bump-version.sh index 205fc168ef..4b9a1985eb 100755 --- a/script/lib/bump-version.sh +++ b/script/lib/bump-version.sh @@ -2,14 +2,15 @@ set -eu -if [[ $# < 3 ]]; then +if [[ $# < 4 ]]; then echo "Missing version increment (major, minor, or patch)" >&2 exit 1 fi package=$1 tag_prefix=$2 -version_increment=$3 +tag_suffix=$3 +version_increment=$4 if [[ -n $(git status --short --untracked-files=no) ]]; then echo "Can't push a new version with uncommitted changes" @@ -20,20 +21,23 @@ which cargo-set-version > /dev/null || cargo install cargo-edit cargo set-version --package $package --bump $version_increment cargo check --quiet -new_version=$(cargo metadata --no-deps --format-version=1 | jq --raw-output ".packages[] | select(.name == \"${package}\") | .version") +new_version=$(script/get-crate-version $package) branch_name=$(git rev-parse --abbrev-ref HEAD) old_sha=$(git rev-parse HEAD) -tag_name=${tag_prefix}${new_version} +tag_name=${tag_prefix}${new_version}${tag_suffix} git commit --quiet --all --message "${package} ${new_version}" git tag ${tag_name} cat < /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 roll the railcars with uncommitted changes" + exit 1 +fi +if [[ $(git rev-parse --abbrev-ref HEAD) != "main" ]]; then + echo "Run this command on the main branch" + exit 1 +fi +git pull -q --ff-only origin main +git fetch --tags + +# Parse the current version +version=$(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" + +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 + +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 +old_prev_minor_sha=$(git rev-parse HEAD) +echo -n stable > crates/zed/RELEASE_CHANNEL +git commit -q --all --message "Stable ${prev_minor_branch_name}" +git tag ${stable_tag_name} + +echo "Creating new preview branch ${minor_branch_name}..." +git checkout -q -b ${minor_branch_name} +echo -n preview > crates/zed/RELEASE_CHANNEL +git commit -q --all --message "Preview ${minor_branch_name}" +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 +git commit -q --all --message "Dev ${next_minor_branch_name}" + +cat < vendor/bin/jq - chmod +x vendor/bin/jq -fi - -package_version="v$(cargo metadata --format-version=1 | vendor/bin/jq --raw-output '.packages[] | select(.name == "zed") | .version')" -git_tag=$(git tag --points-at HEAD) - -if [[ $package_version != $git_tag ]]; then - echo "Version $package_version of zed package does not match git tag $git_tag" - exit 1 -fi \ No newline at end of file