hi-client/.github/workflows/build-windows.yml
shanshanzhong 961c655a92
Some checks failed
Build Android APK / 编译 libcore.aar (push) Failing after 10s
Build Android APK / 编译 Android APK (release) (push) Has been skipped
Build Multi-Platform / 编译 libcore (iOS/tvOS) (push) Failing after 9s
Build Windows / 编译 libcore (Windows) (push) Failing after 5s
Build Windows / build (push) Has been skipped
Build Multi-Platform / 构建 Android APK (push) Has been cancelled
Build Multi-Platform / 构建 Windows (push) Has been cancelled
Build Multi-Platform / 构建 macOS (push) Has been cancelled
Build Multi-Platform / 构建 Linux (push) Has been cancelled
Build Multi-Platform / 构建 iOS (push) Has been cancelled
Build Multi-Platform / 创建 Release (push) Has been cancelled
Build Android APK / 创建 GitHub Release (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Android) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Windows) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (macOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Linux) (push) Has been cancelled
docs(workflow): 更新Windows构建工作流的注释
2025-11-05 23:33:09 -08:00

171 lines
5.1 KiB
YAML
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Build Windows
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
jobs:
# 先编译 libcore
build-libcore:
name: 编译 libcore (Windows)
runs-on: client-server
steps:
- name: 📥 Checkout 代码
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 🔧 设置 Go 环境
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: libcore/go.sum
- name: 🔧 安装 MinGW
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64
- name: 📦 编译 libcore.dll
working-directory: libcore
run: |
echo "🚀 开始编译 Windows libcore..."
make windows-amd64
if [ -f "bin/libcore.dll" ] && [ -f "bin/HiddifyCli.exe" ]; then
echo "✅ Windows libcore 编译成功"
ls -lh bin/
else
echo "❌ Windows libcore 编译失败"
exit 1
fi
- name: 📤 上传 Windows libcore
uses: actions/upload-artifact@v4
with:
name: libcore-windows
path: |
libcore/bin/libcore.dll
libcore/bin/HiddifyCli.exe
libcore/bin/webui/**
retention-days: 7
# 构建 Windows 应用1
build:
runs-on: windows-latest
needs: build-libcore
# 新增:设置 job 级 PATH让所有 steps 都能访问 Node.js
env:
PATH: ${{ github.workspace }}\node;${{ env.PATH }}
steps:
# 新增:引导步骤,下载并设置 Node.js便携版无需全局安装
- name: 🔧 Setup Node.js
shell: pwsh
run: |
$nodeVersion = "22.9.0" # 可调整为其他 LTS 版本,如 "20.17.0"
$zipUrl = "https://nodejs.org/dist/v${nodeVersion}/node-v${nodeVersion}-win-x64.zip"
$zipPath = Join-Path $env:GITHUB_WORKSPACE "node.zip"
$nodeDir = Join-Path $env:GITHUB_WORKSPACE "node"
# 创建目录
New-Item -ItemType Directory -Force -Path $nodeDir | Out-Null
# 下载 ZIP
Write-Host "Downloading Node.js from $zipUrl"
Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath
# 解压
Expand-Archive -Path $zipPath -DestinationPath $nodeDir -Force
Remove-Item $zipPath
# 验证(此时 PATH 已包含 $nodeDir所以能直接调用
Write-Host "Node.js version: $(& "$nodeDir\node.exe" --version)"
Write-Host "npm version: $(& "$nodeDir\npm.cmd" --version)"
Write-Host "Node.js installed to: $nodeDir"
- name: 📥 Checkout 代码
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 📥 下载 libcore
uses: actions/download-artifact@v4
with:
name: libcore-windows
path: .
- name: 🔧 复制 libcore 文件到正确位置并重命名
run: |
Write-Host "📋 复制 libcore 文件..."
# 创建目标目录
New-Item -ItemType Directory -Force -Path libcore\bin
# 查找并复制 HiddifyCli.exe重命名为 BearVPNCli.exe
$exeFiles = Get-ChildItem -Recurse -Filter "HiddifyCli.exe" -ErrorAction SilentlyContinue
if ($exeFiles) {
$sourceExe = $exeFiles[0].FullName
Write-Host "✅ 找到 HiddifyCli.exe: $sourceExe"
Write-Host "📝 复制并重命名为 BearVPNCli.exe"
Copy-Item $sourceExe libcore\bin\BearVPNCli.exe
Write-Host "✅ 重命名完成HiddifyCli.exe → BearVPNCli.exe"
} else {
Write-Host "⚠️ 未找到 HiddifyCli.exe"
}
# 复制 libcore.dll
$dllFiles = Get-ChildItem -Recurse -Filter "libcore.dll" -ErrorAction SilentlyContinue
if ($dllFiles) {
$sourceDll = $dllFiles[0].FullName
Write-Host "✅ 找到 libcore.dll: $sourceDll"
Copy-Item $sourceDll libcore\bin\libcore.dll
} else {
Write-Host "⚠️ 未找到 libcore.dll"
}
Write-Host ""
Write-Host "📄 验证文件:"
if (Test-Path libcore\bin) {
Get-ChildItem libcore\bin\ -ErrorAction SilentlyContinue | Format-Table Name, Length
}
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.5'
channel: 'stable'
- name: Enable Windows desktop
run: flutter config --enable-windows-desktop
- name: Get dependencies
run: flutter pub get
- name: Generate code
run: dart run build_runner build --delete-conflicting-outputs
- name: Build Windows Debug
run: flutter build windows
- name: Build Windows Release
run: flutter build windows --release
- name: Upload Debug build artifacts
uses: actions/upload-artifact@v4
with:
name: windows-debug-build
path: build/windows/runner/Debug/
- name: Upload Release build artifacts
uses: actions/upload-artifact@v4
with:
name: windows-release-build
path: build/windows/runner/Release/