1
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
This commit is contained in:
@@ -16,10 +16,19 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# 缓存 node_modules
|
||||||
|
- name: Cache Node modules
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: web/node_modules
|
||||||
|
key: node-modules-${{ hashFiles('web/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
node-modules-
|
||||||
|
|
||||||
- name: Build Frontend
|
- name: Build Frontend
|
||||||
run: |
|
run: |
|
||||||
cd web
|
cd web
|
||||||
npm ci
|
npm ci --prefer-offline --no-audit
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: Upload Frontend Artifact
|
- name: Upload Frontend Artifact
|
||||||
@@ -34,15 +43,14 @@ jobs:
|
|||||||
needs: build-frontend
|
needs: build-frontend
|
||||||
runs-on: golang-latest
|
runs-on: golang-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false # 即使某个平台失败,也继续构建其他平台
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
# Linux 平台
|
# Linux 平台
|
||||||
- { goos: linux, goarch: amd64, target: server, upx: true }
|
- { goos: linux, goarch: amd64, target: server, upx: true }
|
||||||
- { goos: linux, goarch: amd64, target: client, upx: true }
|
- { goos: linux, goarch: amd64, target: client, upx: true }
|
||||||
- { goos: linux, goarch: arm64, target: server, upx: true } # ARMv8 64-bit
|
- { goos: linux, goarch: arm64, target: server, upx: true }
|
||||||
- { goos: linux, goarch: arm64, target: client, upx: true }
|
- { goos: linux, goarch: arm64, target: client, upx: true }
|
||||||
# 针对 ARMv8 (v8l) 32位模式,使用 GOARM=7 确保最大兼容性
|
|
||||||
- { goos: linux, goarch: arm, goarm: 7, target: server, upx: true }
|
- { goos: linux, goarch: arm, goarm: 7, target: server, upx: true }
|
||||||
- { goos: linux, goarch: arm, goarm: 7, target: client, upx: true }
|
- { goos: linux, goarch: arm, goarm: 7, target: client, upx: true }
|
||||||
|
|
||||||
@@ -54,10 +62,10 @@ jobs:
|
|||||||
# Darwin (macOS) 平台
|
# Darwin (macOS) 平台
|
||||||
- { goos: darwin, goarch: amd64, target: server, upx: false }
|
- { goos: darwin, goarch: amd64, target: server, upx: false }
|
||||||
- { goos: darwin, goarch: arm64, target: server, upx: false }
|
- { goos: darwin, goarch: arm64, target: server, upx: false }
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# 关键步骤:在 checkout 之前安装 Node.js,否则 checkout@v4 会报错
|
# 在 checkout 前安装依赖
|
||||||
- name: Install Node.js & UPX
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
if command -v apk > /dev/null; then
|
if command -v apk > /dev/null; then
|
||||||
apk add --no-cache nodejs upx
|
apk add --no-cache nodejs upx
|
||||||
@@ -66,16 +74,31 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo "Unsupported package manager" && exit 1
|
echo "Unsupported package manager" && exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# 缓存 Go 模块
|
||||||
|
- name: Cache Go modules
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/go-build
|
||||||
|
~/go/pkg/mod
|
||||||
|
key: go-${{ runner.os }}-${{ hashFiles('go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
go-${{ runner.os }}-
|
||||||
|
|
||||||
|
# 下载依赖(只在缓存未命中时执行)
|
||||||
|
- name: Download Go dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
- name: Download Frontend Artifact
|
- name: Download Frontend Artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: frontend-dist
|
name: frontend-dist
|
||||||
path: internal/server/app/dist
|
path: internal/server/app/dist
|
||||||
|
|
||||||
- name: Build Binary
|
- name: Build Binary
|
||||||
env:
|
env:
|
||||||
GOOS: ${{ matrix.goos }}
|
GOOS: ${{ matrix.goos }}
|
||||||
@@ -83,33 +106,28 @@ jobs:
|
|||||||
GOARM: ${{ matrix.goarm }}
|
GOARM: ${{ matrix.goarm }}
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
run: |
|
run: |
|
||||||
# 处理文件名后缀
|
# 处理文件名
|
||||||
ARM_VAL=""
|
ARM_VAL=""
|
||||||
if [ "${{ matrix.goarch }}" = "arm" ]; then
|
[ "${{ matrix.goarch }}" = "arm" ] && ARM_VAL="v${{ matrix.goarm }}"
|
||||||
ARM_VAL="v${{ matrix.goarm }}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
EXT=""
|
EXT=""
|
||||||
if [ "${{ matrix.goos }}" = "windows" ]; then
|
[ "${{ matrix.goos }}" = "windows" ] && EXT=".exe"
|
||||||
EXT=".exe"
|
|
||||||
fi
|
|
||||||
|
|
||||||
FILENAME="gotunnel-${{ matrix.target }}-${{ matrix.goos }}-${{ matrix.goarch }}${ARM_VAL}${EXT}"
|
FILENAME="gotunnel-${{ matrix.target }}-${{ matrix.goos }}-${{ matrix.goarch }}${ARM_VAL}${EXT}"
|
||||||
|
|
||||||
# 执行编译
|
# 编译(使用 -trimpath 减小体积,利用缓存)
|
||||||
go build -ldflags="-s -w" -o "${FILENAME}" ./cmd/${{ matrix.target }}
|
go build -trimpath -ldflags="-s -w" -o "${FILENAME}" ./cmd/${{ matrix.target }}
|
||||||
|
|
||||||
# 记录文件名供后续步骤使用
|
|
||||||
echo "CURRENT_FILENAME=${FILENAME}" >> $GITHUB_ENV
|
echo "CURRENT_FILENAME=${FILENAME}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Run UPX Compression
|
- name: Run UPX Compression
|
||||||
if: matrix.upx == true
|
if: matrix.upx == true
|
||||||
run: |
|
run: |
|
||||||
# 尝试压缩,即使失败也不中断工作流(某些架构不支持 UPX)
|
upx --best --lzma "${{ env.CURRENT_FILENAME }}" || echo "UPX skipped for this platform"
|
||||||
upx -9 "${{ env.CURRENT_FILENAME }}" || echo "UPX skipped for this platform"
|
|
||||||
|
|
||||||
- name: Upload Binary
|
- name: Upload Binary
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ env.CURRENT_FILENAME }}
|
name: ${{ env.CURRENT_FILENAME }}
|
||||||
path: ${{ env.CURRENT_FILENAME }}
|
path: ${{ env.CURRENT_FILENAME }}
|
||||||
|
retention-days: 7
|
||||||
Reference in New Issue
Block a user