Skip to content

Commit

Permalink
feat(ci): add gh actions build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
GarciaLnk committed May 24, 2024
1 parent 9579ca8 commit 341be2c
Show file tree
Hide file tree
Showing 3 changed files with 1,318 additions and 921 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build

on:
push:
tags:
- "*"

env:
NODE_OPTIONS: "--max-old-space-size=4096"

jobs:
build:
strategy:
fail-fast: false
matrix:
build:
- name: "whispergo-linux"
platform: "linux/amd64"
os: "ubuntu-latest"
- name: "whispergo-windows.exe"
platform: "windows/amd64"
os: "windows-latest"

runs-on: ${{matrix.build.os}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup GoLang
uses: actions/setup-go@v5
with:
go-version: "1.21"
- run: go version
shell: bash

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: "20"
- uses: pnpm/action-setup@v4
with:
version: 9

- name: Install Wails
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
shell: bash
- name: Install Linux deps
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libgtk-3-0 libwebkit2gtk-4.0-dev gcc-aarch64-linux-gnu upx-ucl
shell: bash
- name: Install Windows deps
if: runner.os == 'Windows'
run: choco install wget upx
shell: bash

- name: Build Linux App
if: runner.os == 'Linux'
run: BUILD_ARGS="--platform ${{matrix.build.platform}} -upx" PROJECT_NAME=${{matrix.build.name}} make
shell: bash
- name: Build Windows App
if: runner.os == 'Windows'
run: BUILD_ARGS="--platform ${{matrix.build.platform}} -upx" PROJECT_NAME=${{matrix.build.name}} make CC=gcc.exe
shell: bash

- uses: actions/upload-artifact@v4
with:
name: Build ${{runner.os}} ${{matrix.build.name}}
path: |
*/bin/
*\bin\*
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
*/bin/*
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
PROJECT_NAME := whispergo
PROJECT_NAME ?= whispergo
OUTPUT := build/bin/$(PROJECT_NAME)
UPX_EXECUTABLE := upx
MODEL_FILE := ggml-tiny-q5_1.bin
MODEL_URL := https://huggingface.co/ggerganov/whisper.cpp/resolve/main/${MODEL_FILE}
MODEL_URL := https://huggingface.co/ggerganov/whisper.cpp/resolve/main/$(MODEL_FILE)

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

CC ?= gcc

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

whisper:
echo Build whisper
@${MAKE} -C external/whisper.cpp libwhisper.a
@${MAKE} CC=$(CC) -C external/whisper.cpp libwhisper.a

models/${MODEL_FILE}:
models/$(MODEL_FILE):
echo Download tiny model
@wget -nc ${MODEL_URL} -P models
@wget -q -nc $(MODEL_URL) -P models

release: whisper models/${MODEL_FILE}
C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} wails build
echo $(OUTPUT)
release: whisper models/$(MODEL_FILE)
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(INCLUDE_PATH) LIBRARY_PATH=$(LIBRARY_PATH) wails build $(BUILD_ARGS) -o $(PROJECT_NAME)

compressed: release
$(UPX_EXECUTABLE) $(UPXFLAGS) $(OUTPUT);

dev: whisper models/${MODEL_FILE}
C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} wails dev
dev: whisper models/$(MODEL_FILE)
C_INCLUDE_PATH=$(INCLUDE_PATH) LIBRARY_PATH=$(LIBRARY_PATH) wails dev

clean:
rm -rf build/bin
Expand Down
Loading

0 comments on commit 341be2c

Please sign in to comment.