Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/sprout-desktop-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
contents: write
env:
RELEASE_VERSION: '' # set in the "Extract version from tag" step
SPROUT_RELAY_URL: wss://sprout-oss.stage.blox.sqprod.co
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

Expand Down
9 changes: 6 additions & 3 deletions desktop/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@ and signature for the latest version.

The app connects to the relay via the `SPROUT_RELAY_URL` environment variable.

- **Release builds**: Set this to the production relay URL (e.g.
`wss://relay.sprout.example.com`). Configure it in the environment before
building, or set it in the CI workflow.
- **Production releases**: The GitHub release workflow currently builds the app
with `SPROUT_RELAY_URL=wss://sprout-oss.stage.blox.sqprod.co`, which is baked
into the release binary as its default relay URL.
- **Local release builds**: Export `SPROUT_RELAY_URL` before running
`just desktop-release-build` if you want a non-localhost relay URL compiled
into the app.
- **Development**: If not set, it defaults to `ws://localhost:3000`.

---
Expand Down
11 changes: 11 additions & 0 deletions desktop/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
fn main() {
println!("cargo:rerun-if-env-changed=SPROUT_RELAY_URL");
println!("cargo:rerun-if-env-changed=SPROUT_RELAY_HTTP");

if let Ok(relay_url) = std::env::var("SPROUT_RELAY_URL") {
println!("cargo:rustc-env=SPROUT_DESKTOP_BUILD_RELAY_URL={relay_url}");
}

if let Ok(relay_http) = std::env::var("SPROUT_RELAY_HTTP") {
println!("cargo:rustc-env=SPROUT_DESKTOP_BUILD_RELAY_HTTP={relay_http}");
}

tauri_build::build()
}
19 changes: 17 additions & 2 deletions desktop/src-tauri/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ use sha2::{Digest, Sha256};

use crate::app_state::AppState;

const DEFAULT_RELAY_WS_URL: &str = "ws://localhost:3000";

fn configured_env_var(name: &str) -> Option<String> {
std::env::var(name)
.ok()
.map(|value| value.trim().to_string())
.filter(|value| !value.is_empty())
}

pub fn relay_ws_url() -> String {
std::env::var("SPROUT_RELAY_URL").unwrap_or_else(|_| "ws://localhost:3000".to_string())
configured_env_var("SPROUT_RELAY_URL")
.or_else(|| option_env!("SPROUT_DESKTOP_BUILD_RELAY_URL").map(str::to_string))
.unwrap_or_else(|| DEFAULT_RELAY_WS_URL.to_string())
}

pub fn relay_http_base_url(relay_url: &str) -> String {
Expand All @@ -26,7 +37,11 @@ pub fn relay_http_base_url(relay_url: &str) -> String {
}

pub fn relay_api_base_url() -> String {
if let Ok(base) = std::env::var("SPROUT_RELAY_HTTP") {
if let Some(base) = configured_env_var("SPROUT_RELAY_HTTP") {
return base.trim_end_matches('/').to_string();
}

if let Some(base) = option_env!("SPROUT_DESKTOP_BUILD_RELAY_HTTP") {
return base.trim().trim_end_matches('/').to_string();
}

Expand Down
Loading