1use std::env;
2
3use lazy_static::lazy_static;
4use url::Url;
5
6lazy_static! {
7 pub static ref RELEASE_CHANNEL_NAME: String = if cfg!(debug_assertions) {
8 env::var("ZED_RELEASE_CHANNEL")
9 .unwrap_or_else(|_| include_str!("../../zed/RELEASE_CHANNEL").to_string())
10 } else {
11 include_str!("../../zed/RELEASE_CHANNEL").to_string()
12 };
13 pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME.as_str() {
14 "dev" => ReleaseChannel::Dev,
15 "preview" => ReleaseChannel::Preview,
16 "stable" => ReleaseChannel::Stable,
17 _ => panic!("invalid release channel {}", *RELEASE_CHANNEL_NAME),
18 };
19
20 static ref URL_SCHEME: Url = Url::parse(match RELEASE_CHANNEL_NAME.as_str() {
21 "dev" => "zed-dev:/",
22 "preview" => "zed-preview:/",
23 "stable" => "zed:/",
24 // NOTE: this must be kept in sync with ./script/bundle and https://zed.dev.
25 _ => unreachable!(),
26 })
27 .unwrap();
28 static ref LINK_PREFIX: Url = Url::parse(match RELEASE_CHANNEL_NAME.as_str() {
29 "dev" => "http://localhost:3000/dev/",
30 "preview" => "https://zed.dev/preview/",
31 "stable" => "https://zed.dev/",
32 // NOTE: this must be kept in sync with https://zed.dev.
33 _ => unreachable!(),
34 })
35 .unwrap();
36}
37
38#[derive(Copy, Clone, PartialEq, Eq, Default)]
39pub enum ReleaseChannel {
40 #[default]
41 Dev,
42 Preview,
43 Stable,
44}
45
46impl ReleaseChannel {
47 pub fn display_name(&self) -> &'static str {
48 match self {
49 ReleaseChannel::Dev => "Zed Dev",
50 ReleaseChannel::Preview => "Zed Preview",
51 ReleaseChannel::Stable => "Zed",
52 }
53 }
54
55 pub fn dev_name(&self) -> &'static str {
56 match self {
57 ReleaseChannel::Dev => "dev",
58 ReleaseChannel::Preview => "preview",
59 ReleaseChannel::Stable => "stable",
60 }
61 }
62
63 pub fn url_scheme(&self) -> &'static Url {
64 &URL_SCHEME
65 }
66
67 pub fn link_prefix(&self) -> &'static Url {
68 &LINK_PREFIX
69 }
70}