mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-05-01 22:36:11 -04:00
feat(gui, tauri, ci): Auto updater (#105)
This commit is contained in:
parent
90584a211d
commit
6c433041b7
10 changed files with 925 additions and 75 deletions
102
.github/workflows/build-gui-preview-release-cb.yml
vendored
Normal file
102
.github/workflows/build-gui-preview-release-cb.yml
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
# This file is used to build the preview release binaries for the Tauri GUI with CloudNebula integration
|
||||
name: "Publish GUI Preview Release with CloudNebula"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
UBUNTU: "ubuntu-22.04"
|
||||
MACOS_ARM: "macos-latest"
|
||||
MACOS_INTEL: "macos-13"
|
||||
WINDOWS: "windows-latest"
|
||||
CN_APPLICATION: "UnstoppableSwap/unstoppableswap-gui-rs"
|
||||
|
||||
jobs:
|
||||
draft:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Create Draft Release
|
||||
uses: crabnebula-dev/cloud-release@v0
|
||||
with:
|
||||
command: release draft ${{ env.CN_APPLICATION }} --framework tauri
|
||||
api-key: ${{ secrets.CN_API_KEY }}
|
||||
|
||||
build:
|
||||
needs: draft
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: "macos-latest" # For Arm-based Macs (M1 and above)
|
||||
args: "--target aarch64-apple-darwin"
|
||||
- platform: "macos-13" # For Intel-based Macs
|
||||
args: "--target x86_64-apple-darwin"
|
||||
- platform: "ubuntu-22.04"
|
||||
args: ""
|
||||
- platform: "windows-latest"
|
||||
args: ""
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
|
||||
- name: Install Rust Stable
|
||||
uses: dtolnay/rust-toolchain@1.79
|
||||
with:
|
||||
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
||||
|
||||
- name: Install Dependencies (Ubuntu Only)
|
||||
if: matrix.platform == 'ubuntu-22.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Install Frontend Dependencies
|
||||
working-directory: src-gui
|
||||
run: yarn install
|
||||
|
||||
- name: Install Tauri CLI Globally
|
||||
run: cargo install tauri-cli@^2.0.0-rc
|
||||
|
||||
- name: Install Typeshare CLI Globally
|
||||
run: cargo install typeshare-cli
|
||||
|
||||
- name: Install Dprint Globally
|
||||
run: cargo install dprint@0.39.1
|
||||
|
||||
- name: Build Tauri App
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.BOTTY_GITHUB_TOKEN }}
|
||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
run: |
|
||||
cargo tauri build ${{ matrix.args }}
|
||||
|
||||
- name: Upload Assets
|
||||
uses: crabnebula-dev/cloud-release@v0
|
||||
with:
|
||||
command: release upload ${{ env.CN_APPLICATION }} --framework tauri
|
||||
api-key: ${{ secrets.CN_API_KEY }}
|
||||
path: ./src-tauri/target/release/bundle
|
||||
|
||||
publish:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Publish Release
|
||||
uses: crabnebula-dev/cloud-release@v0
|
||||
with:
|
||||
command: release publish ${{ env.CN_APPLICATION }} --framework tauri
|
||||
api-key: ${{ secrets.CN_API_KEY }}
|
834
Cargo.lock
generated
834
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -22,9 +22,11 @@
|
|||
"@tauri-apps/api": "^2.0.0",
|
||||
"@tauri-apps/plugin-cli": "^2.0.0",
|
||||
"@tauri-apps/plugin-clipboard-manager": "^2.0.0",
|
||||
"@tauri-apps/plugin-dialog": "^2.0.0",
|
||||
"@tauri-apps/plugin-process": "^2.0.0",
|
||||
"@tauri-apps/plugin-shell": "^2.0.0",
|
||||
"@tauri-apps/plugin-store": "^2.0.0",
|
||||
"@tauri-apps/plugin-updater": "^2.0.0",
|
||||
"humanize-duration": "^3.32.1",
|
||||
"lodash": "^4.17.21",
|
||||
"multiaddr": "^10.0.1",
|
||||
|
|
|
@ -18,6 +18,7 @@ import App from "./components/App";
|
|||
import { initEventListeners } from "./rpc";
|
||||
import { persistor, store } from "./store/storeRenderer";
|
||||
import { Box } from "@material-ui/core";
|
||||
import { checkForAppUpdates } from "./updater";
|
||||
|
||||
const container = document.getElementById("root");
|
||||
const root = createRoot(container!);
|
||||
|
@ -67,3 +68,4 @@ async function fetchInitialData() {
|
|||
|
||||
fetchInitialData();
|
||||
initEventListeners();
|
||||
checkForAppUpdates();
|
||||
|
|
27
src-gui/src/renderer/updater.ts
Normal file
27
src-gui/src/renderer/updater.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { check } from "@tauri-apps/plugin-updater";
|
||||
import { ask, message } from "@tauri-apps/plugin-dialog";
|
||||
import { relaunch } from "@tauri-apps/plugin-process";
|
||||
|
||||
export async function checkForAppUpdates() {
|
||||
const update = await check();
|
||||
|
||||
if (update?.available) {
|
||||
const yes = await ask(
|
||||
`
|
||||
Update to ${update.version} is available!
|
||||
Release notes: ${update.body}
|
||||
`,
|
||||
{
|
||||
title: "Update Now!",
|
||||
kind: "info",
|
||||
okLabel: "Update",
|
||||
cancelLabel: "Cancel",
|
||||
}
|
||||
);
|
||||
|
||||
if (yes) {
|
||||
await update.downloadAndInstall();
|
||||
await relaunch();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -888,6 +888,13 @@
|
|||
dependencies:
|
||||
"@tauri-apps/api" "^2.0.0"
|
||||
|
||||
"@tauri-apps/plugin-dialog@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-dialog/-/plugin-dialog-2.0.0.tgz#f1e2840c7f824572a76b375fd1b538a36f28de14"
|
||||
integrity sha512-ApNkejXP2jpPBSifznPPcHTXxu9/YaRW+eJ+8+nYwqp0lLUtebFHG4QhxitM43wwReHE81WAV1DQ/b+2VBftOA==
|
||||
dependencies:
|
||||
"@tauri-apps/api" "^2.0.0"
|
||||
|
||||
"@tauri-apps/plugin-process@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-process/-/plugin-process-2.0.0.tgz#002fd73f0d7b1ae2a5aacf442aa657e83dc2960b"
|
||||
|
@ -909,6 +916,13 @@
|
|||
dependencies:
|
||||
"@tauri-apps/api" "^2.0.0"
|
||||
|
||||
"@tauri-apps/plugin-updater@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-updater/-/plugin-updater-2.0.0.tgz#38cb3e735da28cd1726a3c0e13f032117e4db111"
|
||||
integrity sha512-N0cl71g7RPr7zK2Fe5aoIwzw14NcdLcz7XMGFWZVjprsqgDRWoxbnUkknyCQMZthjhGkppCd/wN2MIsUz+eAhQ==
|
||||
dependencies:
|
||||
"@tauri-apps/api" "^2.0.0"
|
||||
|
||||
"@testing-library/react@^16.0.1":
|
||||
version "16.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-16.0.1.tgz#29c0ee878d672703f5e7579f239005e4e0faa875"
|
||||
|
|
|
@ -23,9 +23,11 @@ swap = { path = "../swap", features = [ "tauri" ] }
|
|||
tauri = { version = "2.0", features = [ "config-json5" ] }
|
||||
tauri-plugin-clipboard-manager = "2.0"
|
||||
tauri-plugin-devtools = "2.0"
|
||||
tauri-plugin-dialog = "2.0.1"
|
||||
tauri-plugin-process = "2.0"
|
||||
tauri-plugin-shell = "2.0"
|
||||
tauri-plugin-store = "2.0"
|
||||
tauri-plugin-updater = "2.0.2"
|
||||
tracing = "0.1"
|
||||
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
"shell:allow-open",
|
||||
"store:default",
|
||||
"process:default",
|
||||
"cli:allow-cli-matches"
|
||||
"cli:allow-cli-matches",
|
||||
"dialog:default",
|
||||
"updater:default",
|
||||
"process:allow-restart"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use swap::cli::{
|
|||
command::{Bitcoin, Monero},
|
||||
};
|
||||
use tauri::{async_runtime::RwLock, Manager, RunEvent};
|
||||
use tauri_plugin_dialog;
|
||||
|
||||
/// Trait to convert Result<T, E> to Result<T, String>
|
||||
/// Tauri commands require the error type to be a string
|
||||
|
@ -127,6 +128,8 @@ fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
|||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_store::Builder::new().build())
|
||||
.plugin(tauri_plugin_clipboard_manager::init())
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
}
|
||||
},
|
||||
"bundle": {
|
||||
"createUpdaterArtifacts": true,
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
|
@ -34,6 +35,14 @@
|
|||
]
|
||||
},
|
||||
"plugins": {
|
||||
"updater": {
|
||||
"active": true,
|
||||
"dialog": true,
|
||||
"endpoints": [
|
||||
"https://cdn.crabnebula.app/update/unstoppableswap/unstoppableswap-gui-rs/{{target}}-{{arch}}/{{current_version}}"
|
||||
],
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEQyNTQ3NTQxQTQ2MkI4N0IKUldSN3VHS2tRWFZVMGpWYytkRFg4dFBzNEh5ZnlxaHBubGpRalVMMG5nVytiR3JPOUE3QjRxc00K"
|
||||
},
|
||||
"cli": {
|
||||
"description": "Start the GUI application",
|
||||
"args": [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue