auto_updater: Fix upload-nightly.ps1 and auto-update check (#43404)
Release Notes: - N/A
This commit is contained in:
@@ -637,7 +637,10 @@ impl AutoUpdater {
|
||||
if let AutoUpdateStatus::Updated { version, .. } = status {
|
||||
match version {
|
||||
VersionCheckType::Sha(cached_version) => {
|
||||
let should_download = fetched_version != cached_version.full();
|
||||
let should_download = parsed_fetched_version
|
||||
.as_ref()
|
||||
.ok()
|
||||
.is_none_or(|version| version.build.as_str() != cached_version.full());
|
||||
let newer_version = should_download
|
||||
.then(|| VersionCheckType::Sha(AppCommitSha::new(fetched_version)));
|
||||
return Ok(newer_version);
|
||||
@@ -656,7 +659,12 @@ impl AutoUpdater {
|
||||
let should_download = app_commit_sha
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|sha| fetched_version != sha)
|
||||
.map(|sha| {
|
||||
parsed_fetched_version
|
||||
.as_ref()
|
||||
.ok()
|
||||
.is_none_or(|version| version.build.as_str() != sha)
|
||||
})
|
||||
.unwrap_or(true);
|
||||
let newer_version = should_download
|
||||
.then(|| VersionCheckType::Sha(AppCommitSha::new(fetched_version)));
|
||||
@@ -1209,9 +1217,10 @@ 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 = semver::Version::new(1, 0, 0);
|
||||
let mut installed_version = semver::Version::new(1, 0, 0);
|
||||
installed_version.build = semver::BuildMetadata::new("a").unwrap();
|
||||
let status = AutoUpdateStatus::Idle;
|
||||
let fetched_sha = "a".to_string();
|
||||
let fetched_sha = "1.0.0+a".to_string();
|
||||
|
||||
let newer_version = AutoUpdater::check_if_fetched_version_is_newer(
|
||||
release_channel,
|
||||
@@ -1247,14 +1256,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nightly_does_not_update_when_fetched_sha_is_same_as_cached() {
|
||||
fn test_nightly_does_not_update_when_fetched_version_is_same_as_cached() {
|
||||
let release_channel = ReleaseChannel::Nightly;
|
||||
let app_commit_sha = Ok(Some("a".to_string()));
|
||||
let installed_version = semver::Version::new(1, 0, 0);
|
||||
let mut installed_version = semver::Version::new(1, 0, 0);
|
||||
installed_version.build = semver::BuildMetadata::new("a").unwrap();
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Sha(AppCommitSha::new("b".to_string())),
|
||||
};
|
||||
let fetched_sha = "b".to_string();
|
||||
let fetched_sha = "1.0.0+b".to_string();
|
||||
|
||||
let newer_version = AutoUpdater::check_if_fetched_version_is_newer(
|
||||
release_channel,
|
||||
@@ -1271,11 +1281,12 @@ 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 = semver::Version::new(1, 0, 0);
|
||||
let mut installed_version = semver::Version::new(1, 0, 0);
|
||||
installed_version.build = semver::BuildMetadata::new("a").unwrap();
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Sha(AppCommitSha::new("b".to_string())),
|
||||
};
|
||||
let fetched_sha = "c".to_string();
|
||||
let fetched_sha = "1.0.0+c".to_string();
|
||||
|
||||
let newer_version = AutoUpdater::check_if_fetched_version_is_newer(
|
||||
release_channel,
|
||||
@@ -1322,7 +1333,7 @@ mod tests {
|
||||
let status = AutoUpdateStatus::Updated {
|
||||
version: VersionCheckType::Sha(AppCommitSha::new("b".to_string())),
|
||||
};
|
||||
let fetched_sha = "b".to_string();
|
||||
let fetched_sha = "1.0.0+b".to_string();
|
||||
|
||||
let newer_version = AutoUpdater::check_if_fetched_version_is_newer(
|
||||
release_channel,
|
||||
|
||||
@@ -12,10 +12,8 @@ ParseZedWorkspace
|
||||
Write-Host "Uploading nightly for target: $target"
|
||||
|
||||
$bucketName = "zed-nightly-host"
|
||||
|
||||
# Get current git SHA
|
||||
$sha = git rev-parse HEAD
|
||||
$sha | Out-File -FilePath "target/latest-sha" -NoNewline
|
||||
$releaseVersion = & "$PSScriptRoot\get-crate-version.ps1" zed
|
||||
$version = "$releaseVersion-$env:GITHUB_RUN_NUMBER+$env:GITHUB_SHA"
|
||||
|
||||
# TODO:
|
||||
# Upload remote server files
|
||||
@@ -26,7 +24,10 @@ $sha | Out-File -FilePath "target/latest-sha" -NoNewline
|
||||
# }
|
||||
|
||||
UploadToBlobStore -BucketName $bucketName -FileToUpload "target/Zed-$Architecture.exe" -BlobStoreKey "nightly/Zed-$Architecture.exe"
|
||||
UploadToBlobStore -BucketName $bucketName -FileToUpload "target/latest-sha" -BlobStoreKey "nightly/latest-sha-windows"
|
||||
UploadToBlobStore -BucketName $bucketName -FileToUpload "target/Zed-$Architecture.exe" -BlobStoreKey "$version/Zed-$Architecture.exe"
|
||||
|
||||
Remove-Item -Path "target/Zed-$Architecture.exe" -ErrorAction SilentlyContinue
|
||||
|
||||
$version | Out-File -FilePath "target/latest-sha" -NoNewline
|
||||
UploadToBlobStore -BucketName $bucketName -FileToUpload "target/latest-sha" -BlobStoreKey "nightly/latest-sha-windows"
|
||||
Remove-Item -Path "target/latest-sha" -ErrorAction SilentlyContinue
|
||||
|
||||
Reference in New Issue
Block a user