diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dab6b158c2..088d1b4afb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,9 +79,22 @@ jobs: clean: false submodules: 'recursive' - - name: Validate version + - name: Check that tag version matches package version if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: script/validate-version + run: | + set -eu + crate_version=$(script/get-crate-version zed) + tag_version=$(echo $GITHUB_REF_NAME | sed -e 's/^v//' -e 's/-pre$//') + if [[ $tag_version != $crate_version ]]; then + echo "zed crate version $crate_version does not match git tag version $tag_version" + exit 1 + fi + echo "Publishing zed version: $crate_version" + + - name: Enable the preview channel + if: ${{ startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') }} + run: | + echo "ZED_PREVIEW_CHANNEL=1 >> $GITHUB_ENV - name: Create app bundle run: script/bundle @@ -98,6 +111,7 @@ jobs: if: ${{ startsWith(github.ref, 'refs/tags/v') }} with: draft: true + prerelease: ${{ endsWith(github.ref, '-pre') }} 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..d5e3dd7103 100644 --- a/.github/workflows/publish_collab_image.yml +++ b/.github/workflows/publish_collab_image.yml @@ -31,14 +31,14 @@ jobs: - name: Check that tag version matches package version run: | set -eu - package_version=$(cargo metadata --no-deps --format-version=1 | jq --raw-output '.packages[] | select(.name == "collab") | .version') + crate_version=$(script/get-crate-version collab) 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" + if [[ $tag_version != $crate_version ]]; then + echo "collab crate version $crate_version does not match git tag version $tag_version" exit 1 fi - echo "Publishing image version: $package_version" - echo "COLLAB_VERSION=$package_version" >> $GITHUB_ENV + echo "Publishing collab version: $crate_version" + echo "COLLAB_VERSION=$crate_version" >> $GITHUB_ENV - name: Build docker image run: docker build . --tag registry.digitalocean.com/zed/collab:v${COLLAB_VERSION} diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rs index efe36ccab8..fdbef5cbe4 100644 --- a/crates/auto_update/src/auto_update.rs +++ b/crates/auto_update/src/auto_update.rs @@ -1,7 +1,7 @@ mod update_notification; use anyhow::{anyhow, Context, Result}; -use client::{http::HttpClient, ZED_SECRET_CLIENT_TOKEN}; +use client::{http::HttpClient, PREVIEW_CHANNEL, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL}; use gpui::{ actions, platform::AppVersion, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task, WeakViewHandle, @@ -54,13 +54,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 +173,12 @@ impl AutoUpdater { this.current_version, ) }); + + let preview_param = if *PREVIEW_CHANNEL { "&preview=1" } else { "" }; + 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/src/client.rs b/crates/client/src/client.rs index 8f6d4aa10d..1b6357fa38 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -50,6 +50,9 @@ pub use rpc::*; pub use user::*; lazy_static! { + pub static ref PREVIEW_CHANNEL: bool = std::env::var("ZED_PREVIEW_CHANNEL") + .map_or(false, |var| !var.is_empty()) + || option_env!("ZED_PREVIEW_CHANNEL").map_or(false, |var| !var.is_empty()); pub static ref ZED_SERVER_URL: String = std::env::var("ZED_SERVER_URL").unwrap_or_else(|_| "https://zed.dev".to_string()); pub static ref IMPERSONATE_LOGIN: Option = std::env::var("ZED_IMPERSONATE") @@ -988,6 +991,11 @@ impl Client { match rpc_url.scheme() { "https" => { rpc_url.set_scheme("wss").unwrap(); + rpc_url.set_query(if *PREVIEW_CHANNEL { + Some("preview=1") + } else { + None + }); let request = request.uri(rpc_url.as_str()).body(())?; let (stream, _) = async_tungstenite::async_tls::client_async_tls(request, stream).await?; 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/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/src/main.rs b/crates/zed/src/main.rs index c85a894415..442db83b65 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -158,7 +158,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/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/validate-version b/script/validate-version deleted file mode 100755 index 28102c5038..0000000000 --- a/script/validate-version +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -e - -mkdir -p vendor/bin -if [[ ! -f vendor/bin/jq ]]; then - curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 > 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