Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows build action fix #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 61 additions & 64 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ name: Build and Deploy

# Trigger the workflow on push to the specified branch
on:
pull_request:
branches:
- main
push:
branches:
- main

# Define the jobs to be run
jobs:
# Define the build job
# Define the build job for macOS
build:
# Specify the runner environment
runs-on: macos-latest
Expand Down Expand Up @@ -64,11 +67,10 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: macos-silicon
# The current path is very specific and might need adjustments with any changes in the file name or structure. A more generalized path (e.g., src-tauri/target/release/bundle/dmg/*.dmg) would be preferable as it's more flexible and resilient to such changes.
path: src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error # or 'warn' or 'ignore'
if-no-files-found: error

# Pre command for intell build
# Pre command for Intel build
- name: rustup command
run: rustup target add x86_64-apple-darwin

Expand All @@ -81,9 +83,8 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: macos-intel
# The current path is very specific and might need adjustments with any changes in the file name or structure. A more generalized path (e.g., src-tauri/target/release/bundle/dmg/*.dmg) would be preferable as it's more flexible and resilient to such changes.
path: src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error # or 'warn' or 'ignore'
if-no-files-found: error

# Build the project for MacOS Universal (both Silicon and Intel)
- name: Build for MacOS Universal
Expand All @@ -94,77 +95,82 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: macos-universal
# The current path is very specific and might need adjustments with any changes in the file name or structure. A more generalized path (e.g., src-tauri/target/release/bundle/dmg/*.dmg) would be preferable as it's more flexible and resilient to such changes.
path: src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error # or 'warn' or 'ignore'
if-no-files-found: error

# Placeholder steps for future implementation for Windows
# Build the project for Windows OS
# Define the build job for Windows
windows-build:
# Specify the runner environment
runs-on: windows-latest

- name: Pre windows script
# Define the steps to be performed in the Windows build job
steps:
# Add the target architecture for building Windows apps
- name: Add target architecture
run: rustup target add x86_64-pc-windows-msvc



# Check out the repository code to the runner
- name: Checkout code
uses: actions/checkout@v4

# Set up the required Node.js version
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"

# Set up the Rust toolchain
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

# Install pnpm (a fast, disk space efficient package manager)
- name: Install pnpm
run: npm install -g pnpm

# Install project dependencies
- name: Install dependencies
run: pnpm i

# Build the project for Windows
- name: Build for Windows
run: pnpm build:app:windows

# Archive Windows build artifacts
- name: Archive Windows artifacts
uses: actions/upload-artifact@v3
with:
name: windows
path: src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe

# Placeholder steps for future implementation for Linux
# Build the project for Linux OS
# - name: Build for Linux
# run: pnpm build:app:linux

# - name: Archive Linux artifacts
# uses: actions/upload-artifact@v3
# with:
# name: linux
# path: src-tauri/target/release/bundle/linux/* # Adjust this path if necessary

# # List the contents of the build directory
# # For Debugging purposes
# - name: List files in the build directory
# run: |
# echo "Listing contents of macos-silicon directory"
# ls -la src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/
# echo "Listing contents of macos-intel directory"
# ls -la src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/
# echo "Listing contents of macos-universal directory"
# ls -la src-tauri/target/universal-apple-darwin/release/bundle/dmg/

# Define the release job which depends on the build job
# Define the release job which depends on both the macOS and Windows build jobs
release:
# Specify that this job needs the build job to complete successfully
needs: build
# Specify that this job needs the build and windows-build jobs to complete successfully
needs: [build, windows-build]
# Specify the runner environment
runs-on: ubuntu-latest

# Define the steps to be performed in the release job
steps:
# Download the build artifacts from the build job
- name: Download artifacts
- name: Download macOS artifacts
uses: actions/download-artifact@v3
with:
name: macos-silicon

- name: Download Windows artifacts
uses: actions/download-artifact@v3
with:
name: windows

# # List the contents of the directories
# # For debugging purposes
# - name: List contents of directories
# run: |
# echo "Listing contents of macos-silicon directory"
# ls -la /home/runner/work/Ollama-Gui/Ollama-Gui/macos-silicon
# echo "Listing contents of macos-intel directory"
# ls -la /home/runner/work/Ollama-Gui/Ollama-Gui/macos-intel
# echo "Listing contents of macos-universal directory"
# ls -la /home/runner/work/Ollama-Gui/Ollama-Gui/macos-universal

# Needs to be updated to use an adequate generated tag
# Generate the tag
- name: Generate tag
id: generate_tag
run: echo "::set-output name=tag::release-$(date +'%Y%m%d%H%M%S')"

# Create a new GitHub release with the generated tag
- name: Create GitHub Release
id: create_release
Expand All @@ -180,7 +186,7 @@ jobs:
# Get the file name and assign it to an object
- name: Get Silicon file name
id: get_filename_silicon
run: echo "::set-output name=filename::$(ls /home/runner/work/Ollama-Gui/Ollama-Gui/macos-silicon/*.dmg)"
run: echo "::set-output name=filename::$(ls src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*.dmg)"

# Print the file name
- name: Echo the Silicon file name
Expand All @@ -200,7 +206,7 @@ jobs:
# Get the file name and assign it to an object
- name: Get Intel file name
id: get_filename_intel
run: echo "::set-output name=filename::$(ls /home/runner/work/Ollama-Gui/Ollama-Gui/macos-intel/*.dmg)"
run: echo "::set-output name=filename::$(ls src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg)"

# Print the file name
- name: Echo the Intel file name
Expand All @@ -220,19 +226,10 @@ jobs:
# Get the file name and assign it to an object
- name: Get Universal file name
id: get_filename_universal
run: echo "::set-output name=filename::$(ls /home/runner/work/Ollama-Gui/Ollama-Gui/macos-universal/*.dmg)"
run: echo "::set-output name=filename::$(ls src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg)"

