Skip to content

feat: add wake word detection functionality with refactored audio cal… #56

feat: add wake word detection functionality with refactored audio cal…

feat: add wake word detection functionality with refactored audio cal… #56

Workflow file for this run

name: Build and Release
on:
push:
branches:
- main
- master
tags:
- 'v*'
pull_request:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: [1.23]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Install audio libraries (Ubuntu only)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y libasound2-dev libopus-dev libpulse-dev
- name: Install audio libraries (macOS only)
if: matrix.os == 'macos-latest'
run: |
brew install --build-from-source portaudio opus opusfile pkg-config
arch -x86_64 brew install --build-from-source opus opusfile pkg-config
- name: Set macOS env for CGO
if: matrix.os == 'macos-latest'
run: |
echo "PKG_CONFIG_PATH=$(brew --prefix)/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "CGO_CFLAGS=-I$(brew --prefix)/include -I$(brew --prefix)/include/opus" >> $GITHUB_ENV
echo "CGO_LDFLAGS=-L$(brew --prefix)/lib -lopus" >> $GITHUB_ENV
- name: Install dependencies
run: |
go mod download
go mod verify
- name: Install zip (Windows only)
if: matrix.os == 'windows-latest'
run: choco install zip -y
- name: Build
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
GOOS=windows
OUTPUT="xiaozhi-client.exe"
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
GOOS=darwin
GOARCH=amd64
OUTPUT="xiaozhi-client"
else
GOOS=linux
GOARCH=amd64
OUTPUT="xiaozhi-client"
fi
CGO_ENABLED=1 \
go build -x -v -o $OUTPUT ./cmd/client
- name: Package Linux/macOS artifacts
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
shell: bash
run: |
tar -czvf xiaozhi-client-${{ matrix.os }}.tar.gz xiaozhi-client
- name: Prepare Windows artifacts
if: matrix.os == 'windows-latest'
shell: bash
run: |
mkdir -p dist
cp xiaozhi-client.exe dist/
cp cmd/client/opus.dll dist/
cd dist
zip -r ../xiaozhi-client-windows.zip *
- name: Upload Linux artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: xiaozhi-client-ubuntu-latest
path: xiaozhi-client-ubuntu-latest.tar.gz
- name: Upload macOS artifact
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: xiaozhi-client-macos-latest
path: xiaozhi-client-macos-latest.tar.gz
- name: Upload Windows artifact
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: xiaozhi-client-windows-latest
path: xiaozhi-client-windows.zip
release:
name: Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/xiaozhi-client-ubuntu-latest/xiaozhi-client-ubuntu-latest.tar.gz
artifacts/xiaozhi-client-macos-latest/xiaozhi-client-macos-latest.tar.gz
artifacts/xiaozhi-client-windows-latest/xiaozhi-client-windows.zip
draft: false
prerelease: false
generate_release_notes: true