All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 30s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, client, false) (push) Successful in 34s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 51s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 40s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m1s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 1m8s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 59s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, client, false) (push) Successful in 34s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 51s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 40s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m3s
Build Multi-Platform Binaries / build-binaries (arm64, windows, client, true) (push) Successful in 36s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, true) (push) Successful in 52s
133 lines
3.6 KiB
YAML
133 lines
3.6 KiB
YAML
name: Build Multi-Platform Binaries
|
|
on:
|
|
push:
|
|
paths:
|
|
- '**.go'
|
|
- 'go.mod'
|
|
- 'go.sum'
|
|
- 'web/**'
|
|
- '.gitea/workflows/**'
|
|
|
|
jobs:
|
|
build-frontend:
|
|
runs-on: node-latest # 使用 Node.js 专用镜像
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build Frontend
|
|
run: |
|
|
cd web
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Upload Frontend Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: frontend-dist
|
|
path: web/dist
|
|
retention-days: 1
|
|
|
|
build-binaries:
|
|
needs: build-frontend
|
|
runs-on: golang-latest # 使用 Golang 专用镜像
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- goos: linux
|
|
goarch: amd64
|
|
target: server
|
|
upx: true
|
|
- goos: linux
|
|
goarch: amd64
|
|
target: client
|
|
upx: true
|
|
- goos: linux
|
|
goarch: arm64
|
|
target: server
|
|
upx: true
|
|
- goos: linux
|
|
goarch: arm64
|
|
target: client
|
|
upx: true
|
|
- goos: darwin
|
|
goarch: amd64
|
|
target: server
|
|
upx: false
|
|
- goos: darwin
|
|
goarch: amd64
|
|
target: client
|
|
upx: false
|
|
- goos: darwin
|
|
goarch: arm64
|
|
target: server
|
|
upx: false
|
|
- goos: darwin
|
|
goarch: arm64
|
|
target: client
|
|
upx: false
|
|
- goos: windows
|
|
goarch: amd64
|
|
target: server
|
|
upx: true
|
|
- goos: windows
|
|
goarch: amd64
|
|
target: client
|
|
upx: true
|
|
- goos: windows
|
|
goarch: arm64
|
|
target: server
|
|
upx: true
|
|
- goos: windows
|
|
goarch: arm64
|
|
target: client
|
|
upx: true
|
|
steps:
|
|
- name: Install Node.js for Actions
|
|
run: |
|
|
# 尝试兼容 Alpine (apk) 和 Debian/Ubuntu (apt)
|
|
if command -v apk > /dev/null; then
|
|
apk add --no-cache nodejs
|
|
elif command -v apt-get > /dev/null; then
|
|
apt-get update && apt-get install -y nodejs
|
|
else
|
|
echo "Unknown package manager"
|
|
exit 1
|
|
fi
|
|
- name: Set Node IPv4 Priority
|
|
run: echo "NODE_OPTIONS=--dns-result-order=ipv4first" >> $GITHUB_ENV
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download Frontend Artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: frontend-dist
|
|
path: internal/server/app/dist
|
|
|
|
- name: Build Binary
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
OUTPUT_NAME="${{ matrix.target }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
|
OUTPUT_NAME="${OUTPUT_NAME}.exe"
|
|
fi
|
|
|
|
go build -ldflags="-s -w" -o "${OUTPUT_NAME}" ./cmd/${{ matrix.target }}
|
|
echo "BINARY_NAME=${OUTPUT_NAME}" >> $GITHUB_ENV
|
|
|
|
- name: Install and Run UPX
|
|
if: matrix.upx == true
|
|
run: |
|
|
apk add --no-cache upx || apt-get update && apt-get install -y upx-ucl
|
|
upx -9 "${{ env.BINARY_NAME }}" || true
|
|
|
|
- name: Upload Individual Binary
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ env.BINARY_NAME }}
|
|
path: ${{ env.BINARY_NAME }} |