From 6157eb75a19e9aa207fc2a723f92ae0a0c5b9740 Mon Sep 17 00:00:00 2001 From: PandaDEV <70103896+0PandaDEV@users.noreply.github.com> Date: Wed, 1 Jan 2025 18:26:37 +1000 Subject: [PATCH 1/3] feat: add 'Check for updates' option to tray menu and improve update handling --- assets/css/settings.scss | 20 ++++++++++---------- src-tauri/src/api/tray.rs | 8 ++++++++ src-tauri/src/api/updater.rs | 26 ++++++++++++++++++++++---- src-tauri/src/main.rs | 2 +- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/assets/css/settings.scss b/assets/css/settings.scss index c3ad9d4..c593334 100644 --- a/assets/css/settings.scss +++ b/assets/css/settings.scss @@ -1,10 +1,10 @@ -$primary: #2E2D2B; -$accent: #FEB453; +$primary: #2e2d2b; +$accent: #feb453; $divider: #ffffff0d; -$text: #E5DFD5; -$text2: #ADA9A1; -$mutedtext: #78756F; +$text: #e5dfd5; +$text2: #ada9a1; +$mutedtext: #78756f; .bg { width: 750px; @@ -25,7 +25,7 @@ $mutedtext: #78756F; gap: 8px; align-items: center; - img{ + img { background-color: $divider; border-radius: 6px; padding: 8px 6px; @@ -123,7 +123,7 @@ $mutedtext: #78756F; background-color: $divider; margin-left: 8px; margin-right: 4px; - transition: all .2s; + transition: all 0.2s; } .actions { @@ -134,7 +134,7 @@ $mutedtext: #78756F; gap: 8px; border-radius: 7px; background-color: transparent; - transition: all .2s; + transition: all 0.2s; cursor: pointer; } @@ -142,8 +142,8 @@ $mutedtext: #78756F; background-color: $divider; } - &:hover .actions:hover~.divider { + &:hover .actions:hover ~ .divider { opacity: 0; } } -} \ No newline at end of file +} diff --git a/src-tauri/src/api/tray.rs b/src-tauri/src/api/tray.rs index 8c3d9bc..72d24ec 100644 --- a/src-tauri/src/api/tray.rs +++ b/src-tauri/src/api/tray.rs @@ -23,6 +23,7 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box> { .build(app)?]) .items(&[&MenuItemBuilder::with_id("show", "Show/Hide").build(app)?]) .items(&[&MenuItemBuilder::with_id("keybind", "Change keybind").build(app)?]) + .items(&[&MenuItemBuilder::with_id("check_updates", "Check for updates").build(app)?]) .items(&[&MenuItemBuilder::with_id("quit", "Quit").build(app)?]) .build()?, ) @@ -48,6 +49,13 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box> { let _ = _app.track_event("tray_keybind_change", None); window.emit("change_keybind", ()).unwrap(); } + "check_updates" => { + let _ = _app.track_event("tray_check_updates", None); + let app_handle = _app.app_handle().clone(); + tauri::async_runtime::spawn(async move { + crate::api::updater::check_for_updates(app_handle, true).await; + }); + } _ => (), }) .icon(icon) diff --git a/src-tauri/src/api/updater.rs b/src-tauri/src/api/updater.rs index a5e16f9..8c600fa 100644 --- a/src-tauri/src/api/updater.rs +++ b/src-tauri/src/api/updater.rs @@ -1,8 +1,9 @@ +use tauri::Manager; use tauri::{async_runtime, AppHandle}; use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind}; use tauri_plugin_updater::UpdaterExt; -pub async fn check_for_updates(app: AppHandle) { +pub async fn check_for_updates(app: AppHandle, prompted: bool) { println!("Checking for updates..."); let updater = app.updater().unwrap(); @@ -18,6 +19,10 @@ pub async fn check_for_updates(app: AppHandle) { "Would you like to install it now?", ]); + let window = app.get_webview_window("main").unwrap(); + window.show().unwrap(); + window.set_focus().unwrap(); + app.dialog() .message(msg) .title("Qopy Update Available") @@ -31,7 +36,7 @@ pub async fn check_for_updates(app: AppHandle) { Ok(_) => { app.dialog() .message("Update installed successfully. The application needs to restart to apply the changes.") - .title("Qopy Update Installed") + .title("Qopy Needs to Restart") .buttons(MessageDialogButtons::OkCancelCustom(String::from("Restart"), String::from("Cancel"))) .show(move |response| { if response { @@ -50,9 +55,22 @@ pub async fn check_for_updates(app: AppHandle) { }); }); } - Ok(None) => println!("No updates available."), + Ok(None) => { + println!("No updates available."); + } Err(e) => { - println!("Failed to check for updates: {:?}", e); + if prompted { + let window = app.get_webview_window("main").unwrap(); + window.show().unwrap(); + window.set_focus().unwrap(); + + app.dialog() + .message("No updates available.") + .title("Qopy Update Check") + .show(|_| {}); + } + + println!("No updates available. {}", e.to_string()); } } } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 7f9fb79..0f2ae6a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -96,7 +96,7 @@ fn main() { let _ = app.track_event("app_started", None); tauri::async_runtime::spawn(async move { - api::updater::check_for_updates(app_handle).await; + api::updater::check_for_updates(app_handle, false).await; }); Ok(()) From 3552a3779b9427d77d87bab036eb8fa9acc4c6b3 Mon Sep 17 00:00:00 2001 From: PandaDEV <70103896+0PandaDEV@users.noreply.github.com> Date: Wed, 1 Jan 2025 18:31:12 +1000 Subject: [PATCH 2/3] fix: update bun installation steps in workflows for proper dependency setup --- .github/workflows/build.yml | 15 ++++++++++++--- .github/workflows/release.yml | 21 ++++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afe4e08..eeb8b66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,10 @@ jobs: key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} restore-keys: | ${{ runner.os }}-bun- - - run: curl -fsSL https://bun.sh/install | bash && bun install + - run: | + curl -fsSL https://bun.sh/install | bash + source ~/.bashrc + bun install - name: Import Apple Developer Certificate env: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} @@ -147,7 +150,10 @@ jobs: key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} restore-keys: | ${{ runner.os }}-bun- - - run: curl -fsSL https://bun.sh/install | bash && bun install + - run: | + curl -fsSL https://bun.sh/install | bash + source ~/.bashrc + bun install - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -208,7 +214,10 @@ jobs: sudo apt update sudo apt install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev libasound2-dev rpm echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV - - run: curl -fsSL https://bun.sh/install | bash && bun install + - run: | + curl -fsSL https://bun.sh/install | bash + source ~/.bashrc + bun install - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99ce4e6..111c2ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,7 +61,12 @@ jobs: key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} restore-keys: | ${{ runner.os }}-bun- - - run: curl -fsSL https://bun.sh/install | bash && bun install + - run: curl -fsSL https://bun.sh/install | bash + - name: Install dependencies + run: | + curl -fsSL https://bun.sh/install | bash + source ~/.bashrc + bun install - name: Import Apple Developer Certificate env: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} @@ -129,7 +134,12 @@ jobs: key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} restore-keys: | ${{ runner.os }}-bun- - - run: curl -fsSL https://bun.sh/install | bash && bun install + - run: curl -fsSL https://bun.sh/install | bash + - name: Install dependencies + run: | + curl -fsSL https://bun.sh/install | bash + source ~/.bashrc + bun install - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -198,7 +208,12 @@ jobs: sudo apt update sudo apt install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev libasound2-dev rpm echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV - - run: curl -fsSL https://bun.sh/install | bash && bun install + - run: curl -fsSL https://bun.sh/install | bash + - name: Install dependencies + run: | + curl -fsSL https://bun.sh/install | bash + source ~/.bashrc + bun install - name: Generate Changelog id: changelog run: | From 9db390c1c2a8b41fa0c8d7c09ecc50e1784ce3a1 Mon Sep 17 00:00:00 2001 From: PandaDEV <70103896+0PandaDEV@users.noreply.github.com> Date: Wed, 1 Jan 2025 20:41:29 +1000 Subject: [PATCH 3/3] chore: migrate from bun to pnpm for dependency management in workflows --- .github/workflows/build.yml | 33 ++++++++------------ .github/workflows/release.yml | 57 +++++++++++++---------------------- src-tauri/tauri.conf.json | 4 +-- 3 files changed, 35 insertions(+), 59 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eeb8b66..4c23943 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,14 +56,11 @@ jobs: save-if: "true" - uses: actions/cache@v4 with: - path: ~/.bun - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-bun- - - run: | - curl -fsSL https://bun.sh/install | bash - source ~/.bashrc - bun install + ${{ runner.os }}-pnpm- + - run: npm install -g pnpm && pnpm install - name: Import Apple Developer Certificate env: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} @@ -146,14 +143,11 @@ jobs: save-if: "true" - uses: actions/cache@v4 with: - path: ~/.bun - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-bun- - - run: | - curl -fsSL https://bun.sh/install | bash - source ~/.bashrc - bun install + ${{ runner.os }}-pnpm- + - run: npm install -g pnpm && pnpm install - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -205,19 +199,16 @@ jobs: save-if: "true" - uses: actions/cache@v4 with: - path: ~/.bun - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-bun- + ${{ runner.os }}-pnpm- - name: Install dependencies run: | sudo apt update sudo apt install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev libasound2-dev rpm echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV - - run: | - curl -fsSL https://bun.sh/install | bash - source ~/.bashrc - bun install + - run: npm install -g pnpm && pnpm install - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 111c2ae..f79b85d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,16 +57,11 @@ jobs: save-if: "true" - uses: actions/cache@v4 with: - path: ~/.bun - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-bun- - - run: curl -fsSL https://bun.sh/install | bash - - name: Install dependencies - run: | - curl -fsSL https://bun.sh/install | bash - source ~/.bashrc - bun install + ${{ runner.os }}-pnpm- + - run: npm install -g pnpm && pnpm install - name: Import Apple Developer Certificate env: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} @@ -88,7 +83,7 @@ jobs: TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} with: args: ${{ matrix.args }} - + - name: Rename macOS Artifacts run: | mv src-tauri/target/${{ matrix.args == '--target aarch64-apple-darwin' && 'aarch64-apple-darwin' || 'x86_64-apple-darwin' }}/release/bundle/dmg/*.dmg src-tauri/target/${{ matrix.args == '--target aarch64-apple-darwin' && 'aarch64-apple-darwin' || 'x86_64-apple-darwin' }}/release/bundle/dmg/Qopy-${{ needs.prepare.outputs.version }}_${{ matrix.arch }}.dmg @@ -130,16 +125,11 @@ jobs: save-if: "true" - uses: actions/cache@v4 with: - path: ~/.bun - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-bun- - - run: curl -fsSL https://bun.sh/install | bash - - name: Install dependencies - run: | - curl -fsSL https://bun.sh/install | bash - source ~/.bashrc - bun install + ${{ runner.os }}-pnpm- + - run: npm install -g pnpm && pnpm install - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -199,21 +189,16 @@ jobs: save-if: "true" - uses: actions/cache@v4 with: - path: ~/.bun - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-bun- + ${{ runner.os }}-pnpm- - name: Install dependencies run: | sudo apt update sudo apt install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev libasound2-dev rpm echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV - - run: curl -fsSL https://bun.sh/install | bash - - name: Install dependencies - run: | - curl -fsSL https://bun.sh/install | bash - source ~/.bashrc - bun install + - run: npm install -g pnpm && pnpm install - name: Generate Changelog id: changelog run: | @@ -258,10 +243,10 @@ jobs: id: release_body run: | VERSION="${{ needs.prepare.outputs.version }}" - + # Get the most recent release tag (v* tags only) LAST_TAG=$(git describe --match "v*" --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1` 2>/dev/null || echo "") - + if [ -n "$LAST_TAG" ]; then echo "Debug: Found last release tag: $LAST_TAG" CHANGES=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s") @@ -269,10 +254,10 @@ jobs: echo "Debug: No previous release tag found, using first commit" CHANGES=$(git log --pretty=format:"- %s") fi - + echo "Debug: Changelog content:" echo "$CHANGES" - + # Calculate hashes with corrected paths WINDOWS_ARM_HASH=$(sha256sum "artifacts/windows-arm64-binaries/Qopy-${VERSION}_arm64.msi" | awk '{ print $1 }') WINDOWS_64_HASH=$(sha256sum "artifacts/windows-x64-binaries/Qopy-${VERSION}_x64.msi" | awk '{ print $1 }') @@ -294,11 +279,11 @@ jobs: RELEASE_BODY=$(cat <<-EOF ## ♻️ Changelog - + $CHANGES - + ## ⬇️ Downloads - + - [Windows (x64)](https://github.com/${{ github.repository }}/releases/download/v${VERSION}/Qopy-${VERSION}_x64.msi) - ${WINDOWS_64_HASH} - [Windows (ARM64)](https://github.com/${{ github.repository }}/releases/download/v${VERSION}/Qopy-${VERSION}_arm64.msi) - ${WINDOWS_ARM_HASH} - [macOS (Silicon)](https://github.com/${{ github.repository }}/releases/download/v${VERSION}/Qopy-${VERSION}_silicon.dmg) - ${MAC_SILICON_HASH} @@ -327,4 +312,4 @@ jobs: artifacts/**/*.deb artifacts/**/*.AppImage artifacts/**/*.rpm - body: ${{ env.RELEASE_BODY }} + body: ${{ env.RELEASE_BODY }} \ No newline at end of file diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 2cfde48..7be281f 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -5,8 +5,8 @@ "build": { "frontendDist": "../dist", "devUrl": "http://localhost:3000", - "beforeDevCommand": "bun nuxt dev", - "beforeBuildCommand": "bun nuxt generate" + "beforeDevCommand": "pnpm nuxt dev", + "beforeBuildCommand": "pnpm nuxt generate" }, "app": { "windows": [