From 92b9e55b21e3e46d8dc23ae83a245201c02af5b6 Mon Sep 17 00:00:00 2001 From: Jeroen Nijhuis Date: Tue, 23 Apr 2024 09:57:47 +0200 Subject: [PATCH] feat: add aarch64 builds for OSX + overhaul CI with caching --- .github/workflows/build.yml | 24 ++++++----- .github/workflows/release.yml | 77 +++++++++++++++-------------------- src-tauri/Cargo.lock | 21 ++++++++++ src-tauri/Cargo.toml | 2 +- src/App.vue | 5 +++ 5 files changed, 73 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55088a2..429e47d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js uses: actions/setup-node@v3 @@ -37,6 +37,11 @@ jobs: with: toolchain: stable + - name: Rust cache + uses: swatinem/rust-cache@v2 + with: + workspaces: "./src-tauri -> target" + - name: Install Linux dependencies if: matrix.platform == 'ubuntu-latest' run: | @@ -52,19 +57,16 @@ jobs: copy "C:\Program Files\OpenSSL\bin\libcrypto-3-x64.dll" .\src-tauri copy "C:\Program Files\OpenSSL\bin\libssl-3-x64.dll" .\src-tauri - - name: Build Vite + Tauri (MacOS + Linux) - if: matrix.platform != 'windows-latest' - env: - TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} + - name: Set Windows Env Vars run: | - npm run build + if [ "${{ matrix.platform }}" = "windows-latest" ]; then + echo "export OPENSSL_DIR='C:\Program Files\OpenSSL'" >> $GITHUB_ENV + echo "export SSL_CERT_FILE='C:\Program Files\OpenSSL\ca\cacert.pem'" >> $GITHUB_ENV + echo "export OPENSSL_NO_VENDOR=1" >> $GITHUB_ENV + fi - - name: Build Vite + Tauri (Windows) - if: matrix.platform == 'windows-latest' + - name: Build Vite + Tauri env: TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - OPENSSL_DIR: 'C:\Program Files\OpenSSL' - SSL_CERT_FILE: 'C:\Program Files\OpenSSL\ca\cacert.pem' - OPENSSL_NO_VENDOR: 1 run: | npm run build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8b11f4..8b769dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,11 +14,19 @@ jobs: strategy: fail-fast: false matrix: - platform: [macos-latest, ubuntu-latest, windows-latest] + settings: + - platform: "macos-latest" + args: "--target aarch64-apple-darwin" + - platform: "macos-latest" + args: "--target x86_64-apple-darwin" + - platform: "ubuntu-latest" + args: "" + - platform: "windows-latest" + args: "" - runs-on: ${{ matrix.platform }} + runs-on: ${{ matrix.settings.platform }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js uses: actions/setup-node@v3 @@ -26,22 +34,14 @@ jobs: node-version: 18 cache: "npm" - - name: Install dependencies - run: npm install - - - name: install Rust stable - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-latest' + if: matrix.settings.platform == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf - name: Install OpenSSL (Windows only) - if: matrix.platform == 'windows-latest' + if: matrix.settings.platform == 'windows-latest' run: | choco install openssl mkdir -p "C:\Program Files\OpenSSL\ca" @@ -49,42 +49,30 @@ jobs: copy "C:\Program Files\OpenSSL\bin\libcrypto-3-x64.dll" .\src-tauri copy "C:\Program Files\OpenSSL\bin\libssl-3-x64.dll" .\src-tauri - - name: Build Vite + Tauri (MacOS + Linux) - if: matrix.platform != 'windows-latest' - env: - TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - run: npm run build - - - name: Build Vite + Tauri (Windows) - if: matrix.platform == 'windows-latest' - env: - OPENSSL_DIR: 'C:\Program Files\OpenSSL' - SSL_CERT_FILE: 'C:\Program Files\OpenSSL\ca\cacert.pem' - OPENSSL_NO_VENDOR: 1 - TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - run: npm run build + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.settings.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - - name: Create release (MacOS + Linux) - if: matrix.platform != 'windows-latest' - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} + - name: Rust cache + uses: swatinem/rust-cache@v2 with: - tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version - releaseName: "v__VERSION__" - releaseBody: "See the assets to download and install this version." - releaseDraft: true - prerelease: false - tauriScript: ./node_modules/.bin/tauri + workspaces: "./src-tauri -> target" + + - name: Install dependencies + run: npm install + + - name: Set Windows Env Vars + run: | + if [ "${{ matrix.os }}" = "windows-latest" ]; then + echo "export OPENSSL_DIR='C:\Program Files\OpenSSL'" >> $GITHUB_ENV + echo "export SSL_CERT_FILE='C:\Program Files\OpenSSL\ca\cacert.pem'" >> $GITHUB_ENV + echo "export OPENSSL_NO_VENDOR=1" >> $GITHUB_ENV + fi - - name: Create release (Windows) - if: matrix.platform == 'windows-latest' + - name: Create release uses: tauri-apps/tauri-action@v0 env: - OPENSSL_DIR: 'C:\Program Files\OpenSSL' - SSL_CERT_FILE: 'C:\Program Files\OpenSSL\ca\cacert.pem' - OPENSSL_NO_VENDOR: 1 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} with: @@ -94,3 +82,4 @@ jobs: releaseDraft: true prerelease: false tauriScript: ./node_modules/.bin/tauri + args: ${{ matrix.settings.args }} diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 57316ad..d4c534d 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2331,6 +2331,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minisign-verify" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -4187,6 +4193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd27c04b9543776a972c86ccf70660b517ecabbeced9fb58d8b961a13ad129af" dependencies = [ "anyhow", + "base64 0.21.6", "bytes", "cocoa 0.24.1", "dirs-next", @@ -4200,6 +4207,7 @@ dependencies = [ "heck 0.4.1", "http", "ignore", + "minisign-verify", "notify-rust", "objc", "once_cell", @@ -4227,12 +4235,14 @@ dependencies = [ "tauri-utils", "tempfile", "thiserror", + "time", "tokio", "url", "uuid", "webkit2gtk", "webview2-com", "windows 0.39.0", + "zip", ] [[package]] @@ -5807,6 +5817,17 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", +] + [[package]] name = "zvariant" version = "3.15.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 4a54011..1d1b4ea 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -14,7 +14,7 @@ tauri-build = { version = "1.4.0", features = [] } [dependencies] serde_json = "1.0.100" serde = { version = "1.0.167", features = ["derive"] } -tauri = { version = "1.4.1", features = [ "macos-private-api", "api-all"] } +tauri = { version = "1.4.1", features = [ "updater", "macos-private-api", "api-all"] } tokio = "1.29.1" kube = { version = "0.87.2" } k8s-openapi = { version = "0.20.0", features = ["v1_26"] } diff --git a/src/App.vue b/src/App.vue index c597408..2955375 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,6 +11,11 @@ import CommandPaletteProvider from "./providers/CommandPaletteProvider"; import TabProvider from "./providers/TabProvider"; import DialogProvider from "./providers/DialogProvider"; import DialogHandler from "./components/DialogHandler.vue"; + +import { checkUpdate } from "@tauri-apps/api/updater"; +checkUpdate().then((update) => { + console.log(update); +});