build: 新增,ubuntu依赖库 #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 dependencies | |
| run: | | |
| go mod download | |
| go mod verify | |
| - 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 | |
| OUTPUT="xiaozhi-client" | |
| else | |
| GOOS=linux | |
| OUTPUT="xiaozhi-client" | |
| fi | |
| GOARCH=amd64 \ | |
| go build -v -o $OUTPUT ./cmd/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 artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: xiaozhi-client-${{ matrix.os }} | |
| path: ${{ matrix.os == 'windows-latest' && 'xiaozhi-client-windows.zip' || matrix.os == 'macos-latest' && 'xiaozhi-client' || 'xiaozhi-client' }} | |
| 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 | |
| artifacts/xiaozhi-client-macos-latest | |
| artifacts/xiaozhi-client-windows-latest | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true |