mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-25 09:30:46 +00:00
111 lines
3.3 KiB
YAML
111 lines
3.3 KiB
YAML
name: Build Binaries on Main Push and PR
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-binaries:
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
goos: [windows, linux]
|
|
goarch: [amd64, arm64, 386, riscv64]
|
|
include:
|
|
# Windows
|
|
- goos: windows
|
|
goarch: amd64
|
|
zig_target_triple: x86_64-windows-gnu
|
|
binary_extension: .exe
|
|
- goos: windows
|
|
goarch: arm64
|
|
zig_target_triple: aarch64-windows-gnu
|
|
binary_extension: .exe
|
|
- goos: windows
|
|
goarch: 386
|
|
zig_target_triple: x86-windows-gnu
|
|
binary_extension: .exe
|
|
|
|
# Linux
|
|
- goos: linux
|
|
goarch: amd64
|
|
zig_target_triple: x86_64-linux-musl
|
|
binary_extension: ""
|
|
- goos: linux
|
|
goarch: arm64
|
|
zig_target_triple: aarch64-linux-musl
|
|
binary_extension: ""
|
|
- goos: linux
|
|
goarch: 386
|
|
zig_target_triple: x86-linux-musl
|
|
binary_extension: ""
|
|
- goos: linux
|
|
goarch: riscv64
|
|
zig_target_triple: riscv64-linux-musl
|
|
binary_extension: ""
|
|
|
|
exclude:
|
|
- goos: windows
|
|
goarch: riscv64
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "23"
|
|
|
|
- name: Clone and build frontend
|
|
run: |
|
|
git clone https://github.com/komari-monitor/komari-web web
|
|
cd web
|
|
npm install
|
|
npm run build
|
|
cd ..
|
|
mkdir -p public/dist
|
|
cp -r web/dist/* public/dist/
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.23"
|
|
|
|
- name: Install Zig cross-compiler toolchain
|
|
run: |
|
|
sudo apt-get update # Update apt package lists
|
|
sudo apt-get install -y build-essential curl
|
|
wget https://ziglang.org/download/0.14.1/zig-x86_64-linux-0.14.1.tar.xz
|
|
sudo tar -C /usr/local -Jxf zig-x86_64-linux-0.14.1.tar.xz
|
|
echo "PATH=$PATH:/usr/local/zig-x86_64-linux-0.14.1" >> $GITHUB_ENV
|
|
|
|
- name: Build binary
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: 1
|
|
CC: zig cc -target ${{ matrix.zig_target_triple }}
|
|
GIN_MODE: release
|
|
run: |
|
|
BINARY_NAME=komari-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
# Append the appropriate executable extension based on the OS
|
|
if [ "${{ matrix.binary_extension }}" != "" ]; then
|
|
BINARY_NAME=${BINARY_NAME}${{ matrix.binary_extension }}
|
|
fi
|
|
VERSION="${{ github.sha }}"
|
|
VERSION_HASH="${{ github.sha }}"
|
|
go build -trimpath -ldflags="-s -w -X github.com/komari-monitor/komari/internal/conf.Version=${VERSION} -X github.com/komari-monitor/komari/internal/conf.CommitHash=${VERSION_HASH}" -o $BINARY_NAME
|
|
|
|
- name: Upload binary as artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: komari-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
path: komari-${{ matrix.goos }}-${{ matrix.goarch }}*
|