releases: Add build number to Nightly builds (#42990)
- **Remove semantic_version crate and use semver instead** - **Update upload-nightly** Release Notes: - N/A --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
co-authored by
Conrad Irwin
parent
a0fa5d57c1
commit
2d55c088cc
@@ -21,6 +21,7 @@ http_client.workspace = true
|
||||
log.workspace = true
|
||||
paths.workspace = true
|
||||
release_channel.workspace = true
|
||||
semver.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
settings.workspace = true
|
||||
|
||||
@@ -2,12 +2,13 @@ use anyhow::{Context as _, Result};
|
||||
use client::Client;
|
||||
use db::kvp::KEY_VALUE_STORE;
|
||||
use gpui::{
|
||||
App, AppContext as _, AsyncApp, BackgroundExecutor, Context, Entity, Global, SemanticVersion,
|
||||
Task, Window, actions,
|
||||
App, AppContext as _, AsyncApp, BackgroundExecutor, Context, Entity, Global, Task, Window,
|
||||
actions,
|
||||
};
|
||||
use http_client::{HttpClient, HttpClientWithUrl};
|
||||
use paths::remote_servers_dir;
|
||||
use release_channel::{AppCommitSha, ReleaseChannel};
|
||||
use semver::Version;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{RegisterSetting, Settings, SettingsStore};
|
||||
use smol::fs::File;
|
||||
@@ -44,7 +45,7 @@ actions!(
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum VersionCheckType {
|
||||
Sha(AppCommitSha),
|
||||
Semantic(SemanticVersion),
|
||||
Semantic(Version),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
@@ -100,7 +101,7 @@ impl AutoUpdateStatus {
|
||||
|
||||
pub struct AutoUpdater {
|
||||
status: AutoUpdateStatus,
|
||||
current_version: SemanticVersion,
|
||||
current_version: Version,
|
||||
client: Arc<Client>,
|
||||
pending_poll: Option<Task<Option<()>>>,
|
||||
quit_subscription: Option<gpui::Subscription>,
|
||||
@@ -256,7 +257,7 @@ pub fn view_release_notes(_: &ViewReleaseNotes, cx: &mut App) -> Option<()> {
|
||||
match release_channel {
|
||||
ReleaseChannel::Stable | ReleaseChannel::Preview => {
|
||||
let auto_updater = auto_updater.read(cx);
|
||||
let current_version = auto_updater.current_version;
|
||||
let current_version = auto_updater.current_version.clone();
|
||||
let release_channel = release_channel.dev_name();
|
||||
let path = format!("/releases/{release_channel}/{current_version}");
|
||||
let url = &auto_updater.client.http_client().build_url(&path);
|
||||
@@ -322,7 +323,7 @@ impl AutoUpdater {
|
||||
cx.default_global::<GlobalAutoUpdate>().0.clone()
|
||||
}
|
||||
|
||||
fn new(current_version: SemanticVersion, client: Arc<Client>, cx: &mut Context<Self>) -> Self {
|
||||
fn new(current_version: Version, client: Arc<Client>, cx: &mut Context<Self>) -> Self {
|
||||
// On windows, executable files cannot be overwritten while they are
|
||||
// running, so we must wait to overwrite the application until quitting
|
||||
// or restarting. When quitting the app, we spawn the auto update helper
|
||||
@@ -400,8 +401,8 @@ impl AutoUpdater {
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn current_version(&self) -> SemanticVersion {
|
||||
self.current_version
|
||||
pub fn current_version(&self) -> Version {
|
||||
self.current_version.clone()
|
||||
}
|
||||
|
||||
pub fn status(&self) -> AutoUpdateStatus {
|
||||
@@ -422,7 +423,7 @@ impl AutoUpdater {
|
||||
// Ok(None).
|
||||
pub async fn download_remote_server_release(
|
||||
release_channel: ReleaseChannel,
|
||||
version: Option<SemanticVersion>,
|
||||
version: Option<Version>,
|
||||
os: &str,
|
||||
arch: &str,
|
||||
set_status: impl Fn(&str, &mut AsyncApp) + Send + 'static,
|
||||
@@ -469,7 +470,7 @@ impl AutoUpdater {
|
||||
|
||||
pub async fn get_remote_server_release_url(
|
||||
channel: ReleaseChannel,
|
||||
version: Option<SemanticVersion>,
|
||||
version: Option<Version>,
|
||||
os: &str,
|
||||
arch: &str,
|
||||
cx: &mut AsyncApp,
|
||||
@@ -491,7 +492,7 @@ impl AutoUpdater {
|
||||
async fn get_release_asset(
|
||||
this: &Entity<Self>,
|
||||
release_channel: ReleaseChannel,
|
||||
version: Option<SemanticVersion>,
|
||||
version: Option<Version>,
|
||||
asset: &str,
|
||||
os: &str,
|
||||
arch: &str,
|
||||
@@ -554,7 +555,7 @@ impl AutoUpdater {
|
||||
this.read_with(cx, |this, cx| {
|
||||
(
|
||||
this.client.http_client(),
|
||||
this.current_version,
|
||||
this.current_version.clone(),
|
||||
this.status.clone(),
|
||||
ReleaseChannel::try_global(cx).unwrap_or(ReleaseChannel::Stable),
|
||||
)
|
||||
@@ -627,11 +628,11 @@ impl AutoUpdater {
|
||||
fn check_if_fetched_version_is_newer(
|
||||
release_channel: ReleaseChannel,
|
||||
app_commit_sha: Result<Option<String>>,
|
||||
installed_version: SemanticVersion,
|
||||
installed_version: Version,
|
||||
fetched_version: String,
|
||||
status: AutoUpdateStatus,
|
||||
) -> Result<Option<VersionCheckType>> {
|
||||
let parsed_fetched_version = fetched_version.parse::<SemanticVersion>();
|
||||
let parsed_fetched_version = fetched_version.parse::<Version>();
|
||||
|
||||
if let AutoUpdateStatus::Updated { version, .. } = status {
|
||||
match version {
|
||||
@@ -708,8 +709,8 @@ impl AutoUpdater {
|
||||
}
|
||||
|
||||
fn check_if_fetched_version_is_newer_non_nightly(
|
||||
installed_version: SemanticVersion,
|
||||
fetched_version: SemanticVersion,
|
||||
installed_version: Version,
|
||||
fetched_version: Version,
|
||||
) -> Result<Option<VersionCheckType>> {
|
||||
let should_download = fetched_version > installed_version;
|
||||
let newer_version = should_download.then(|| VersionCheckType::Semantic(fetched_version));
|
||||
@@ -1020,7 +1021,7 @@ mod tests {
|
||||
cx.update(|cx| {
|
||||
settings::init(cx);
|
||||
|
||||
let current_version = SemanticVersion::new(0, 100, 0);
|
||||
let current_version = semver::Version::new(0, 100, 0);
|
||||
release_channel::init_test(current_version, ReleaseChannel::Stable, cx);
|
||||
|
||||
let clock = Arc::new(FakeSystemClock::new());
|
||||
@@ -1059,7 +1060,7 @@ mod tests {
|
||||
|
||||
auto_updater.read_with(cx, |updater, _| {
|
||||
assert_eq!(updater.status(), AutoUpdateStatus::Idle);
|
||||
assert_eq!(updater.current_version(), SemanticVersion::new(0, 100, 0));
|
||||
assert_eq!(updater.current_version(), semver::Version::new(0, 100, 0));
|
||||
});
|
||||
|
||||
release_available.store(true, atomic::Ordering::SeqCst);
|
||||
@@ -1078,7 +1079,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
status,
|
||||
AutoUpdateStatus::Downloading {
|
||||
version: VersionCheckType::Semantic(SemanticVersion::new(0, 100, 1))
|
||||
version: VersionCheckType::Semantic(semver::Version::new(0, 100, 1))
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1108,7 +1109,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
status,
|
||||
AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Semantic(SemanticVersion::new(0, 100, 1))
|
||||
version: VersionCheckType::Semantic(semver::Version::new(0, 100, 1))
|
||||
}
|
||||
);
|
||||
let will_restart = cx.expect_restart();
|
||||
@@ -1122,9 +1123,9 @@ mod tests {
|
||||
fn test_stable_does_not_update_when_fetched_version_is_not_higher() {
|
||||
let release_channel = ReleaseChannel::Stable;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Idle;
|
||||
let fetched_version = SemanticVersion::new(1, 0, 0);
|
||||
let fetched_version = semver::Version::new(1, 0, 0);
|
||||
|
||||
let newer_version = AutoUpdater::check_if_fetched_version_is_newer(
|
||||
release_channel,
|
||||
@@ -1141,9 +1142,9 @@ mod tests {
|
||||
fn test_stable_does_update_when_fetched_version_is_higher() {
|
||||
let release_channel = ReleaseChannel::Stable;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Idle;
|
||||
let fetched_version = SemanticVersion::new(1, 0, 1);
|
||||
let fetched_version = semver::Version::new(1, 0, 1);
|
||||
|
||||
let newer_version = AutoUpdater::check_if_fetched_version_is_newer(
|
||||
release_channel,
|
||||
@@ -1163,11 +1164,11 @@ mod tests {
|
||||
fn test_stable_does_not_update_when_fetched_version_is_not_higher_than_cached() {
|
||||
let release_channel = ReleaseChannel::Stable;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Semantic(SemanticVersion::new(1, 0, 1)),
|
||||
version: VersionCheckType::Semantic(semver::Version::new(1, 0, 1)),
|
||||
};
|
||||
let fetched_version = SemanticVersion::new(1, 0, 1);
|
||||
let fetched_version = semver::Version::new(1, 0, 1);
|
||||
|
||||
let newer_version = AutoUpdater::check_if_fetched_version_is_newer(
|
||||
release_channel,
|
||||
@@ -1184,11 +1185,11 @@ mod tests {
|
||||
fn test_stable_does_update_when_fetched_version_is_higher_than_cached() {
|
||||
let release_channel = ReleaseChannel::Stable;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Semantic(SemanticVersion::new(1, 0, 1)),
|
||||
version: VersionCheckType::Semantic(semver::Version::new(1, 0, 1)),
|
||||
};
|
||||
let fetched_version = SemanticVersion::new(1, 0, 2);
|
||||
let fetched_version = semver::Version::new(1, 0, 2);
|
||||
|
||||
let newer_version = AutoUpdater::check_if_fetched_version_is_newer(
|
||||
release_channel,
|
||||
@@ -1208,7 +1209,7 @@ mod tests {
|
||||
fn test_nightly_does_not_update_when_fetched_sha_is_same() {
|
||||
let release_channel = ReleaseChannel::Nightly;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Idle;
|
||||
let fetched_sha = "a".to_string();
|
||||
|
||||
@@ -1227,7 +1228,7 @@ mod tests {
|
||||
fn test_nightly_does_update_when_fetched_sha_is_not_same() {
|
||||
let release_channel = ReleaseChannel::Nightly;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Idle;
|
||||
let fetched_sha = "b".to_string();
|
||||
|
||||
@@ -1249,7 +1250,7 @@ mod tests {
|
||||
fn test_nightly_does_not_update_when_fetched_sha_is_same_as_cached() {
|
||||
let release_channel = ReleaseChannel::Nightly;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Sha(AppCommitSha::new("b".to_string())),
|
||||
};
|
||||
@@ -1270,7 +1271,7 @@ mod tests {
|
||||
fn test_nightly_does_update_when_fetched_sha_is_not_same_as_cached() {
|
||||
let release_channel = ReleaseChannel::Nightly;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Sha(AppCommitSha::new("b".to_string())),
|
||||
};
|
||||
@@ -1294,7 +1295,7 @@ mod tests {
|
||||
fn test_nightly_does_update_when_installed_versions_sha_cannot_be_retrieved() {
|
||||
let release_channel = ReleaseChannel::Nightly;
|
||||
let app_commit_sha = Ok(None);
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Idle;
|
||||
let fetched_sha = "a".to_string();
|
||||
|
||||
@@ -1317,7 +1318,7 @@ mod tests {
|
||||
{
|
||||
let release_channel = ReleaseChannel::Nightly;
|
||||
let app_commit_sha = Ok(None);
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Sha(AppCommitSha::new("b".to_string())),
|
||||
};
|
||||
@@ -1339,7 +1340,7 @@ mod tests {
|
||||
{
|
||||
let release_channel = ReleaseChannel::Nightly;
|
||||
let app_commit_sha = Ok(None);
|
||||
let installed_version = SemanticVersion::new(1, 0, 0);
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Sha(AppCommitSha::new("b".to_string())),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user