From ca5bc328fcbbb82d795262034b8e5f5fea73fc00 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Fri, 18 Apr 2025 11:05:08 -0400 Subject: [PATCH 1/9] ci: add cache to CI/CD --- .github/workflows/publish.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 440ad56..f16eb55 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -37,6 +37,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: | From f776d7f29359a2667757b5ba940009347686b278 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 22 Apr 2025 10:45:50 -0400 Subject: [PATCH 2/9] feat: add alert, version info, and async run --- src-tauri/Cargo.lock | 2 +- src-tauri/src/lib.rs | 17 ++++++++++++----- src/App.tsx | 13 +++++++++---- 3 files changed, 22 insertions(+), 10 deletions(-) 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..8fd6ed7 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) -> String { // 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 @@ -46,6 +51,8 @@ fn run_path_update(app_handle: tauri::AppHandle) { let updated_path_var = format!("{bin_dir_str};{path_var}"); reg_key.set_value("Path", &updated_path_var).unwrap(); } + drop(qsv_file); + String::from_utf8(std::process::Command::new(bin_dir.join("qsv.exe")).arg("--version").output().unwrap().stdout).unwrap() } #[cfg_attr(mobile, tauri::mobile_entry_point)] diff --git a/src/App.tsx b/src/App.tsx index 4f1da8b..ce12373 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,9 +22,14 @@ function App() { disabled={loading} onClick={() => { setLoading(true); - invoke("run_path_update").finally(() => { - setLoading(false); - }); + invoke("run_path_update") + .then((message) => { + setLoading(false); + alert("Successfully installed qsv. Try opening a new terminal and run a qsv command! Version info: " + message); + }) + .finally(() => { + setLoading(false); + }); }} className="mx-auto w-full flex justify-center bg-blue-400" > @@ -36,7 +41,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...

)} From 1463a3675b710daeeb05e7e634594101c654466f Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 22 Apr 2025 10:46:25 -0400 Subject: [PATCH 3/9] chore: remove version info --- src-tauri/src/lib.rs | 5 ++--- src/App.tsx | 4 ---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 8fd6ed7..a30a0c6 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -5,7 +5,7 @@ use tempfile::tempfile; use winreg::{enums::HKEY_CURRENT_USER, RegKey}; #[tauri::command] -async fn run_path_update(app_handle: tauri::AppHandle) -> String { +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 @@ -40,6 +40,7 @@ async fn run_path_update(app_handle: tauri::AppHandle) -> String { // 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 @@ -51,8 +52,6 @@ async fn run_path_update(app_handle: tauri::AppHandle) -> String { let updated_path_var = format!("{bin_dir_str};{path_var}"); reg_key.set_value("Path", &updated_path_var).unwrap(); } - drop(qsv_file); - String::from_utf8(std::process::Command::new(bin_dir.join("qsv.exe")).arg("--version").output().unwrap().stdout).unwrap() } #[cfg_attr(mobile, tauri::mobile_entry_point)] diff --git a/src/App.tsx b/src/App.tsx index ce12373..fdba217 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -23,10 +23,6 @@ function App() { onClick={() => { setLoading(true); invoke("run_path_update") - .then((message) => { - setLoading(false); - alert("Successfully installed qsv. Try opening a new terminal and run a qsv command! Version info: " + message); - }) .finally(() => { setLoading(false); }); From d9543dd49bd24a42712f978b7c92ccf8fc76ee1e Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 22 Apr 2025 10:59:53 -0400 Subject: [PATCH 4/9] ci: add bun cache --- .github/workflows/publish.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f16eb55..ea73b8d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,7 +25,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: From 683534797b07600875f251824c6da0cba3a0dcf1 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 22 Apr 2025 11:11:51 -0400 Subject: [PATCH 5/9] build: specify version --- package.json | 2 +- src-tauri/tauri.conf.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index db0494d..b32784d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qsv-easy-installer", "private": true, - "version": "1.0.0", + "version": "1.1.0", "type": "module", "scripts": { "dev": "vite", 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", From 60f9e106f9a475038597b316f56064f77627837d Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 22 Apr 2025 11:12:22 -0400 Subject: [PATCH 6/9] ci: specify version --- .github/workflows/publish.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ea73b8d..f7778ef 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,9 +2,10 @@ 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. - + inputs: + version: + description: "Specify the version. Ensure that the version is in the format v0.0.0." + required: true jobs: publish-tauri: permissions: From c25b53c45ab2402c7c9293b28182555fc71ad3b4 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 22 Apr 2025 11:36:59 -0400 Subject: [PATCH 7/9] chore: add alert after install --- src/App.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/App.tsx b/src/App.tsx index fdba217..e37eca2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -25,6 +25,7 @@ function App() { 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" From 01629d5de4dee499820a65f2211ba31c97c76c4e Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 22 Apr 2025 11:44:42 -0400 Subject: [PATCH 8/9] build: update to v1.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b32784d..2e32f08 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qsv-easy-installer", "private": true, - "version": "1.1.0", + "version": "1.1.1", "type": "module", "scripts": { "dev": "vite", From b9d765195637ddb31ddf4cb2387c49762f882a14 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Tue, 22 Apr 2025 11:45:37 -0400 Subject: [PATCH 9/9] ci: remove unnecessary input --- .github/workflows/publish.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f7778ef..e1bba89 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,10 +2,7 @@ name: "Publish to Releases" on: workflow_dispatch: - inputs: - version: - description: "Specify the version. Ensure that the version is in the format v0.0.0." - required: true + jobs: publish-tauri: permissions: