From 299e10a7a7f385c1c83bc48d84ab85878b669e4a Mon Sep 17 00:00:00 2001 From: xcmd Date: Mon, 4 Sep 2023 23:16:58 -0700 Subject: [PATCH] Add release GitHub workflow --- .github/workflows/{rust.yaml => build.yaml} | 3 +- .github/workflows/release.yaml | 64 +++++++++++++++++++++ .gitignore | 1 + Cargo.lock | 21 +++++++ Cargo.toml | 4 +- xcmd-tauri/dist/index.html | 6 +- xcmd-tauri/dist/main.js | 7 ++- xcmd-tauri/src-tauri/Cargo.toml | 2 +- xcmd-tauri/src-tauri/build.rs | 31 +++++++++- xcmd-tauri/src-tauri/tauri.conf.json | 20 ++++++- 10 files changed, 145 insertions(+), 14 deletions(-) rename .github/workflows/{rust.yaml => build.yaml} (98%) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/rust.yaml b/.github/workflows/build.yaml similarity index 98% rename from .github/workflows/rust.yaml rename to .github/workflows/build.yaml index c39ccc0..55e6614 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/build.yaml @@ -1,5 +1,4 @@ -name: test - +name: Build on: push: branches: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..ff50799 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,64 @@ +name: Release +on: + push: + branches: + - gh-release + # push: + # tags: + # - 'v*' + # workflow_dispatch: + +jobs: + release: + permissions: + contents: write + strategy: + fail-fast: false + matrix: + platform: [macos-latest, ubuntu-20.04, windows-latest] + runs-on: ${{ matrix.platform }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-20.04' + # You can remove libayatana-appindicator3-dev if you don't use the system tray feature. + run: | + sudo apt-get update --fix-missing + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev + + - name: Rust setup + uses: dtolnay/rust-toolchain@stable + + - name: Rust cache + uses: swatinem/rust-cache@v2 + + - name: Sync node version and setup cache + uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + cache: npm + cache-dependency-path: '**/package-lock.json' + + - name: Build binaries + run: cargo build --release --package xcmd-fs --package xcmd-ssh --package xcmd-s3 && cargo test --release --package xcmd-fs --package xcmd-ssh xcmd-s3 + + - name: Install frontend dependencies + working-directory: xcmd-tauri + run: npm install + + - name: Build the app + uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} + TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} + with: + tagName: test # ${{ github.ref_name }} # This only works if your workflow triggers on new tags. + projectPath: xcmd-tauri + releaseName: 'Cross Commander v__VERSION__' + releaseBody: 'See the assets to download and install this version.' + releaseDraft: true + prerelease: false diff --git a/.gitignore b/.gitignore index f00ab93..a75315d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ !.github target node_modules +xcmd-tauri/src-tauri/binaries diff --git a/Cargo.lock b/Cargo.lock index 26085b5..f8ab570 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2912,6 +2912,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[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.3.7" @@ -4893,6 +4899,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fbe522898e35407a8e60dc3870f7579fea2fc262a6a6072eccdd37ae1e1d91e" dependencies = [ "anyhow", + "base64 0.21.2", "bytes", "cocoa", "dirs-next", @@ -4906,6 +4913,7 @@ dependencies = [ "heck 0.4.1", "http", "ignore", + "minisign-verify", "notify-rust", "objc", "once_cell", @@ -4933,12 +4941,14 @@ dependencies = [ "tauri-utils", "tempfile", "thiserror", + "time 0.3.23", "tokio", "url", "uuid", "webkit2gtk", "webview2-com", "windows 0.39.0", + "zip", ] [[package]] @@ -6659,6 +6669,17 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +[[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 = "zstd" version = "0.12.4" diff --git a/Cargo.toml b/Cargo.toml index e5646f3..0e88993 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,10 @@ [workspace] members = [ - "xcmd-tauri/src-tauri", + "xcmd-base", "xcmd-fs", "xcmd-ssh", "xcmd-s3", + "xcmd-tauri/src-tauri", "systemicons", ] +resolver = "2" diff --git a/xcmd-tauri/dist/index.html b/xcmd-tauri/dist/index.html index f9c6878..7754be2 100644 --- a/xcmd-tauri/dist/index.html +++ b/xcmd-tauri/dist/index.html @@ -84,9 +84,9 @@ - name - ext - 0 + name + ext + 0 1970-01-01 00:00 -a-- diff --git a/xcmd-tauri/dist/main.js b/xcmd-tauri/dist/main.js index b470a8d..1389aae 100644 --- a/xcmd-tauri/dist/main.js +++ b/xcmd-tauri/dist/main.js @@ -8,8 +8,11 @@ new Pane(leftPane, 8080); new Pane(rightPane, 8080); if (!sessionStorage.getItem('initialized')) { - const invoke = window.__TAURI__.invoke; - invoke('spawn_process', { process: 'xcmd-fs', arguments: [] }); // port 8080 + const { shell } = window.__TAURI__; + shell.Command.sidecar('binaries/xcmd-fs', []).execute(); + + // const invoke = window.__TAURI__.invoke; + // invoke('spawn_process', { process: 'xcmd-fs', arguments: [] }); // port 8080 // invoke('spawn_process', { process: 'xcmd-ssh', arguments: [] }); // port 8081 // invoke('spawn_process', { process: 'xcmd-s3', arguments: [] }); // port 8082 sessionStorage.setItem('initialized', '1'); diff --git a/xcmd-tauri/src-tauri/Cargo.toml b/xcmd-tauri/src-tauri/Cargo.toml index 58fe221..17e18c3 100644 --- a/xcmd-tauri/src-tauri/Cargo.toml +++ b/xcmd-tauri/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.4.0", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.4.1", features = ["api-all"] } +tauri = { version = "1.4.1", features = [ "updater", "api-all"] } [features] # by default Tauri runs in production mode diff --git a/xcmd-tauri/src-tauri/build.rs b/xcmd-tauri/src-tauri/build.rs index c1ea373..6495561 100644 --- a/xcmd-tauri/src-tauri/build.rs +++ b/xcmd-tauri/src-tauri/build.rs @@ -1,3 +1,30 @@ -fn main() { - tauri_build::build() +use std::env::consts; +use std::error::Error; +use std::fs; +use std::process::Command; + +pub fn get_rustc_host() -> Result> { + let output = Command::new("rustc").arg("-vV").output()?; + let stdout = String::from_utf8(output.stdout)?; + let host = stdout + .lines() + .find_map(|l| l.strip_prefix("host: ")) + .ok_or_else(|| "target triple not found in rustc output")?; + Ok(host.to_string()) +} + +fn main() -> Result<(), Box> { + let host = get_rustc_host()?; + fs::create_dir_all("binaries")?; + eprintln!( + "copying: {} -> {}", + format!("../../target/release/xcmd-fs{}", consts::EXE_SUFFIX), + format!("binaries/xcmd-fs-{}{}", host, consts::EXE_SUFFIX) + ); + fs::copy( + format!("../../target/release/xcmd-fs{}", consts::EXE_SUFFIX), + format!("binaries/xcmd-fs-{}{}", host, consts::EXE_SUFFIX), + )?; + + Ok(tauri_build::build()) } diff --git a/xcmd-tauri/src-tauri/tauri.conf.json b/xcmd-tauri/src-tauri/tauri.conf.json index a1762d9..31dd9d9 100644 --- a/xcmd-tauri/src-tauri/tauri.conf.json +++ b/xcmd-tauri/src-tauri/tauri.conf.json @@ -9,13 +9,20 @@ }, "package": { "productName": "xcmd", - "version": "0.1.0" + "version": "0.1.1" }, "tauri": { "allowlist": { "all": true, "shell": { "sidecar": true, + "scope": [ + { + "name": "binaries/xcmd-fs", + "sidecar": true, + "args": [] + } + ], "execute": true } }, @@ -26,7 +33,9 @@ "deb": { "depends": [] }, - "externalBin": [], + "externalBin": [ + "binaries/xcmd-fs" + ], "icon": [ "icons/32x32.png", "icons/128x128.png", @@ -56,7 +65,12 @@ "csp": null }, "updater": { - "active": false + "active": true, + "endpoints": [ + "https://github.com/xcmd-io/xcmd/releases/download/test/latest.json" + ], + "dialog": true, + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZDQkZDREVGRkVBQ0RBRDMKUldUVDJxeis3ODIvL0pHRHZkQTlONVpXZzRXNjhGWTdybkZtWFJzdEtHK1NRaVJIaEZuaHVIM3gK" }, "windows": [ {