Files
hi-client/.gitea/workflows/docker.yml
T
shanshanzhong147 577327c40a
Build Windows / ACT Windows Checkout Verification (push) Failing after 7h0m13s
Build Windows / 编译 libcore (Windows) (20.15.1) (push) Failing after 15s
Build Windows / build (push) Has been skipped
ci(workflow): 修复 git extraheader 配置并添加 jq 安装检查
移除 git 配置中的 extraheader 以避免潜在问题
添加 jq 安装检查并在缺失时通过 Chocolatey 安装
2025-11-07 04:50:51 -08:00

308 lines
9.6 KiB
YAML

name: Build Windows
run-name: 构建Win流程
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
# 先编译 libcore
build-libcore:
name: 编译 libcore (Windows)
runs-on: client-server
container:
image: node:20
strategy:
matrix:
# 只有node支持版本号别名
node: ['20.15.1']
steps:
- name: 📥 Checkout 代码
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 🔧 Fix Git Extra Header
shell: powershell
run: |
# 移除可能的 extraheader 配置,包括带 %0A 的变体
git config --global --unset-all http.https://git.kxsw.us/.extraheader
git config --global --unset-all http."https://git.kxsw.us/".extraheader
git config --global --unset-all http.https://git.kxsw.us/.extraheader%0A
git config --global --unset-all http."https://git.kxsw.us/".extraheader%0A
# 对于 submodule
git submodule foreach --recursive "git config --local --unset-all http.https://git.kxsw.us/.extraheader || true"
git submodule foreach --recursive "git config --local --unset-all http.https://git.kxsw.us/.extraheader%0A || true"
# 验证
git config --global --get-regexp http.*.extraheader || echo "No extraheader found"
- name: 🔧 设置 Go 环境
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: libcore/go.sum
- name: 🔧 安装 MinGW
run: |
# 在 GitHub 托管 runner(有 sudo)与 act/自托管容器(无 sudo)均可运行
if command -v sudo >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y mingw-w64
else
echo "sudo 不存在,按 root 用户直接执行 apt-get"
export DEBIAN_FRONTEND=noninteractive
apt-get update || apt update
apt-get install -y mingw-w64 || apt install -y mingw-w64
fi
- 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@v3
with:
name: libcore-windows
path: |
libcore/bin/libcore.dll
libcore/bin/HiddifyCli.exe
libcore/bin/webui/**
retention-days: 7
# 构建 Windows 应用
build:
runs-on: windows-latest
needs: build-libcore
steps:
- name: 🔧 Add Git to PATH (Windows)
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
$paths = @(
'C:\Program Files\Git\cmd',
'C:\Program Files\Git\bin',
'C:\Program Files (x86)\Git\cmd',
'C:\Program Files (x86)\Git\bin'
)
foreach ($p in $paths) {
if (Test-Path $p) {
Add-Content -Path $env:GITHUB_PATH -Value $p
$env:PATH = "$p;$env:PATH"
Write-Host ("Added to PATH: {0}" -f $p)
}
}
$candidates = @(
'C:\Program Files\Git\cmd\git.exe',
'C:\Program Files\Git\bin\git.exe',
'C:\Program Files (x86)\Git\cmd\git.exe',
'C:\Program Files (x86)\Git\bin\git.exe'
)
$found = $false
foreach ($g in $candidates) {
if (Test-Path $g) {
& $g --version
$found = $true
break
}
}
if (-not $found) {
Write-Host "Git executable not found in common locations; continuing."
}
- name: 📥 Checkout 代码
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 📥 下载 libcore
uses: actions/download-artifact@v3
with:
name: libcore-windows
path: .
- name: 🔧 复制 libcore 文件到正确位置并重命名
shell: cmd
run: call copy_libcore.bat
- 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@v3
with:
name: windows-debug-build
path: build/windows/runner/Debug/
- name: Upload Release build artifacts
uses: actions/upload-artifact@v3
with:
name: windows-release-build
path: build/windows/runner/Release/
# 本地(act)验证作业:只验证 Git PATH 与 checkout/submodules
build-act-windows:
name: ACT Windows Checkout Verification
if: ${{ env.ACT == 'true' }}
runs-on: windows-latest
steps:
- name: Add Git to PATH (Windows)
shell: powershell
run: |
$paths = @(
'C:\Program Files\Git\cmd',
'C:\Program Files\Git\bin',
'C:\Program Files (x86)\Git\cmd',
'C:\Program Files (x86)\Git\bin'
)
foreach ($p in $paths) {
if (Test-Path $p) {
Add-Content -Path $env:GITHUB_PATH -Value $p
$env:PATH = "$p;$env:PATH"
Write-Host ("Added to PATH: {0}" -f $p)
}
}
$candidates = @(
'C:\Program Files\Git\cmd\git.exe',
'C:\Program Files\Git\bin\git.exe',
'C:\Program Files (x86)\Git\cmd\git.exe',
'C:\Program Files (x86)\Git\bin\git.exe'
)
$found = $false
foreach ($g in $candidates) {
if (Test-Path $g) {
& $g --version
$found = $true
break
}
}
if (-not $found) {
Write-Host "Git executable not found in common locations; continuing."
}
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
persist-credentials: false
# 仅用于本地 act 验证:目录级稀疏检出,避免包含 Windows 非法文件
sparse-checkout: |
.github
lib
libcore
android
ios
windows
assets/core
assets/fonts
assets/translations
sparse-checkout-cone: true
- name: 🔧 Fix Git Extra Header (ACT)
shell: powershell
run: |
# 移除可能的 extraheader 配置,包括带 %0A 的变体
git config --global --unset-all http.https://git.kxsw.us/.extraheader
git config --global --unset-all http."https://git.kxsw.us/".extraheader
git config --global --unset-all http.https://git.kxsw.us/.extraheader%0A
git config --global --unset-all http."https://git.kxsw.us/".extraheader%0A
# 对于 submodule
git submodule foreach --recursive "git config --local --unset-all http.https://git.kxsw.us/.extraheader || true"
git submodule foreach --recursive "git config --local --unset-all http.https://git.kxsw.us/.extraheader%0A || true"
# 验证
git config --global --get-regexp http.*.extraheader || echo "No extraheader found"
- name: 🔍 Verify jq Installation (ACT)
shell: powershell
run: |
# 检查 jq 是否可用
$jqFound = $false
try {
$version = jq --version 2>&1
if ($version -match 'jq-[\d\.]+') {
Write-Host "✅ jq 已安装: $version"
$jqFound = $true
}
} catch {
Write-Host "❌ jq 未安装或不在 PATH 中"
}
if (-not $jqFound) {
Write-Host "⚠️ 准备安装 jq..."
# 检查 Chocolatey 是否可用
$chocoFound = $false
try {
choco --version 2>&1 | Out-Null
$chocoFound = $true
} catch {}
if (-not $chocoFound) {
Write-Host "📦 安装 Chocolatey..."
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# 刷新 PATH
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("PATH", "User")
Write-Host "✅ Chocolatey 安装完成"
}
Write-Host "📦 使用 Chocolatey 安装 jq..."
choco install jq -y
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ jq 安装成功"
# 再次验证
$version = jq --version 2>&1
Write-Host "✅ jq 版本: $version"
} else {
Write-Host "❌ jq 安装失败,退出码: $LASTEXITCODE"
exit 1
}
}
- name: Verify submodules
shell: powershell
continue-on-error: true
run: |
git --version
git submodule status
Write-Host "Submodules verified (status printed above)."
- name: Summary
shell: powershell
run: |
Write-Host "ACT Windows verification completed successfully."