Skip to content

Commit 341be2c

Browse files
committed
feat(ci): add gh actions build workflow
1 parent 9579ca8 commit 341be2c

File tree

3 files changed

+1318
-921
lines changed

3 files changed

+1318
-921
lines changed

.github/workflows/build.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
env:
9+
NODE_OPTIONS: "--max-old-space-size=4096"
10+
11+
jobs:
12+
build:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
build:
17+
- name: "whispergo-linux"
18+
platform: "linux/amd64"
19+
os: "ubuntu-latest"
20+
- name: "whispergo-windows.exe"
21+
platform: "windows/amd64"
22+
os: "windows-latest"
23+
24+
runs-on: ${{matrix.build.os}}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: recursive
30+
31+
- name: Setup GoLang
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: "1.21"
35+
- run: go version
36+
shell: bash
37+
38+
- name: Setup NodeJS
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: "20"
42+
- uses: pnpm/action-setup@v4
43+
with:
44+
version: 9
45+
46+
- name: Install Wails
47+
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
48+
shell: bash
49+
- name: Install Linux deps
50+
if: runner.os == 'Linux'
51+
run: sudo apt-get update && sudo apt-get install -y libgtk-3-0 libwebkit2gtk-4.0-dev gcc-aarch64-linux-gnu upx-ucl
52+
shell: bash
53+
- name: Install Windows deps
54+
if: runner.os == 'Windows'
55+
run: choco install wget upx
56+
shell: bash
57+
58+
- name: Build Linux App
59+
if: runner.os == 'Linux'
60+
run: BUILD_ARGS="--platform ${{matrix.build.platform}} -upx" PROJECT_NAME=${{matrix.build.name}} make
61+
shell: bash
62+
- name: Build Windows App
63+
if: runner.os == 'Windows'
64+
run: BUILD_ARGS="--platform ${{matrix.build.platform}} -upx" PROJECT_NAME=${{matrix.build.name}} make CC=gcc.exe
65+
shell: bash
66+
67+
- uses: actions/upload-artifact@v4
68+
with:
69+
name: Build ${{runner.os}} ${{matrix.build.name}}
70+
path: |
71+
*/bin/
72+
*\bin\*
73+
- name: Release
74+
uses: softprops/action-gh-release@v2
75+
if: startsWith(github.ref, 'refs/tags/')
76+
with:
77+
files: |
78+
*/bin/*
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

Makefile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
PROJECT_NAME := whispergo
1+
PROJECT_NAME ?= whispergo
22
OUTPUT := build/bin/$(PROJECT_NAME)
33
UPX_EXECUTABLE := upx
44
MODEL_FILE := ggml-tiny-q5_1.bin
5-
MODEL_URL := https://huggingface.co/ggerganov/whisper.cpp/resolve/main/${MODEL_FILE}
5+
MODEL_URL := https://huggingface.co/ggerganov/whisper.cpp/resolve/main/$(MODEL_FILE)
66

7-
CGO_LDFLAGS=-L$(CUDA_PATH)/stubs -lcuda
7+
ifeq ($(WHISPER_CUDA), 1)
8+
CUDA_PATH ?= /usr/local/cuda
9+
CUDA_LIBPATH ?= $(CUDA_PATH)/lib64
10+
CGO_LDFLAGS += -lcublas -lcudart -lcuda -L$(CUDA_LIBPATH) -L$(CUDA_LIBPATH)/stubs
11+
endif
812

913
CC ?= gcc
1014

@@ -16,21 +20,17 @@ LIBRARY_PATH := $(abspath external/whisper.cpp)
1620

1721
whisper:
1822
echo Build whisper
19-
@${MAKE} -C external/whisper.cpp libwhisper.a
23+
@${MAKE} CC=$(CC) -C external/whisper.cpp libwhisper.a
2024

21-
models/${MODEL_FILE}:
25+
models/$(MODEL_FILE):
2226
echo Download tiny model
23-
@wget -nc ${MODEL_URL} -P models
27+
@wget -q -nc $(MODEL_URL) -P models
2428

25-
release: whisper models/${MODEL_FILE}
26-
C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} wails build
27-
echo $(OUTPUT)
29+
release: whisper models/$(MODEL_FILE)
30+
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(INCLUDE_PATH) LIBRARY_PATH=$(LIBRARY_PATH) wails build $(BUILD_ARGS) -o $(PROJECT_NAME)
2831

29-
compressed: release
30-
$(UPX_EXECUTABLE) $(UPXFLAGS) $(OUTPUT);
31-
32-
dev: whisper models/${MODEL_FILE}
33-
C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} wails dev
32+
dev: whisper models/$(MODEL_FILE)
33+
C_INCLUDE_PATH=$(INCLUDE_PATH) LIBRARY_PATH=$(LIBRARY_PATH) wails dev
3434

3535
clean:
3636
rm -rf build/bin

0 commit comments

Comments
 (0)