diff --git a/.github/workflows/app-release.yml b/.github/workflows/app-release.yml index f3ffa550c..6182f9cac 100644 --- a/.github/workflows/app-release.yml +++ b/.github/workflows/app-release.yml @@ -78,14 +78,13 @@ jobs: if: startsWith(matrix.platform, 'ubuntu') run: | sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev sqlite3 - name: Install frontend dependencies run: pnpm install - name: build app (macos) - uses: tauri-apps/tauri-action@v0 - id: build_os_mac + run: pnpm --filter=@modrinth/app run tauri build --target universal-apple-darwin --config "tauri-release.conf.json" if: startsWith(matrix.platform, 'macos') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -96,34 +95,37 @@ jobs: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - with: - args: "--target universal-apple-darwin --config ./apps/app/tauri-release.conf.json" - tauriScript: pnpm --filter=@modrinth/app run tauri + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - name: build app - uses: tauri-apps/tauri-action@v0 + run: pnpm --filter=@modrinth/app run tauri build --config "tauri-release.conf.json" id: build_os if: "!startsWith(matrix.platform, 'macos')" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - with: - tauriScript: pnpm --filter=@modrinth/app run tauri - args: "--config ./apps/app/tauri-release.conf.json" + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - name: upload ${{ matrix.platform }} uses: actions/upload-artifact@v4 - if: startsWith(matrix.platform, 'macos') with: name: ${{ matrix.platform }} - path: "${{ join(fromJSON(steps.build_os_mac.outputs.artifactPaths), '\n') }}" + path: | + target/*/release/bundle/*/*.dmg + target/*/release/bundle/*/*.app.tar.gz + target/*/release/bundle/*/*.app.tar.gz.sig + target/release/bundle/*/*.dmg + target/release/bundle/*/*.app.tar.gz + target/release/bundle/*/*.app.tar.gz.sig + + target/release/bundle/*/*.AppImage + target/release/bundle/*/*.AppImage.tar.gz + target/release/bundle/*/*.AppImage.tar.gz.sig + target/release/bundle/*/*.deb + target/release/bundle/*/*.rpm + + target/release/bundle/*/*.msi + target/release/bundle/*/*.msi.zip + target/release/bundle/*/*.msi.zip.sig - - name: upload ${{ matrix.platform }} - uses: actions/upload-artifact@v4 - if: "!startsWith(matrix.platform, 'macos')" - with: - name: ${{ matrix.platform }} - path: "${{ join(fromJSON(steps.build_os.outputs.artifactPaths), '\n') }}" diff --git a/apps/app/Info.plist b/apps/app/Info.plist index 49ab096f4..2e875fe1f 100644 --- a/apps/app/Info.plist +++ b/apps/app/Info.plist @@ -6,63 +6,17 @@ CFBundleURLName - ModrinthApp CFBundleURLSchemes - modrinth + modrinthscheme - - CFBundleDocumentTypes - - - CFBundleTypeName - Modrinth type - CFBundleTypeRole - Editor - LSHandlerRank - Owner - LSItemContentTypes - - com.modrinth.theseus-type - - NSDocumentClass - NSDocument - - - UTImportedTypeDeclarations - - - UTTypeConformsTo - - public.data - - UTTypeDescription - Modrinth File - UTTypeIcons - - UTTypeIdentifier - com.modrinth.theseus-type - UTTypeTagSpecification - - public.filename-extension - - mrpack - - public.mime-type - - application/x-mrpack - - - - - NSCameraUsageDescription - A Minecraft mod wants to access your camera. - NSMicrophoneUsageDescription - A Minecraft mod wants to access your microphone. - + NSCameraUsageDescription + A Minecraft mod wants to access your camera. + NSMicrophoneUsageDescription + A Minecraft mod wants to access your microphone. diff --git a/apps/app/src/api/utils.rs b/apps/app/src/api/utils.rs index 831e90d41..391ea50f4 100644 --- a/apps/app/src/api/utils.rs +++ b/apps/app/src/api/utils.rs @@ -137,5 +137,6 @@ pub async fn get_opening_command() -> Result> { // helper function called when redirected by a weblink (ie: modrith://do-something) or when redirected by a .mrpack file (in which case its a filepath) // We hijack the deep link library (which also contains functionality for instance-checking) pub async fn handle_command(command: String) -> Result<()> { + tracing::info!("handle command: {command}"); Ok(theseus::handler::parse_and_emit_command(&command).await?) } diff --git a/apps/app/src/macos/deep_link.rs b/apps/app/src/macos/deep_link.rs index 5383312f1..e2c66ac15 100644 --- a/apps/app/src/macos/deep_link.rs +++ b/apps/app/src/macos/deep_link.rs @@ -1,6 +1,28 @@ use std::sync::Arc; +use tauri::{Manager, Runtime}; use tokio::sync::Mutex; +#[derive(Debug, Clone)] pub struct InitialPayload { pub payload: Arc>>, } + +pub fn get_or_init_payload>( + manager: &M, +) -> InitialPayload { + let initial_payload = manager.try_state::(); + let mtx = if let Some(initial_payload) = initial_payload { + initial_payload.inner().clone() + } else { + tracing::info!("No initial payload found, creating new"); + let payload = InitialPayload { + payload: Arc::new(Mutex::new(None)), + }; + + manager.manage(payload.clone()); + + payload + }; + + mtx +} diff --git a/apps/app/src/main.rs b/apps/app/src/main.rs index 33cee3cbe..fa1e4663f 100644 --- a/apps/app/src/main.rs +++ b/apps/app/src/main.rs @@ -114,27 +114,29 @@ fn main() { .setup(|app| { #[cfg(target_os = "macos")] { - use macos::deep_link::InitialPayload; - let mtx = std::sync::Arc::new(tokio::sync::Mutex::new(None)); + let payload = macos::deep_link::get_or_init_payload(app); - app.manage(InitialPayload { - payload: mtx.clone(), - }); - - let mtx_copy = mtx.clone(); + let mtx_copy = payload.payload.clone(); app.listen("deep-link://new-url", move |url| { let mtx_copy_copy = mtx_copy.clone(); let request = url.payload().to_owned(); + let actual_request = + serde_json::from_str::>(&request) + .ok() + .map(|mut x| x.remove(0)) + .unwrap_or(request); + tauri::async_runtime::spawn(async move { - tracing::info!("Handling deep link {request}"); + tracing::info!("Handling deep link {actual_request}"); let mut payload = mtx_copy_copy.lock().await; if payload.is_none() { - *payload = Some(request.clone()); + *payload = Some(actual_request.clone()); } - let _ = api::utils::handle_command(request).await; + let _ = + api::utils::handle_command(actual_request).await; }); }); }; @@ -206,11 +208,11 @@ fn main() { .next(); if let Some(file) = file { - use macos::deep_link::InitialPayload; - let initial_payload = app.state::(); - let request = file.to_string_lossy().to_string(); + let payload = + macos::deep_link::get_or_init_payload(app); - let mtx_copy = initial_payload.payload.clone(); + let mtx_copy = payload.payload.clone(); + let request = file.to_string_lossy().to_string(); tauri::async_runtime::spawn(async move { let mut payload = mtx_copy.lock().await; if payload.is_none() { diff --git a/apps/app/tauri.conf.json b/apps/app/tauri.conf.json index fb9aa25a6..b48c7d3c5 100644 --- a/apps/app/tauri.conf.json +++ b/apps/app/tauri.conf.json @@ -39,7 +39,13 @@ "deb": { "depends": [] } - } + }, + "fileAssociations": [ + { + "ext": ["mrpack"], + "mimeType": "application/zip+mrpack" + } + ] }, "productName": "Modrinth App", "version": "0.8.3-1",