Skip to content

Commit 26803b8

Browse files
authored
Merge pull request #9 from streed/lets-convert-to-wails
Lets Convert To Wails
2 parents cc7a234 + 58bcd79 commit 26803b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+11260
-237
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,28 @@ jobs:
6868
version: latest
6969
args: --timeout=5m
7070

71-
build:
72-
name: Build
71+
build-desktop:
72+
name: Build Desktop Apps
7373
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
7474
runs-on: ${{ matrix.os }}
7575
strategy:
76+
fail-fast: false
7677
matrix:
7778
include:
7879
- os: ubuntu-latest
79-
goos: linux
80-
goarch: amd64
80+
platform: linux/amd64
8181
name: linux-amd64
8282
ext: ""
8383
- os: macos-latest
84-
goos: darwin
85-
goarch: amd64
84+
platform: darwin/amd64
8685
name: darwin-amd64
87-
ext: ""
86+
ext: ".app"
8887
- os: macos-latest
89-
goos: darwin
90-
goarch: arm64
88+
platform: darwin/arm64
9189
name: darwin-arm64
92-
ext: ""
90+
ext: ".app"
9391
- os: windows-latest
94-
goos: windows
95-
goarch: amd64
92+
platform: windows/amd64
9693
name: windows-amd64
9794
ext: ".exe"
9895

@@ -105,34 +102,58 @@ jobs:
105102
with:
106103
go-version: ${{ env.GO_VERSION }}
107104

