Fix deep linking / file open on mac (#2314)
* Fix deep linking / file open on mac * Update deep linking * fix build * fix build again * update workdir * try again * update conf path * try old conf * use in house tauri * move away from tauri GH act * add rpm support * Fix updater key * Fix signing key pass * fix ubuntu deps * Fix macos artifacts
This commit is contained in:
parent
b06e7d3cf4
commit
38d95b4faf
46
.github/workflows/app-release.yml
vendored
46
.github/workflows/app-release.yml
vendored
@ -78,14 +78,13 @@ jobs:
|
|||||||
if: startsWith(matrix.platform, 'ubuntu')
|
if: startsWith(matrix.platform, 'ubuntu')
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
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
|
- name: Install frontend dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|
||||||
- name: build app (macos)
|
- name: build app (macos)
|
||||||
uses: tauri-apps/tauri-action@v0
|
run: pnpm --filter=@modrinth/app run tauri build --target universal-apple-darwin --config "tauri-release.conf.json"
|
||||||
id: build_os_mac
|
|
||||||
if: startsWith(matrix.platform, 'macos')
|
if: startsWith(matrix.platform, 'macos')
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@ -96,34 +95,37 @@ jobs:
|
|||||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_SIGNING_PRIVATE_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
|
|
||||||
|
|
||||||
- name: build app
|
- 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
|
id: build_os
|
||||||
if: "!startsWith(matrix.platform, 'macos')"
|
if: "!startsWith(matrix.platform, 'macos')"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
with:
|
|
||||||
tauriScript: pnpm --filter=@modrinth/app run tauri
|
|
||||||
args: "--config ./apps/app/tauri-release.conf.json"
|
|
||||||
|
|
||||||
- name: upload ${{ matrix.platform }}
|
- name: upload ${{ matrix.platform }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
if: startsWith(matrix.platform, 'macos')
|
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.platform }}
|
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') }}"
|
|
||||||
|
|||||||
@ -6,63 +6,17 @@
|
|||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleURLName</key>
|
<key>CFBundleURLName</key>
|
||||||
<!-- Obviously needs to be replaced with your app's bundle identifier -->
|
|
||||||
<string>ModrinthApp</string>
|
<string>ModrinthApp</string>
|
||||||
<key>CFBundleURLSchemes</key>
|
<key>CFBundleURLSchemes</key>
|
||||||
<array>
|
<array>
|
||||||
<!-- register the myapp:// and myscheme:// schemes -->
|
|
||||||
<string>modrinth</string>
|
<string>modrinth</string>
|
||||||
|
<string>modrinthscheme</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<!-- Declare file types your app can open -->
|
<key>NSCameraUsageDescription</key>
|
||||||
<key>CFBundleDocumentTypes</key>
|
<string>A Minecraft mod wants to access your camera.</string>
|
||||||
<array>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<dict>
|
<string>A Minecraft mod wants to access your microphone.</string>
|
||||||
<key>CFBundleTypeName</key>
|
|
||||||
<string>Modrinth type</string>
|
|
||||||
<key>CFBundleTypeRole</key>
|
|
||||||
<string>Editor</string>
|
|
||||||
<key>LSHandlerRank</key>
|
|
||||||
<string>Owner</string>
|
|
||||||
<key>LSItemContentTypes</key>
|
|
||||||
<array>
|
|
||||||
<string>com.modrinth.theseus-type</string>
|
|
||||||
</array>
|
|
||||||
<key>NSDocumentClass</key>
|
|
||||||
<string>NSDocument</string>
|
|
||||||
</dict>
|
|
||||||
</array>
|
|
||||||
<key>UTImportedTypeDeclarations</key>
|
|
||||||
<array>
|
|
||||||
<dict>
|
|
||||||
<key>UTTypeConformsTo</key>
|
|
||||||
<array>
|
|
||||||
<string>public.data</string>
|
|
||||||
</array>
|
|
||||||
<key>UTTypeDescription</key>
|
|
||||||
<string>Modrinth File</string>
|
|
||||||
<key>UTTypeIcons</key>
|
|
||||||
<dict/>
|
|
||||||
<key>UTTypeIdentifier</key>
|
|
||||||
<string>com.modrinth.theseus-type</string>
|
|
||||||
<key>UTTypeTagSpecification</key>
|
|
||||||
<dict>
|
|
||||||
<key>public.filename-extension</key>
|
|
||||||
<array>
|
|
||||||
<string>mrpack</string>
|
|
||||||
</array>
|
|
||||||
<key>public.mime-type</key>
|
|
||||||
<array>
|
|
||||||
<string>application/x-mrpack</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</array>
|
|
||||||
<key>NSCameraUsageDescription</key>
|
|
||||||
<string>A Minecraft mod wants to access your camera.</string>
|
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
|
||||||
<string>A Minecraft mod wants to access your microphone.</string>
|
|
||||||
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@ -137,5 +137,6 @@ pub async fn get_opening_command() -> Result<Option<CommandPayload>> {
|
|||||||
// 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)
|
// 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)
|
// We hijack the deep link library (which also contains functionality for instance-checking)
|
||||||
pub async fn handle_command(command: String) -> Result<()> {
|
pub async fn handle_command(command: String) -> Result<()> {
|
||||||
|
tracing::info!("handle command: {command}");
|
||||||
Ok(theseus::handler::parse_and_emit_command(&command).await?)
|
Ok(theseus::handler::parse_and_emit_command(&command).await?)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,28 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use tauri::{Manager, Runtime};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct InitialPayload {
|
pub struct InitialPayload {
|
||||||
pub payload: Arc<Mutex<Option<String>>>,
|
pub payload: Arc<Mutex<Option<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_or_init_payload<R: Runtime, M: Manager<R>>(
|
||||||
|
manager: &M,
|
||||||
|
) -> InitialPayload {
|
||||||
|
let initial_payload = manager.try_state::<InitialPayload>();
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|||||||
@ -114,27 +114,29 @@ fn main() {
|
|||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
use macos::deep_link::InitialPayload;
|
let payload = macos::deep_link::get_or_init_payload(app);
|
||||||
let mtx = std::sync::Arc::new(tokio::sync::Mutex::new(None));
|
|
||||||
|
|
||||||
app.manage(InitialPayload {
|
let mtx_copy = payload.payload.clone();
|
||||||
payload: mtx.clone(),
|
|
||||||
});
|
|
||||||
|
|
||||||
let mtx_copy = mtx.clone();
|
|
||||||
app.listen("deep-link://new-url", move |url| {
|
app.listen("deep-link://new-url", move |url| {
|
||||||
let mtx_copy_copy = mtx_copy.clone();
|
let mtx_copy_copy = mtx_copy.clone();
|
||||||
let request = url.payload().to_owned();
|
let request = url.payload().to_owned();
|
||||||
|
|
||||||
|
let actual_request =
|
||||||
|
serde_json::from_str::<Vec<String>>(&request)
|
||||||
|
.ok()
|
||||||
|
.map(|mut x| x.remove(0))
|
||||||
|
.unwrap_or(request);
|
||||||
|
|
||||||
tauri::async_runtime::spawn(async move {
|
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;
|
let mut payload = mtx_copy_copy.lock().await;
|
||||||
if payload.is_none() {
|
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();
|
.next();
|
||||||
|
|
||||||
if let Some(file) = file {
|
if let Some(file) = file {
|
||||||
use macos::deep_link::InitialPayload;
|
let payload =
|
||||||
let initial_payload = app.state::<InitialPayload>();
|
macos::deep_link::get_or_init_payload(app);
|
||||||
let request = file.to_string_lossy().to_string();
|
|
||||||
|
|
||||||
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 {
|
tauri::async_runtime::spawn(async move {
|
||||||
let mut payload = mtx_copy.lock().await;
|
let mut payload = mtx_copy.lock().await;
|
||||||
if payload.is_none() {
|
if payload.is_none() {
|
||||||
|
|||||||
@ -39,7 +39,13 @@
|
|||||||
"deb": {
|
"deb": {
|
||||||
"depends": []
|
"depends": []
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"fileAssociations": [
|
||||||
|
{
|
||||||
|
"ext": ["mrpack"],
|
||||||
|
"mimeType": "application/zip+mrpack"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"productName": "Modrinth App",
|
"productName": "Modrinth App",
|
||||||
"version": "0.8.3-1",
|
"version": "0.8.3-1",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user