更新 .gitea/workflows/build.yaml
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Successful in 57s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, client, false) (push) Failing after 50s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, client, false) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, windows, client, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, true) (push) Failing after 4s
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Successful in 57s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, client, false) (push) Failing after 50s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, client, false) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, windows, client, true) (push) Failing after 4s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, true) (push) Failing after 4s
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
name: Build Multi-Platform Binaries
|
name: Build Multi-Platform Binaries
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
@@ -10,85 +9,111 @@ on:
|
|||||||
- '.gitea/workflows/**'
|
- '.gitea/workflows/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-frontend:
|
||||||
runs-on: ubuntu-latest
|
runs-on: node-latest # 使用 Node.js 专用镜像
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.24'
|
|
||||||
cache: true
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
cache: 'npm'
|
|
||||||
cache-dependency-path: web/package-lock.json
|
|
||||||
|
|
||||||
- name: Build Frontend
|
- name: Build Frontend
|
||||||
run: |
|
run: |
|
||||||
cd web
|
cd web
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: Copy Frontend to Embed Path
|
- name: Upload Frontend Artifact
|
||||||
run: cp -r web/dist internal/server/app/dist
|
|
||||||
|
|
||||||
- name: Install UPX
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y upx-ucl
|
|
||||||
|
|
||||||
- name: Build all platforms
|
|
||||||
run: |
|
|
||||||
mkdir -p dist
|
|
||||||
|
|
||||||
# Linux amd64
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/server-linux-amd64 ./cmd/server
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/client-linux-amd64 ./cmd/client
|
|
||||||
|
|
||||||
# Linux arm64
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/server-linux-arm64 ./cmd/server
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/client-linux-arm64 ./cmd/client
|
|
||||||
|
|
||||||
# Darwin amd64
|
|
||||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/server-darwin-amd64 ./cmd/server
|
|
||||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/client-darwin-amd64 ./cmd/client
|
|
||||||
|
|
||||||
# Darwin arm64
|
|
||||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/server-darwin-arm64 ./cmd/server
|
|
||||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/client-darwin-arm64 ./cmd/client
|
|
||||||
|
|
||||||
# Windows amd64
|
|
||||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/server-windows-amd64.exe ./cmd/server
|
|
||||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" \
|
|
||||||
-o dist/client-windows-amd64.exe ./cmd/client
|
|
||||||
|
|
||||||
- name: Compress with UPX
|
|
||||||
run: |
|
|
||||||
# UPX 压缩 Linux 和 Windows 二进制 (macOS 不支持)
|
|
||||||
upx -9 dist/server-linux-amd64 dist/client-linux-amd64 || true
|
|
||||||
upx -9 dist/server-linux-arm64 dist/client-linux-arm64 || true
|
|
||||||
upx -9 dist/server-windows-amd64.exe dist/client-windows-amd64.exe || true
|
|
||||||
|
|
||||||
- name: List artifacts
|
|
||||||
run: ls -lah dist/
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: gotunnel-binaries
|
name: frontend-dist
|
||||||
path: 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: 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 }}
|
||||||
Reference in New Issue
Block a user