# Print the file name
- name: Echo the Universal file name
run: echo "The Universal file name is ${{ steps.get_filename_universal.outputs.filename }}"

# Upload the MacOS Universal build artifact to the GitHub release
- name: Upload Release Asset (MacOS Universal)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.get_filename_universal.outputs.filename }} # adjusted path
asset_name: Ollama-Gui-MacOS-Universal.dmg
asset_content_type: application/octet-stream

53 changes: 42 additions & 11 deletions src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
import { useEffect } from "react";
import { actions, core, syncModels } from "@/core";
import { useCallback, useEffect } from "react";
import { actions, core, serverStatusCheck, syncModels } from "@/core";
import { loadDB } from "@/core/local-database";
import { Sidebar } from "@/app/parts/sidebar";
import { ChatWindow } from "./parts/chat-window";
import { SettingsWrapper } from "./parts/settings-wrapper";
import { Command } from "@tauri-apps/plugin-shell";
import { useSimple } from "simple-core-state";
import Axios from 'axios';

Check failure on line 9 in src/app/index.tsx

View workflow job for this annotation

GitHub Actions / windows-build

'Axios' is declared but its value is never read.

Check failure on line 9 in src/app/index.tsx

View workflow job for this annotation

GitHub Actions / build

'Axios' is declared but its value is never read.

// Load the database on the app frame
loadDB();

let intervalID: NodeJS.Timeout;

export const AppFrame = () => {
// async function startServer() {
// let result = await Command.create("ollama-server", [
// "-c",
// "OLLAMA_ORIGINS=* OLLAMA_HOST=127.0.0.1:11434 ollama serve",
// ]).execute();
// console.log(result);
// }
const host = useSimple(core.server_host);
const startServer = useCallback(async () => {
console.log(host);

let result = await Command.create("ollama-server", [
"-c",
`OLLAMA_ORIGINS=* OLLAMA_HOST=${host} ollama serve`,
]).execute();
console.log(result);
}, [host]);



const heartbeatCheck = async () => {
intervalID = setInterval(async () => {
serverStatusCheck();
}, 5000)
}

const loadAppData = async () => {
// Create the tables if not exists
await actions.prepareDatabase();

// Load available models
syncModels();

Expand All @@ -27,8 +46,20 @@
};

useEffect(() => {
// Load app data in order for functionality
loadAppData();
startServer();
serverStatusCheck();
heartbeatCheck();
setTimeout(() => {

setTimeout(() => {
// Load app data in order for functionality
loadAppData();
}, 50);
}, 200);

return () => {
clearInterval(intervalID);
}
}, []);

return (
Expand Down
9 changes: 0 additions & 9 deletions src/app/parts/chat-window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ export const ChatWindow = () => {
return messages;
}, [messages, conv_id]);

// TODO: We need to move this function to a life cycle for auto restart feature
// async function startServer() {
// let result = await Command.create("ollama-server", [
// "-c",
// "OLLAMA_ORIGINS=* OLLAMA_HOST=127.0.0.1:11434 ollama serve",
// ]).execute();
// console.log(result);
// }

const changeModel = (model_name: string) => {
// Update last used
core.last_used_model.set(model_name);
Expand Down
47 changes: 30 additions & 17 deletions src/app/parts/settings-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const SettingsWrapper = ({ children }: { children: ReactNode }) => {
handleSubmit,
formState: { isDirty },
} = useForm<Inputs>({ values: { host: host_url } });
const onSubmit: SubmitHandler<Inputs> = (data) => console.log(data);

const onSubmit: SubmitHandler<Inputs> = (data) => {
console.log("1223m", data);
};

const clearDatabase = async () => {
await actions.flushDatbase();
Expand All @@ -35,7 +38,7 @@ export const SettingsWrapper = ({ children }: { children: ReactNode }) => {
return (
<div className="h-full w-full relative">
{open && (
<div className="absolute h-full w-full bg-white z-10">
<div className="absolute h-full w-full bg-white z-20 ">
<div className="p-4">
<div className="flex-row flex mb-2">
<p className="font-bold text-lg">Settings</p>
Expand All @@ -51,7 +54,13 @@ export const SettingsWrapper = ({ children }: { children: ReactNode }) => {
<form onSubmit={handleSubmit(onSubmit)}>
{isDirty && (
<div className="flex flex-row mb-2">
<Button size="sm" className="mr-2">
<Button
size="sm"
className="mr-2"
onClick={() => {
handleSubmit(onSubmit);
}}
>
Save
</Button>
<Button
Expand Down Expand Up @@ -84,21 +93,25 @@ export const SettingsWrapper = ({ children }: { children: ReactNode }) => {
</div>
<div className="flex flex-col">
<p>Build by:</p>
<Button
variant="link"
onClick={() => window.open("https://x.com/twanluttik")}
>
Twan Luttik - x.com
</Button>
<div className="flex-col flex items-start">
<p
className="cursor-pointer hover:opacity-50 active:opacity-30"
onClick={() => window.open("https://x.com/twanluttik")}
>
Twan Luttik - x.com
</p>

<Button
variant="link"
onClick={() =>
window.open("https://github.com/ollama-interface/Ollama-Gui")
}
>
code - github.com
</Button>
<p
className="cursor-pointer hover:opacity-50"
onClick={() =>
window.open(
"https://github.com/ollama-interface/Ollama-Gui"
)
}
>
code - github.com
</p>
</div>
</div>
</div>
</div>
Expand Down
Loading
Loading