diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 440ad56..e1bba89 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,8 +3,6 @@ name: "Publish to Releases" on: workflow_dispatch: -# This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the release. - jobs: publish-tauri: permissions: @@ -25,7 +23,11 @@ jobs: runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - + - uses: actions/cache@v4 + with: + path: | + ~/.bun/install/cache + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} - name: setup node uses: actions/setup-node@v4 with: @@ -37,6 +39,11 @@ jobs: # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} + - name: Cache cargo deps and target folder + uses: Swatinem/rust-cache@v2 + with: + workspaces: "./src-tauri -> target" + - name: install dependencies (ubuntu only) if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. run: | diff --git a/package.json b/package.json index db0494d..2e32f08 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qsv-easy-installer", "private": true, - "version": "1.0.0", + "version": "1.1.1", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 889bf1e..c7b3fc0 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3058,7 +3058,7 @@ dependencies = [ [[package]] name = "qsv-easy-installer" -version = "0.1.0" +version = "1.0.0" dependencies = [ "reqwest", "serde", diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 352dcf2..a30a0c6 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,30 +1,35 @@ +use std::io::Write; + use tauri::Manager; use tempfile::tempfile; use winreg::{enums::HKEY_CURRENT_USER, RegKey}; #[tauri::command] -fn run_path_update(app_handle: tauri::AppHandle) { +async fn run_path_update(app_handle: tauri::AppHandle) { // Get app local data dir path let app_local_data_dir = app_handle.path().app_local_data_dir().unwrap(); // Download qsv to bin dir if it doesn't exist and overwrite any existing qsv // Get the version of qsv let latest_release_endpoint = "https://api.github.com/repos/dathere/qsv/releases/latest"; - let client = reqwest::blocking::Client::new(); + let client = reqwest::Client::new(); let res = client .get(latest_release_endpoint) .header(reqwest::header::USER_AGENT, "qsv easy installer") .send() + .await .unwrap() .json::() + .await .unwrap(); let release_version = res.get("name").unwrap().as_str().unwrap(); // Download the zip file temporarily then extract the relevant qsvp file (we use qsvp instead of qsv for the broadest compatibility) let zip_download_url = format!("https://github.com/dathere/qsv/releases/download/{release_version}/qsv-{release_version}-x86_64-pc-windows-msvc.zip"); let mut temp_zip_file = tempfile().unwrap(); - reqwest::blocking::get(zip_download_url) + let zip_bytes = reqwest::get(zip_download_url) + .await .unwrap() - .copy_to(&mut temp_zip_file) - .unwrap(); + .bytes().await.unwrap(); + temp_zip_file.write_all(&zip_bytes).unwrap(); let mut zip = zip::ZipArchive::new(temp_zip_file).unwrap(); let mut qsvp = zip.by_name("qsvp.exe").unwrap(); // Create a bin folder in app_local_data_dir if it doesn't exist @@ -35,6 +40,7 @@ fn run_path_update(app_handle: tauri::AppHandle) { // Write qsvp.exe to bin/qsv.exe let mut qsv_file = std::fs::File::create(bin_dir.join("qsv.exe")).unwrap(); std::io::copy(&mut qsvp, &mut qsv_file).unwrap(); + drop(qsv_file); // Add the bin dir to PATH let bin_dir_str = bin_dir.to_str().unwrap(); // Get the current PATH diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 159e668..fddfd65 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "qsv-easy-installer", - "version": "1.0.0", + "version": "../package.json", "identifier": "com.qsv-easy-installer.app", "build": { "beforeDevCommand": "bun run dev", diff --git a/src/App.tsx b/src/App.tsx index 4f1da8b..e37eca2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,9 +22,11 @@ function App() { disabled={loading} onClick={() => { setLoading(true); - invoke("run_path_update").finally(() => { - setLoading(false); - }); + invoke("run_path_update") + .finally(() => { + setLoading(false); + alert("Successfully installed qsv. Try opening a new terminal and run a qsv command!"); + }); }} className="mx-auto w-full flex justify-center bg-blue-400" > @@ -36,7 +38,7 @@ function App() { {loading && (

- Downloading and installing to PATH. This may take a few seconds... + Downloading and installing qsv to PATH. This may take a few seconds...

)}