Skip to content

Commit

Permalink
debug: Add versions to top level, install edge webview2 explicitly fo…
Browse files Browse the repository at this point in the history
…r windows
  • Loading branch information
Sindrir committed Dec 17, 2024
1 parent 4993c95 commit 3f1ff77
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 47 deletions.
62 changes: 35 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,31 +116,39 @@ jobs:
echo "'${{ github.ref_name }}' is not a valid version - using default. Must be a numerical only semver version."
fi
- name: Tauri build
uses: tauri-apps/tauri-action@v0
env:
VITE_SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }}
VITE_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }}
SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }}
SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }}
id: tauri_build

- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v3

# Upload to Artifactory
# Echo array of absolute paths to created artifacts.
# e.g. '["/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/deb/app.deb", "/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/appimage/app.appimage"]'
# sed directly after echo is to handle windows paths with backwards slashes
# e.g. C:\Users\user\actions-runner\_work\trokk\trokk\src-tauri\target\release\bundle\nsis\app.nsis
# jq is used to parse the array
# sed is used to remove the absolute path and only keep the relative path to the artifact
- name: Upload to Artifactory
shell: bash
working-directory: ./src-tauri/target/release/bundle
- name: Supply webview2
if: ${{ matrix.windows }}
shell: cmd
run: |
echo '${{ steps.tauri_build.outputs.artifactPaths }}' |
sed -e 's#\\#/#g' -e 's#//#/#g' |
jq -r .[] |
sed -n -e 's/^.*bundle\///p' |
xargs -I % jf rt u --url ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_URL }} --user ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_USER }} --password ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_PASSWORD }} % "generic/trokk/${{ github.ref_name }}/"
qgi curl -L -o Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/023aa9c1-c16d-4b52-a1dd-55f125aa3061/Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab"
C:\Windows\System32\expand.exe Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab -f:* ./src-tauri
del Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab

- name: Tauri build
uses: tauri-apps/tauri-action@v0
env:
VITE_SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }}
VITE_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }}
SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }}
SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }}
id: tauri_build

- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v3

# Upload to Artifactory
# Echo array of absolute paths to created artifacts.
# e.g. '["/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/deb/app.deb", "/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/appimage/app.appimage"]'
# sed directly after echo is to handle windows paths with backwards slashes
# e.g. C:\Users\user\actions-runner\_work\trokk\trokk\src-tauri\target\release\bundle\nsis\app.nsis
# jq is used to parse the array
# sed is used to remove the absolute path and only keep the relative path to the artifact
- name: Upload to Artifactory
shell: bash
working-directory: ./src-tauri/target/release/bundle
run: |
echo '${{ steps.tauri_build.outputs.artifactPaths }}' |
sed -e 's#\\#/#g' -e 's#//#/#g' |
jq -r .[] |
sed -n -e 's/^.*bundle\///p' |
xargs -I % jf rt u --url ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_URL }} --user ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_USER }} --password ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_PASSWORD }} % "generic/trokk/${{ github.ref_name }}/"
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "2.0.1", features = [] }

[dependencies]
tauri = { version = "2.0.2", features = ["protocol-asset", "test", "tray-icon"] }
tauri = { version = "2.0.2", features = ["protocol-asset", "test", "tray-icon", "devtools"] }
tauri-plugin-store = "2.1.0"
tauri-plugin-fs = { version = "2", features = ["watch"] }
tauri-plugin-oauth = "2"
Expand Down
9 changes: 7 additions & 2 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ async fn upload_directory_to_s3(
s3::upload_directory(directory_path, object_id, material_type, app_window).await
}

#[tauri::command]
fn get_webview_version() -> String {
tauri::webview_version().unwrap()
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::async_runtime::set(tokio::runtime::Handle::current());
Expand All @@ -179,7 +184,6 @@ pub fn run() {
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_oauth::init())
.setup(|app| {
#[cfg(debug_assertions)]
app.get_webview_window("main").unwrap().open_devtools();
{
let handle = app.handle();
Expand All @@ -197,7 +201,8 @@ pub fn run() {
delete_dir,
pick_directory,
get_papi_access_token,
upload_directory_to_s3
upload_directory_to_s3,
get_webview_version
])
.on_window_event(|window, event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"targets": "all",
"windows": {
"webviewInstallMode": {
"type": "offlineInstaller"
"type": "fixedRuntime",
"path": "./Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86/"
}
},
"shortDescription": "Filflytting og registrering fra skannermaskiner",
Expand Down
57 changes: 41 additions & 16 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { FolderOpen, User } from 'lucide-react';
import './App.css';
import { AuthContextType, AuthProvider, useAuth } from './context/auth-context.tsx';
Expand All @@ -10,6 +10,8 @@ import { UploadProgressProvider } from './context/upload-progress-context.tsx';
import Button from './components/ui/button.tsx';
import { SecretProvider } from './context/secret-context.tsx';
import { SettingProvider, useSettings } from './context/setting-context.tsx';
import { invoke } from '@tauri-apps/api/core';
import { getTauriVersion, getVersion } from '@tauri-apps/api/app';

function App() {
// TODO figure out what is making that "Unhandled Promise Rejection: window not found" error
Expand All @@ -20,23 +22,46 @@ function App() {
});

const [openSettings, setOpenSettings] = useState<boolean>(false);
const [webviewVersion, setWebviewVersion] = useState<string | null>(null);
const [trokkVersion, setTrokkVersion] = useState<string | null>(null);
const [tauriVersion, setTauriVersion] = useState<string | null>(null);

useEffect(() => {
const fetchWebviewVersion = async () => {
const webviewVersionFetched = await invoke<string>('get_webview_version');
const trokkVersionFetched = await getVersion();
const tauriVersion = await getTauriVersion();
setWebviewVersion(webviewVersionFetched);
setTrokkVersion(trokkVersionFetched);
setTauriVersion(tauriVersion);
};
void fetchWebviewVersion();
}, []);


return (
<SecretProvider>
<AuthProvider>
<SettingProvider>
<main className="flex flex-col">
<Content
openSettings={openSettings}
setOpenSettings={setOpenSettings}
/>
</main>
<Modal isOpen={openSettings} onClose={() => setOpenSettings(false)}>
<SettingsForm />
</Modal>
</SettingProvider>
</AuthProvider>
</SecretProvider>
<>
<div className={'flex justify-between'}>
<p>WebviewVersion: {webviewVersion}</p>
<p>Trøkk version: {trokkVersion}</p>
<p>Tauri version: {tauriVersion}</p>
</div>
<SecretProvider>
<AuthProvider>
<SettingProvider>
<main className="flex flex-col">
<Content
openSettings={openSettings}
setOpenSettings={setOpenSettings}
/>
</main>
<Modal isOpen={openSettings} onClose={() => setOpenSettings(false)}>
<SettingsForm />
</Modal>
</SettingProvider>
</AuthProvider>
</SecretProvider>
</>
);
}

Expand Down

0 comments on commit 3f1ff77

Please sign in to comment.