mirror of
https://github.com/zhouxiaoka/autoclip.git
synced 2026-10-02 02:34:34 +08:00
ci(windows): 修复冒烟读注册表安装目录带引号;抽出共用脚本,可复用已有安装包重跑
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -218,46 +218,10 @@ jobs:
|
||||
name: autoclip-desktop-windows-x64
|
||||
path: new
|
||||
|
||||
- name: Install previous stable release
|
||||
run: |
|
||||
$prev = gh release view --repo $env:GITHUB_REPOSITORY --json tagName -q .tagName
|
||||
"PREV_TAG=$prev" >> $env:GITHUB_ENV
|
||||
gh release download $prev --repo $env:GITHUB_REPOSITORY --pattern '*x64-setup.exe' --dir old
|
||||
$installer = Get-ChildItem old\*x64-setup.exe | Select-Object -First 1
|
||||
$p = Start-Process $installer.FullName -ArgumentList '/S' -Wait -PassThru
|
||||
if ($p.ExitCode -ne 0) { throw "旧版 $prev 安装失败: $($p.ExitCode)" }
|
||||
$key = Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall |
|
||||
Get-ItemProperty | Where-Object DisplayName -like 'AutoClip*' | Select-Object -First 1
|
||||
if (-not $key) { throw '注册表里找不到 AutoClip 安装记录' }
|
||||
$dir = $key.InstallLocation
|
||||
if (-not $dir) { $dir = Split-Path ($key.UninstallString -replace '"','') }
|
||||
"INSTALL_DIR=$dir" >> $env:GITHUB_ENV
|
||||
"旧版 $prev 安装到 $dir($($key.DisplayVersion))"
|
||||
|
||||
- name: Simulate leftover backend holding _asyncio.pyd
|
||||
run: |
|
||||
$py = Join-Path $env:INSTALL_DIR 'resources\python\python.exe'
|
||||
$p = Start-Process $py -ArgumentList '-c', '"import asyncio, time; time.sleep(900)"' -PassThru -WindowStyle Hidden
|
||||
Start-Sleep 3
|
||||
if ($p.HasExited) { throw '模拟残留进程没起来' }
|
||||
"LOCK_PID=$($p.Id)" >> $env:GITHUB_ENV
|
||||
"残留 python.exe PID=$($p.Id)"
|
||||
|
||||
- name: Upgrade in place with the new installer
|
||||
- name: Upgrade over previous release and verify installed runtime
|
||||
run: |
|
||||
$installer = Get-ChildItem -Recurse new -Filter '*-setup.exe' | Select-Object -First 1
|
||||
$p = Start-Process $installer.FullName -ArgumentList '/S' -Wait -PassThru
|
||||
if ($p.ExitCode -ne 0) { throw "覆盖安装失败: $($p.ExitCode)" }
|
||||
if (Get-Process -Id $env:LOCK_PID -ErrorAction SilentlyContinue) { throw '安装器没有结束残留的 python.exe' }
|
||||
$marker = Join-Path $env:INSTALL_DIR 'resources\backend\core\local_origin_guard.py'
|
||||
if (-not (Test-Path $marker)) { throw '覆盖安装后仍是旧文件(新版文件没写进去)' }
|
||||
"从 $env:PREV_TAG 覆盖升级成功,残留进程已被安装器结束"
|
||||
|
||||
- name: Verify installed runtime
|
||||
run: |
|
||||
$res = Join-Path $env:INSTALL_DIR 'resources'
|
||||
& (Join-Path $res 'python\python.exe') -B scripts\verify_windows_install.py --resources $res --report windows-smoke.json
|
||||
if ($LASTEXITCODE -ne 0) { throw "安装后冒烟失败: $LASTEXITCODE" }
|
||||
./scripts/windows_upgrade_smoke.ps1 -NewInstaller $installer.FullName
|
||||
|
||||
- name: Upload smoke report
|
||||
if: always()
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# 只重跑 Windows 安装冒烟,复用某次 desktop-build 已经打好的安装包,不用再等 25 分钟构建。
|
||||
# 调冒烟脚本、复现安装问题时用。
|
||||
name: Windows Install Smoke
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
build_run_id:
|
||||
description: "desktop-build.yml 的 run id(其中 build-windows-x64 成功)"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
|
||||
jobs:
|
||||
smoke:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: pwsh
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Download installer from build run
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: autoclip-desktop-windows-x64
|
||||
path: new
|
||||
run-id: ${{ inputs.build_run_id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upgrade over previous release and verify installed runtime
|
||||
run: |
|
||||
$installer = Get-ChildItem -Recurse new -Filter '*-setup.exe' | Select-Object -First 1
|
||||
./scripts/windows_upgrade_smoke.ps1 -NewInstaller $installer.FullName
|
||||
|
||||
- name: Upload smoke report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-smoke-report
|
||||
path: windows-smoke.json
|
||||
if-no-files-found: ignore
|
||||
@@ -0,0 +1,60 @@
|
||||
# Windows 覆盖升级 + 安装后冒烟。desktop-build.yml 的 smoke-windows-x64 和 windows-install-smoke.yml 共用。
|
||||
#
|
||||
# pwsh scripts/windows_upgrade_smoke.ps1 -NewInstaller <本次构建的 setup.exe>
|
||||
#
|
||||
# 1. 静默安装上一个正式版(GitHub latest release,需要 GH_TOKEN)
|
||||
# 2. 用安装目录里的 python.exe 起一个进程占住 _asyncio.pyd,模拟旧版残留后端(#224)
|
||||
# 3. 静默覆盖安装新包:安装器必须结束残留进程,并写入新文件
|
||||
# 4. 用安装目录自带的 Python 跑 scripts/verify_windows_install.py
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$NewInstaller,
|
||||
[string]$Report = 'windows-smoke.json'
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$repo = $env:GITHUB_REPOSITORY
|
||||
|
||||
function Get-InstallDir {
|
||||
$key = Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall |
|
||||
Get-ItemProperty | Where-Object DisplayName -like 'AutoClip*' | Select-Object -First 1
|
||||
if (-not $key) { throw '注册表里找不到 AutoClip 安装记录' }
|
||||
# NSIS 写的 InstallLocation 带引号,例如 "C:\Users\<user>\AppData\Local\AutoClip Desktop"
|
||||
$dir = ($key.InstallLocation -replace '"', '').TrimEnd('\')
|
||||
if (-not $dir) { $dir = Split-Path ($key.UninstallString -replace '"', '') }
|
||||
if (-not (Test-Path (Join-Path $dir 'resources\python\python.exe'))) {
|
||||
throw "安装目录里找不到 resources\python\python.exe: $dir"
|
||||
}
|
||||
return @{ Dir = $dir; Version = $key.DisplayVersion }
|
||||
}
|
||||
|
||||
Write-Host '==> 安装上一个正式版'
|
||||
$prev = gh release view --repo $repo --json tagName -q .tagName
|
||||
gh release download $prev --repo $repo --pattern '*x64-setup.exe' --dir old --clobber
|
||||
$old = Get-ChildItem old\*x64-setup.exe | Select-Object -First 1
|
||||
$p = Start-Process $old.FullName -ArgumentList '/S' -Wait -PassThru
|
||||
if ($p.ExitCode -ne 0) { throw "旧版 $prev 安装失败: $($p.ExitCode)" }
|
||||
$install = Get-InstallDir
|
||||
Write-Host "旧版 $prev 安装到 $($install.Dir)($($install.Version))"
|
||||
|
||||
Write-Host '==> 模拟旧版残留后端占住 _asyncio.pyd'
|
||||
$py = Join-Path $install.Dir 'resources\python\python.exe'
|
||||
$lock = Start-Process $py -ArgumentList '-c', '"import asyncio, time; time.sleep(900)"' -PassThru -WindowStyle Hidden
|
||||
Start-Sleep 3
|
||||
if ($lock.HasExited) { throw '模拟残留进程没起来' }
|
||||
Write-Host "残留 python.exe PID=$($lock.Id)"
|
||||
|
||||
Write-Host '==> 静默覆盖安装新包'
|
||||
$p = Start-Process (Resolve-Path $NewInstaller).Path -ArgumentList '/S' -Wait -PassThru
|
||||
if ($p.ExitCode -ne 0) { throw "覆盖安装失败: $($p.ExitCode)" }
|
||||
if (Get-Process -Id $lock.Id -ErrorAction SilentlyContinue) {
|
||||
Stop-Process -Id $lock.Id -Force
|
||||
throw '安装器没有结束残留的 python.exe'
|
||||
}
|
||||
$install = Get-InstallDir
|
||||
$marker = Join-Path $install.Dir 'resources\backend\core\local_origin_guard.py'
|
||||
if (-not (Test-Path $marker)) { throw '覆盖安装后仍是旧文件(新版文件没写进去)' }
|
||||
Write-Host "从 $prev 覆盖升级到 $($install.Version) 成功,残留进程已被安装器结束"
|
||||
|
||||
Write-Host '==> 安装后运行时冒烟'
|
||||
$res = Join-Path $install.Dir 'resources'
|
||||
& (Join-Path $res 'python\python.exe') -B scripts\verify_windows_install.py --resources $res --report $Report
|
||||
if ($LASTEXITCODE -ne 0) { throw "安装后冒烟失败: $LASTEXITCODE" }
|
||||
Reference in New Issue
Block a user