Skip to content

Commit 68ea205

Browse files
Merge pull request #127 from datum-cloud/fix/macos-auto-update
Fix macos auto update logic
2 parents 490668d + 990b6ee commit 68ea205

File tree

12 files changed

+132
-39
lines changed

12 files changed

+132
-39
lines changed

.github/workflows/bundle.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ jobs:
227227
exit 1
228228
fi
229229
230+
# DMG build leaves Datum.app under ui/dist; upload-artifact uses ui/dist/** and the release
231+
# step used artifacts/**/*, so every file inside the bundle (fonts, PNGs, CodeResources, …)
232+
# became a separate GitHub release asset. The DMG already contains the app.
233+
- name: Remove unpacked macOS .app from dist before artifact upload
234+
if: runner.os == 'macOS'
235+
run: rm -rf ui/dist/Datum.app
236+
230237
- name: Cleanup macOS Keychain
231238
if: runner.os == 'macOS' && always()
232239
run: |
@@ -368,7 +375,12 @@ jobs:
368375
Workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
369376
370377
Assets: Datum.dmg, Datum.AppImage, Datum-setup.exe (see SHA256 checksums below).
371-
files: artifacts/**/*
378+
# Do not use artifacts/**/* — that uploads every nested file from historical artifact layouts.
379+
files: |
380+
artifacts/aliases/*
381+
artifacts/**/ui/dist/*.dmg
382+
artifacts/**/ui/dist/*.AppImage
383+
artifacts/**/ui/dist/*.exe
372384
generate_release_notes: false
373385

374386
update-homebrew:

.github/workflows/manual-release.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ jobs:
194194
exit 1
195195
fi
196196
197+
# See bundle.yml — avoid uploading Datum.app tree as hundreds of separate release assets.
198+
- name: Remove unpacked macOS .app from dist before artifact upload
199+
if: runner.os == 'macOS'
200+
run: rm -rf ui/dist/Datum.app
201+
197202
- name: Cleanup macOS Keychain
198203
if: runner.os == 'macOS' && always()
199204
run: |
@@ -269,7 +274,11 @@ jobs:
269274
make_latest: false
270275
prerelease: ${{ steps.channel.outputs.prerelease == 'true' }}
271276
draft: false
272-
files: artifacts/**/*
277+
files: |
278+
artifacts/aliases/*
279+
artifacts/**/ui/dist/*.dmg
280+
artifacts/**/ui/dist/*.AppImage
281+
artifacts/**/ui/dist/*.exe
273282
274283
publish-docker:
275284
if: ${{ inputs.publish_docker }}

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dirs-next = "2"
1919
http-body-util = "0.1.3"
2020
snafu = "0.8.6"
2121
hex = "0.4.3"
22+
http = "1"
2223
hyper = "1"
2324
hyper-util = { version = "0.1.19", features = ["full"] }
2425
iroh = { version = "0.95", default-features = false }

lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ data-encoding.workspace = true
1111
derive_more.workspace = true
1212
dirs-next.workspace = true
1313
hex.workspace = true
14+
http.workspace = true
1415
http-body-util.workspace = true
1516
hyper.workspace = true
1617
hyper-util.workspace = true

lib/src/datum_cloud.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use tokio::sync::watch;
99
use tracing::warn;
1010

1111
use crate::datum_apis::user_invitation::RoleReference;
12+
use crate::http_user_agent::datum_http_user_agent;
1213
use crate::{ProjectControlPlaneClient, Repo, SelectedContext};
1314

1415
pub use self::{
@@ -32,7 +33,10 @@ impl DatumCloudClient {
3233
pub async fn with_repo(env: ApiEnv, repo: Repo) -> Result<Self> {
3334
let auth = AuthClient::with_repo(env, repo.clone()).await?;
3435
let session = SessionStateWrapper::from_repo(Some(repo)).await?;
35-
let http = reqwest::Client::builder().build().anyerr()?;
36+
let http = reqwest::Client::builder()
37+
.user_agent(datum_http_user_agent())
38+
.build()
39+
.anyerr()?;
3640
let mut client = Self {
3741
env,
3842
auth,
@@ -47,7 +51,10 @@ impl DatumCloudClient {
4751
pub async fn new(env: ApiEnv) -> Result<Self> {
4852
let auth = AuthClient::new(env).await?;
4953
let session = SessionStateWrapper::empty();
50-
let http = reqwest::Client::builder().build().anyerr()?;
54+
let http = reqwest::Client::builder()
55+
.user_agent(datum_http_user_agent())
56+
.build()
57+
.anyerr()?;
5158
let mut client = Self {
5259
env,
5360
auth,

lib/src/datum_cloud/auth.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use tokio_util::sync::CancellationToken;
2222
use tracing::{debug, error, info, warn};
2323

2424
use crate::Repo;
25+
use crate::http_user_agent::datum_http_user_agent;
2526

2627
use self::{redirect_server::RedirectServer, types::OidcTokenResponse};
2728
use super::ApiEnv;
@@ -142,6 +143,7 @@ impl StatelessClient {
142143
let http = reqwest::ClientBuilder::new()
143144
// Following redirects opens the client up to SSRF vulnerabilities.
144145
.redirect(reqwest::redirect::Policy::none())
146+
.user_agent(datum_http_user_agent())
145147
.build()
146148
.expect("Client should build");
147149

lib/src/http_user_agent.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Shared [`User-Agent`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent) for
2+
//! outbound HTTP from Datum Desktop (reqwest and kube). Helps backend logs and support correlate
3+
//! traffic with app builds.
4+
//!
5+
//! The version is [`env!("CARGO_PKG_VERSION")`] for this crate; keep `lib`’s version aligned with
6+
//! the shipped desktop app when cutting releases.
7+
8+
/// Product token plus version, OS, and CPU arch for support and debugging.
9+
pub fn datum_http_user_agent() -> String {
10+
format!(
11+
"Datum Desktop/{} ({}; {})",
12+
env!("CARGO_PKG_VERSION"),
13+
std::env::consts::OS,
14+
std::env::consts::ARCH,
15+
)
16+
}

lib/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub mod datum_apis;
44
pub mod datum_cloud;
55
pub mod gateway;
66
pub mod heartbeat;
7+
mod http_user_agent;
78
mod node;
89
pub mod project_control_plane;
910
mod repo;
@@ -13,6 +14,7 @@ pub mod update;
1314

1415
pub use config::{Config, DiscoveryMode, GatewayConfig};
1516
pub use heartbeat::HeartbeatAgent;
17+
pub use http_user_agent::datum_http_user_agent;
1618
pub use node::*;
1719
pub use project_control_plane::ProjectControlPlaneClient;
1820
pub use repo::Repo;

lib/src/project_control_plane.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
use std::sync::Arc;
22

33
use arc_swap::ArcSwap;
4+
use http::HeaderValue;
5+
use http::header::USER_AGENT;
46
use kube::{Client, Config};
57
use n0_error::{Result, StdResultExt};
68
use n0_future::task::AbortOnDropHandle;
79
use secrecy::SecretString;
810
use tracing::warn;
911

1012
use crate::datum_cloud::{DatumCloudClient, LoginState};
13+
use crate::http_user_agent::datum_http_user_agent;
1114

1215
#[derive(derive_more::Debug, Clone)]
1316
pub struct ProjectControlPlaneClient {
@@ -70,6 +73,9 @@ impl ProjectControlPlaneClient {
7073
.std_context("Invalid project control plane URL")?;
7174
let mut config = Config::new(uri);
7275
config.auth_info.token = Some(SecretString::new(access_token.to_string().into_boxed_str()));
76+
let ua = HeaderValue::from_str(&datum_http_user_agent())
77+
.std_context("Invalid User-Agent for kube client")?;
78+
config.headers.push((USER_AGENT, ua));
7379
Client::try_from(config).std_context("Failed to create project control plane client")
7480
}
7581

0 commit comments

Comments
 (0)