Skip to content

Commit

Permalink
Add release GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
xcmd-io committed Sep 9, 2023
1 parent f9c1f35 commit 6053e04
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/rust.yaml → .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: test

name: Build
on:
push:
branches:
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
!.github
target
node_modules
xcmd-tauri/src-tauri/binaries
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 6 additions & 1 deletion xcmd-fs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ use xcmd_base::{
stop_server_when_parent_process_exits, FileInfo, ListRequest, ListResponse, Request, Response, init_telemetry,
};

#[cfg(target_os = "windows")]
const DEFAULT_PATH: &str = "c:/";
#[cfg(not(target_os = "windows"))]
const DEFAULT_PATH: &str = "/";

#[post("/")]
async fn enact(request: web::Json<Request>) -> Result<HttpResponse, Box<dyn Error>> {
match request.into_inner() {
Expand Down Expand Up @@ -92,7 +97,7 @@ fn list_files(request: ListRequest) -> Result<ListResponse, Box<dyn Error>> {
let path = if let Some(ref path) = request.path {
std::path::Path::new(path).to_path_buf()
} else {
std::path::Path::new("c:/").to_path_buf()
std::path::Path::new(DEFAULT_PATH).to_path_buf()
};

// gets the full path; this path concatenated with the optional key, for instance `a/b/c/d`
Expand Down
6 changes: 3 additions & 3 deletions xcmd-tauri/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
</thead>
<tbody>
<tr class="tbody-row" tabindex="0">
<td style="width: 100%"><img class="icon" src="../folder.svg"/> <span data-text="name">name</span></td>
<td style="width: 3em" style="width: 3em">ext</td>
<td style="width: 5em" class="vtable--align-right">0</td>
<td style="width: 100%"><img class="icon" data-src-fn="icon" src="../folder.svg"/> <span data-text="name">name</span></td>
<td style="width: 3em" data-text="extension" style="width: 3em">ext</td>
<td style="width: 5em" data-text="size" class="vtable--align-right">0</td>
<td style="width: 10em">1970-01-01 00:00</td>
<td style="width: 5em">-a--</td>
<td></td>
Expand Down
7 changes: 5 additions & 2 deletions xcmd-tauri/dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion xcmd-tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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", "devtools"] }

[features]
# by default Tauri runs in production mode
Expand Down
31 changes: 29 additions & 2 deletions xcmd-tauri/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -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<String, Box<dyn Error>> {
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<dyn Error>> {
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())
}
20 changes: 17 additions & 3 deletions xcmd-tauri/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
},
"package": {
"productName": "xcmd",
"version": "0.1.0"
"version": "0.1.3"
},
"tauri": {
"allowlist": {
"all": true,
"shell": {
"sidecar": true,
"scope": [
{
"name": "binaries/xcmd-fs",
"sidecar": true,
"args": []
}
],
"execute": true
}
},
Expand All @@ -26,7 +33,9 @@
"deb": {
"depends": []
},
"externalBin": [],
"externalBin": [
"binaries/xcmd-fs"
],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
Expand Down Expand Up @@ -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": [
{
Expand Down

0 comments on commit 6053e04

Please sign in to comment.