Skip to content

Commit

Permalink
feat: windows build (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelint committed Jul 14, 2024
1 parent e430e08 commit 58e1b71
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 33 deletions.
90 changes: 60 additions & 30 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ on:
tags:
- "v*.*.*"


jobs:
bundle_core:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: core
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
# os: ["windows-latest", "ubuntu-latest", "macos-latest"]
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
# - platform: 'macos-latest' # for Intel based macs.
# args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
args: ''
- platform: 'windows-latest'
args: ''
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4
Expand All @@ -31,74 +37,98 @@ jobs:
poetry install
- run: make bundle

- uses: actions/upload-artifact@v4
with:
name: core-${{ matrix.os }}
name: core-${{ matrix.platform }}
retention-days: 1
path: core/dist/*

bundle_desktop:
needs: bundle_core
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
# os: ["windows-latest", "ubuntu-latest", "macos-latest"]
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
# - platform: 'macos-latest' # for Intel based macs.
# args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
args: ''
- platform: 'windows-latest'
args: ''
runs-on: ${{ matrix.platform }}
steps:
- name: Extract version from tag
id: extract_version
- name: Set env
run: echo "__VERSION__=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Display version
run: |
echo "Tag name: ${{ github.ref_name }}"
TAG_NAME=${{ github.ref_name }}
if [[ $TAG_NAME =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
VERSION=${BASH_REMATCH[1]}
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "The tag $TAG_NAME is not in the expected format 'v<MAJOR>.<MINOR>.<PATCH>'"
exit 1
fi
echo $__VERSION__
- uses: actions/checkout@v4
- name: Download bundle artifacts
uses: actions/download-artifact@v4
with:
name: core-${{ matrix.os }}
name: core-${{ matrix.platform }}
path: core/dist

- name: Linux Only - Install Extra Libs
if: runner.os == 'Linux'
shell: bash
run: sudo apt-get update && sudo apt-get install -y build-essential libgtk-3-dev libssl-dev libsoup2.4-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf

- name: Update package.json version
uses: jossef/[email protected]
with:
file: webapp/src-tauri/tauri.conf.json
field: package.version
value: ${{ github.ref_name }}

- name: Setup Webapp
id: prepare-webapp
uses: ./.github/actions/prepare_webapp
with:
working-directory: webapp

- name: Set Version
working-directory: webapp
run: pnpm run set-version ${{ env.VERSION }}
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ github.ref_name }}
releaseName: ${{ github.ref_name }}
releaseDraft: true
args: ${{ matrix.args }}

- name: Bundle
working-directory: webapp
run: pnpm run build

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
webapp/src-tauri/target/**/release/bundle/**/*.dmg
webapp/src-tauri/target/**/release/bundle/**/*.app
webapp/src-tauri/target/release/bundle/**/*.dmg
webapp/src-tauri/target/release/bundle/**/*.app
webapp/src-tauri/target/release/bundle/**/*.deb
webapp/src-tauri/target/release/bundle/**/*.rpm
webapp/src-tauri/target/release/bundle/**/*.AppImage
webapp/src-tauri/target/release/bundle/**/*.exe
webapp/src-tauri/target/release/bundle/**/*.msi
# # Project rules must be updated to push changes
# # GH013: Repository rule violations found for refs/heads/main.
Expand Down
2 changes: 1 addition & 1 deletion core/pyinstaller_hooks/hook-llama_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# Append the additional .dll or .so file
if os.name == "nt": # Windows
dll_path = os.path.join(package_path, "llama_cpp", "lib", "libllama.dll")
dll_path = os.path.join(package_path, "llama_cpp", "lib", "llama.dll")
datas.append((dll_path, "llama_cpp"))
elif sys.platform == "darwin": # Mac
so_path = os.path.join(package_path, "llama_cpp", "lib", "libllama.dylib")
Expand Down
12 changes: 10 additions & 2 deletions webapp/src-tauri/src/app_state/sidecar_lifecycle_service.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::borrow::BorrowMut;

use std::process::{Child, Command, Stdio};
use command_group::{Signal, UnixChildExt};
use tauri::api::process::Command as TCommand;
use log::{info, error};
use std::io::{BufReader, BufRead};
use std::thread;

#[cfg(unix)]
use command_group::{Signal, UnixChildExt};

fn log_child_stderr(mut child: Child) -> Child {
if let Some(stderr) = child.stderr.take() {
Expand Down Expand Up @@ -77,9 +78,16 @@ impl SidecarLifeCycleService {
Some(child) => {
let id = child.id();

child
#[cfg(unix)]
{
child
.signal(Signal::SIGTERM)
.expect("Some error happened when killing child process");
}
#[cfg(windows)]
{
child.kill().expect("Some error happened when killing child process");
}

self.child = None;
let info = format!("Sidecar {} stopped - {}", self.program, id);
Expand Down

0 comments on commit 58e1b71

Please sign in to comment.