ci: 自动构建附件

This commit is contained in:
Akizon77
2025-07-03 14:06:19 +08:00
parent b18f79bf4e
commit 10baf9aa8a

50
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Build on Main
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
exclude:
- goos: windows
goarch: arm
- goos: darwin
goarch: 386
- goos: darwin
goarch: arm
goos: [windows, linux, darwin, freebsd]
goarch: [amd64, arm64, 386, arm]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
VERSION: ${{ github.sha }}
run: |
BINARY_NAME=komari-agent-${{ matrix.goos }}-${{ matrix.goarch }}
if [ "${{ matrix.goos }}" = "windows" ]; then
BINARY_NAME=${BINARY_NAME}.exe
fi
go build -trimpath -ldflags="-s -w -X github.com/komari-monitor/komari-agent/update.CurrentVersion=${VERSION}" -o $BINARY_NAME
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: komari-agent-${{ matrix.goos }}-${{ matrix.goarch }}
path: komari-agent-${{ matrix.goos }}-${{ matrix.goarch }}*