108-
- name: Setup Windows build environment
109-
if: matrix.goos == 'windows'
110-
shell: bash
105+
- name: Setup Node.js
106+
uses: actions/setup-node@v4
107+
with:
108+
node-version: '20'
109+
cache: 'npm'
110+
cache-dependency-path: frontend/package-lock.json
111+
112+
- name: Install Wails
113+
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
114+
115+
- name: Install Linux dependencies
116+
if: matrix.os == 'ubuntu-latest'
117+
run: |
118+
sudo apt-get update
119+
sudo apt-get install -y build-essential pkg-config libgtk-3-dev libwebkit2gtk-4.0-dev
120+
121+
- name: Install Windows dependencies
122+
if: matrix.os == 'windows-latest'
123+
run: |
124+
choco install mingw -y
125+
choco install nsis -y
126+
127+
- name: Install frontend dependencies
128+
working-directory: frontend
129+
run: npm ci
130+
131+
- name: Build Wails app
132+
run: |
133+
wails build -platform ${{ matrix.platform }} -clean
134+
135+
- name: Package artifacts (Linux)
136+
if: matrix.os == 'ubuntu-latest'
111137
run: |
112-
# Install MSYS2 for complete build environment
113-
choco install msys2 -y
114-
# Initialize MSYS2 and install required packages
115-
C:/tools/msys64/usr/bin/bash -lc 'pacman --noconfirm -S mingw-w64-x86_64-gcc mingw-w64-x86_64-pkg-config mingw-w64-x86_64-sqlite3'
116-
# Add MSYS2 MinGW64 to PATH
117-
echo "C:\\tools\\msys64\\mingw64\\bin" >> $GITHUB_PATH
118-
# Verify installation
119-
C:/tools/msys64/mingw64/bin/gcc --version || echo "GCC not found"
120-
121-
- name: Build binary
122-
shell: bash
138+
mkdir -p artifacts
139+
cp build/bin/ml-notes artifacts/ml-notes-${{ matrix.name }}
140+
chmod +x artifacts/ml-notes-${{ matrix.name }}
141+
142+
- name: Package artifacts (macOS)
143+
if: matrix.os == 'macos-latest'
123144
run: |
124-
if [ "${{ matrix.goos }}" = "windows" ]; then
125-
# Set up CGO environment for Windows with MSYS2
126-
export CGO_ENABLED=1
127-
export CC=C:/tools/msys64/mingw64/bin/gcc.exe
128-
export CXX=C:/tools/msys64/mingw64/bin/g++.exe
129-
export PKG_CONFIG_PATH="C:/tools/msys64/mingw64/lib/pkgconfig"
130-
export PATH="C:/tools/msys64/mingw64/bin:$PATH"
131-
fi
132-
CGO_ENABLED=1 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -v -o ml-notes-${{ matrix.name }}${{ matrix.ext }}
133-
134-
- name: Test binary
135-
if: matrix.goarch == 'amd64' # Only test on native architecture
136-
shell: bash
145+
mkdir -p artifacts
146+
cp -r "build/bin/ML Notes.app" "artifacts/ML Notes-${{ matrix.name }}.app"
147+
148+
- name: Package artifacts (Windows)
149+
if: matrix.os == 'windows-latest'
137150
run: |
138-
./ml-notes-${{ matrix.name }}${{ matrix.ext }} --help
151+
mkdir -p artifacts
152+
cp build/bin/ml-notes.exe artifacts/ml-notes-${{ matrix.name }}.exe
153+
154+
- name: Upload artifacts
155+
uses: actions/upload-artifact@v4
156+
with:
157+
name: ml-notes-desktop-${{ matrix.name }}
158+
path: artifacts/*
159+
retention-days: 30

Makefile

Lines changed: 102 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Makefile for ML Notes
22

33
# Variables
4-
BINARY_NAME := ml-notes
4+
CLI_BINARY_NAME := ml-notes-cli
5+
GUI_BINARY_NAME := ml-notes
56
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
67
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
78
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
@@ -12,6 +13,19 @@ LDFLAGS := -ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)
1213
CGO_ENABLED := 1
1314
GOFLAGS := -v
1415

16+
# Go binary paths
17+
GOPATH := $(shell go env GOPATH)
18+
GOBIN := $(shell go env GOBIN)
19+
ifeq ($(GOBIN),)
20+
GOBIN := $(GOPATH)/bin
21+
endif
22+
23+
# Add Go bin to PATH for this Makefile
24+
export PATH := $(PATH):$(GOBIN)
25+
26+
# Check if Wails is available (after adding GOBIN to PATH)
27+
WAILS_AVAILABLE := $(shell command -v wails 2> /dev/null)
28+
1529
# Directories
1630
PREFIX := /usr/local
1731
BINDIR := $(PREFIX)/bin
@@ -41,37 +55,78 @@ endif
4155

4256
# Default target
4357
.PHONY: all
44-
all: build install
58+
all: build-cli build-gui install
4559

46-
# Build the binary
60+
# Build both CLI and GUI binaries
4761
.PHONY: build
48-
build:
49-
@echo "Building $(BINARY_NAME) $(VERSION) for $(PLATFORM)/$(ARCH)..."
62+
build: build-cli build-gui
63+
64+
# Build the CLI binary
65+
.PHONY: build-cli
66+
build-cli:
67+
@echo "Building $(CLI_BINARY_NAME) $(VERSION) for $(PLATFORM)/$(ARCH)..."
68+
@echo "Go version: $(GO_VERSION)"
69+
@echo "Git commit: $(GIT_COMMIT)"
70+
CGO_ENABLED=$(CGO_ENABLED) go build $(GOFLAGS) $(LDFLAGS) -o $(CLI_BINARY_NAME) ./app/cli
71+
@echo "CLI build complete: ./$(CLI_BINARY_NAME)"
72+
73+
# Build the GUI binary using Wails
74+
.PHONY: build-gui
75+
build-gui:
76+
ifdef WAILS_AVAILABLE
77+
@echo "Building $(GUI_BINARY_NAME) $(VERSION) using Wails..."
5078
@echo "Go version: $(GO_VERSION)"
5179
@echo "Git commit: $(GIT_COMMIT)"
52-
CGO_ENABLED=$(CGO_ENABLED) go build $(GOFLAGS) $(LDFLAGS) -o $(BINARY_NAME) .
53-
@echo "Build complete: ./$(BINARY_NAME)"
80+
wails build -clean -o $(GUI_BINARY_NAME)
81+
@echo "GUI build complete: ./build/bin/$(GUI_BINARY_NAME)"
82+
else
83+
@echo "⚠️ Wails not found. Skipping GUI build."
84+
@echo " Install Wails with: go install github.com/wailsapp/wails/v2/cmd/wails@latest"
85+
endif
86+
87+
# Development build with race detector for CLI
88+
.PHONY: dev-cli
89+
dev-cli:
90+
@echo "Building CLI development version with race detector..."
91+
CGO_ENABLED=1 go build -race $(LDFLAGS) -o $(CLI_BINARY_NAME)-dev ./app/cli
92+
@echo "CLI development build complete: ./$(CLI_BINARY_NAME)-dev"
93+
94+
# Development build for GUI using Wails
95+
.PHONY: dev-gui
96+
dev-gui:
97+
ifdef WAILS_AVAILABLE
98+
@echo "Starting Wails development server..."
99+
wails dev
100+
else
101+
@echo "⚠️ Wails not found. Cannot start development server."
102+
@echo " Install Wails with: go install github.com/wailsapp/wails/v2/cmd/wails@latest"
103+
endif
54104

55-
# Development build with race detector
105+
# Development build for both
56106
.PHONY: dev
57-
dev:
58-
@echo "Building development version with race detector..."
59-
CGO_ENABLED=1 go build -race $(LDFLAGS) -o $(BINARY_NAME)-dev .
60-
@echo "Development build complete: ./$(BINARY_NAME)-dev"
107+
dev: dev-cli dev-gui
61108

62-
# Install the binary to system PATH
109+
# Install binaries to system PATH
63110
.PHONY: install
64-
install: $(BINARY_NAME)
65-
@echo "Installing $(BINARY_NAME) to $(BINDIR)..."
66-
@$(INSTALL_PROGRAM) $(BINARY_NAME) $(BINDIR)/
111+
install: $(CLI_BINARY_NAME) $(GUI_BINARY_NAME)
112+
@echo "Installing $(CLI_BINARY_NAME) to $(BINDIR)..."
113+
@$(INSTALL_PROGRAM) $(CLI_BINARY_NAME) $(BINDIR)/
114+
ifdef WAILS_AVAILABLE
115+
@if [ -f "./build/bin/$(GUI_BINARY_NAME)" ]; then \
116+
echo "Installing $(GUI_BINARY_NAME) to $(BINDIR)..."; \
117+
$(INSTALL_PROGRAM) ./build/bin/$(GUI_BINARY_NAME) $(BINDIR)/; \
118+
fi
119+
endif
67120
@echo "Installation complete!"
68-
@echo "Run 'ml-notes init' to set up your configuration."
121+
@echo "Run '$(CLI_BINARY_NAME) init' to set up your configuration."
122+
@echo "Run '$(GUI_BINARY_NAME)' to start the desktop application."
69123

70-
# Uninstall the binary
124+
# Uninstall the binaries
71125
.PHONY: uninstall
72126
uninstall:
73-
@echo "Removing $(BINARY_NAME) from $(BINDIR)..."
74-
@rm -f $(BINDIR)/$(BINARY_NAME)
127+
@echo "Removing binaries from $(BINDIR)..."
128+
@rm -f $(BINDIR)/$(CLI_BINARY_NAME)
129+
@rm -f $(BINDIR)/$(GUI_BINARY_NAME)
75130
@echo "Uninstall complete."
76131

77132
# Run tests
@@ -111,7 +166,9 @@ fmt:
111166
.PHONY: clean
112167
clean:
113168
@echo "Cleaning build artifacts..."
114-
@rm -f $(BINARY_NAME) $(BINARY_NAME)-dev
169+
@rm -f $(CLI_BINARY_NAME) $(CLI_BINARY_NAME)-dev
170+
@rm -f $(GUI_BINARY_NAME) $(GUI_BINARY_NAME)-dev
171+
@rm -rf build/
115172
@rm -f coverage.out coverage.html
116173
@rm -rf dist/
117174
@echo "Clean complete."
@@ -218,7 +275,9 @@ help:
218275
@echo "ML Notes - Makefile targets:"
219276
@echo ""
220277
@echo "🏗️ Build targets:"
221-
@echo " make build - Build the binary for current platform"
278+
@echo " make build - Build both CLI and GUI binaries"
279+
@echo " make build-cli - Build the CLI binary only"
280+
@echo " make build-gui - Build the GUI binary using Wails"
222281
@echo " make build-native - Build for native platform (auto-detect)"
223282
@echo " make build-linux - Build for Linux AMD64"
224283
@echo " make build-darwin - Build for macOS (Intel & Apple Silicon)"
@@ -229,9 +288,11 @@ help:
229288
@echo " make release - Create release packages for all platforms"
230289
@echo ""
231290
@echo "🛠️ Development targets:"
232-
@echo " make install - Build and install to $(BINDIR)"
233-
@echo " make uninstall - Remove from $(BINDIR)"
234-
@echo " make dev - Build with race detector"
291+
@echo " make install - Build and install both binaries to $(BINDIR)"
292+
@echo " make uninstall - Remove both binaries from $(BINDIR)"
293+
@echo " make dev - Build CLI with race detector"
294+
@echo " make dev-cli - Build CLI with race detector"
295+
@echo " make dev-gui - Start Wails development server"
235296
@echo " make test - Run tests"
236297
@echo " make test-coverage - Run tests with coverage"
237298
@echo " make lint - Run linters"
@@ -242,16 +303,29 @@ help:
242303
@echo ""
243304
@echo "ℹ️ Information:"
244305
@echo " VERSION=$(VERSION)"
306+
@echo " CLI_BINARY_NAME=$(CLI_BINARY_NAME)"
307+
@echo " GUI_BINARY_NAME=$(GUI_BINARY_NAME)"
245308
@echo " PLATFORM=$(PLATFORM)/$(ARCH)"
246309
@echo " PREFIX=$(PREFIX)"
310+
ifdef WAILS_AVAILABLE
311+
@echo " WAILS=available"
312+
else
313+
@echo " WAILS=not available (GUI builds disabled)"
314+
endif
247315
@echo ""
248316
@echo "📝 Notes:"
317+
@echo " - The CLI binary provides all command-line functionality"
318+
@echo " - The GUI binary is a desktop app built with Wails"
319+
@echo " - Wails is required for GUI builds: go install github.com/wailsapp/wails/v2/cmd/wails@latest"
249320
@echo " - Cross-compilation for macOS/Windows requires appropriate toolchains"
250321
@echo " - For best results, build natively on target platforms"
251322
@echo " - CGO is required for sqlite-vec support"
252323

253-
# Ensure binary exists for install target
254-
$(BINARY_NAME):
255-
@$(MAKE) build
324+
# Ensure binaries exist for install target
325+
$(CLI_BINARY_NAME):
326+
@$(MAKE) build-cli
327+
328+
$(GUI_BINARY_NAME):
329+
@$(MAKE) build-gui
256330

257331
.DEFAULT_GOAL := help

app/cli/main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/streed/ml-notes/internal/cli"
8+
)
9+
10+
// Version is set via ldflags during build
11+
var Version = "dev"
12+
13+
func main() {
14+
// Set version for the CLI package
15+
cli.Version = Version
16+
17+
if err := cli.Execute(); err != nil {
18+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
19+
os.Exit(1)
20+
}
21+
}

app/desktop/assets.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package main
2+
3+
import (
4+
"embed"
5+
)
6+
7+
//go:embed frontend
8+
var assets embed.FS

0 commit comments

Comments
 (0)