更新 .gitea/workflows/build.yaml
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Failing after 26s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 6, linux, client, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, windows, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, true) (push) Has been skipped
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Failing after 26s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 6, linux, client, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, windows, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, true) (push) Has been skipped
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
name: Build Multi-Platform Binaries
|
name: Build Multi-Platform Binaries
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
@@ -9,125 +10,169 @@ on:
|
|||||||
- '.gitea/workflows/**'
|
- '.gitea/workflows/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# =======================
|
||||||
|
# Frontend Build
|
||||||
|
# =======================
|
||||||
build-frontend:
|
build-frontend:
|
||||||
runs-on: node-latest # 使用 Node.js 专用镜像
|
runs-on: node-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build Frontend
|
- name: Build Frontend
|
||||||
run: |
|
run: |
|
||||||
cd web
|
cd web
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: Upload Frontend Artifact
|
- name: Upload Frontend Artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: frontend-dist
|
name: frontend-dist
|
||||||
path: web/dist
|
path: web/dist
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
|
# =======================
|
||||||
|
# Backend Build Matrix
|
||||||
|
# =======================
|
||||||
build-binaries:
|
build-binaries:
|
||||||
needs: build-frontend
|
needs: build-frontend
|
||||||
runs-on: golang-latest # 使用 Golang 专用镜像
|
runs-on: golang-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
# ---------- Linux amd64 ----------
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: amd64
|
goarch: amd64
|
||||||
target: server
|
target: server
|
||||||
upx: true
|
upx: true
|
||||||
|
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: amd64
|
goarch: amd64
|
||||||
target: client
|
target: client
|
||||||
upx: true
|
upx: true
|
||||||
|
|
||||||
|
# ---------- Linux arm64 ----------
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
target: server
|
target: server
|
||||||
upx: true
|
upx: true
|
||||||
|
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
target: client
|
target: client
|
||||||
upx: true
|
upx: true
|
||||||
|
|
||||||
|
# ---------- Linux ARMv7 / ARMv8l ----------
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 7
|
||||||
|
target: server
|
||||||
|
upx: false
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 7
|
||||||
|
target: client
|
||||||
|
upx: false
|
||||||
|
|
||||||
|
# ---------- (Optional) ARMv6 ----------
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 6
|
||||||
|
target: client
|
||||||
|
upx: false
|
||||||
|
|
||||||
|
# ---------- macOS ----------
|
||||||
- goos: darwin
|
- goos: darwin
|
||||||
goarch: amd64
|
goarch: amd64
|
||||||
target: server
|
target: server
|
||||||
upx: false
|
upx: false
|
||||||
- goos: darwin
|
|
||||||
goarch: amd64
|
|
||||||
target: client
|
|
||||||
upx: false
|
|
||||||
- goos: darwin
|
- goos: darwin
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
target: server
|
target: server
|
||||||
upx: false
|
upx: false
|
||||||
- goos: darwin
|
|
||||||
goarch: arm64
|
# ---------- Windows ----------
|
||||||
target: client
|
|
||||||
upx: false
|
|
||||||
- goos: windows
|
- goos: windows
|
||||||
goarch: amd64
|
goarch: amd64
|
||||||
target: server
|
target: server
|
||||||
upx: true
|
upx: true
|
||||||
|
|
||||||
- goos: windows
|
- goos: windows
|
||||||
goarch: amd64
|
goarch: amd64
|
||||||
target: client
|
target: client
|
||||||
upx: true
|
upx: true
|
||||||
|
|
||||||
- goos: windows
|
- goos: windows
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
target: server
|
target: server
|
||||||
upx: true
|
upx: true
|
||||||
|
|
||||||
- goos: windows
|
- goos: windows
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
target: client
|
target: client
|
||||||
upx: true
|
upx: true
|
||||||
|
|
||||||
steps:
|
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
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# ---------- Download frontend ----------
|
||||||
- name: Download Frontend Artifact
|
- name: Download Frontend Artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: frontend-dist
|
name: frontend-dist
|
||||||
path: internal/server/app/dist
|
path: internal/server/app/dist
|
||||||
|
|
||||||
|
# ---------- Build ----------
|
||||||
- name: Build Binary
|
- name: Build Binary
|
||||||
env:
|
env:
|
||||||
GOOS: ${{ matrix.goos }}
|
GOOS: ${{ matrix.goos }}
|
||||||
GOARCH: ${{ matrix.goarch }}
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
GOARM: ${{ matrix.goarm }}
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
run: |
|
run: |
|
||||||
|
set -e
|
||||||
|
|
||||||
OUTPUT_NAME="${{ matrix.target }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
OUTPUT_NAME="${{ matrix.target }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
||||||
|
|
||||||
|
if [ "${{ matrix.goarch }}" = "arm" ]; then
|
||||||
|
OUTPUT_NAME="${OUTPUT_NAME}v${{ matrix.goarm }}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${{ matrix.goos }}" = "windows" ]; then
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||||
OUTPUT_NAME="${OUTPUT_NAME}.exe"
|
OUTPUT_NAME="${OUTPUT_NAME}.exe"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
go build -ldflags="-s -w" -o "${OUTPUT_NAME}" ./cmd/${{ matrix.target }}
|
echo "Building $OUTPUT_NAME"
|
||||||
echo "BINARY_NAME=${OUTPUT_NAME}" >> $GITHUB_ENV
|
|
||||||
|
go build \
|
||||||
|
-trimpath \
|
||||||
|
-ldflags="-s -w" \
|
||||||
|
-o "$OUTPUT_NAME" \
|
||||||
|
./cmd/${{ matrix.target }}
|
||||||
|
|
||||||
|
echo "BINARY_NAME=$OUTPUT_NAME" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# ---------- UPX (safe only) ----------
|
||||||
- name: Install and Run UPX
|
- name: Install and Run UPX
|
||||||
if: matrix.upx == true
|
if: matrix.upx == true && matrix.goarch != 'arm'
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache upx || apt-get update && apt-get install -y upx-ucl
|
if command -v apk >/dev/null; then
|
||||||
|
apk add --no-cache upx
|
||||||
|
else
|
||||||
|
apt-get update && apt-get install -y upx-ucl
|
||||||
|
fi
|
||||||
|
|
||||||
upx -9 "${{ env.BINARY_NAME }}" || true
|
upx -9 "${{ env.BINARY_NAME }}" || true
|
||||||
|
|
||||||
- name: Upload Individual Binary
|
# ---------- Upload ----------
|
||||||
uses: actions/upload-artifact@v3
|
- name: Upload Binary
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ env.BINARY_NAME }}
|
name: ${{ env.BINARY_NAME }}
|
||||||
path: ${{ env.BINARY_NAME }}
|
path: ${{ env.BINARY_NAME }}
|
||||||
|
|||||||
Reference in New Issue
Block a user