Peach: Local-first video metadata scraper and media manager.
fix(release): 适配 GitLab 安装更新验收与 PowerShell 输出路径
longmeidao9132adef794c
diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.mdindex c847fa2a1..226c0c87f 100644--- a/docs/OPERATIONS.md+++ b/docs/OPERATIONS.md@@ -57,6 +57,8 @@ Windows 原生 Runner 在深目录中检出项目时,需为 Git 启用 `core.lLinux 发布任务使用官方 uv Python 3.14 容器,并在获取制品工具前核对解释器版本;源码归档使用 `tarfile` 的 `data` 过滤器解压。CI 的 `.npm/` 与 `.uv-cache/` 属于生成缓存,不计入源码工作区变化。+Windows 安装覆盖与任务恢复验收允许 GitHub Actions,以及受保护版本标签上的 GitLab `smoke-windows` 作业;主机已有 Peach 安装登记时拒绝执行。所有程序、账本与任务夹具均放在临时目录,安装与卸载完成后核对登记清理。`fetch_cloudflared.ps1` 的相对输出路径按 PowerShell 当前工作位置解析,下载仍须通过固定 SHA-256 校验。+媒体工具源码可通过 `PEACH_SOURCE_CACHE_BASE` 指定 HTTPS 缓存入口,按 `<SHA-256>/<归档名>` 定位文件。标签流水线使用发布桶的 `_sources/` 前缀;维护者填充缓存前须核对锁文件的原始 SHA-256,缓存同样计入桶容量预算。下载缓存失败时尝试锁定的上游地址;任一来源的哈希不符立即拒绝,不能放宽清单。未配置缓存的对应源码包直接使用上游。可选的 `r2` 后端使用独立 Standard 桶与 HTTPS 自定义域名。`PEACH_R2_ACCESS_KEY_ID`、`PEACH_R2_SECRET_ACCESS_KEY`、`PEACH_R2_ENDPOINT` 放入受保护且隐藏的 CI 变量,环境作用域为 `release`;`PEACH_R2_BUCKET` 和 `PEACH_R2_PUBLIC_BASE` 指定发布目标。S3 传输复用 rclone,版本文件禁止覆盖;每份文件必须从公开入口完整下载并核对大小及 SHA-256 后,才更新公开版本索引和 Release 链接。diff --git a/docs/REUSE.md b/docs/REUSE.mdindex f1b0b488d..1233a0646 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -2,6 +2,8 @@## GitLab 与 R2 发布+Windows 构建路径解析复用 PowerShell 7 的原生 [`GetUnresolvedProviderPathFromPSPath`](https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.pathintrinsics.getunresolvedproviderpathfrompspath);以当前 PowerShell 工作位置解析尚未创建的文件,无新增依赖或安装体积。安装更新验收使用 GitLab 官方[预定义变量](https://docs.gitlab.com/ci/variables/predefined_variables/)识别受保护版本标签及指定作业,沿用 Windows 注册表的既有安装检查。离线 PowerShell 回归覆盖进程工作目录与脚本工作位置不同的输入;主机检查覆盖受保护作业、未知作业与既有安装登记。+GitLab API、CI 认证和 Release 创建复用官方 [glab 1.124.0](https://gitlab.com/gitlab-org/cli)(MIT,维护中);GitLab CI 的发布写入使用短期 `CI_JOB_TOKEN` 与官方 CI 自动登录。R2 的 S3 上传复用 [rclone 1.75.2](https://rclone.org/)(MIT,维护中),使用单桶对象读写凭据;版本文件不可覆盖,并由独立 HTTPS 下载校验 SHA-256。两者都是构建期 CLI,不进入应用运行时依赖。轻量安装器的 R2 优先与 GitHub 同版本回退复用 `standalone_update.download`、既有 HTTPX 和内置工具清单;每个来源分别验证大小与 SHA-256。发布后空缓存验收复用 `smoke_split_update.py` 与实际冻结程序的 `--installer-tools` 入口,不新增下载器或依赖。diff --git a/scripts/fetch_cloudflared.ps1 b/scripts/fetch_cloudflared.ps1index 284ae45c0..722eb8f4f 100644--- a/scripts/fetch_cloudflared.ps1+++ b/scripts/fetch_cloudflared.ps1@@ -11,7 +11,7 @@ if (-not $ManifestPath) {$ManifestPath = Join-Path $PSScriptRoot 'cloudflared-windows.json'}$Manifest = Get-Content -LiteralPath $ManifestPath -Raw -Encoding utf8 | ConvertFrom-Json-$Destination = [IO.Path]::GetFullPath($OutputPath)+$Destination = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputPath)$Parent = Split-Path -Parent $DestinationNew-Item -ItemType Directory -Path $Parent -Force | Out-Null$Temporary = Join-Path $Parent ('.cloudflared-' + [guid]::NewGuid().ToString('N') + '.tmp')diff --git a/scripts/smoke_update_tasks.py b/scripts/smoke_update_tasks.pyindex a842cc950..67a9078ac 100644--- a/scripts/smoke_update_tasks.py+++ b/scripts/smoke_update_tasks.py@@ -8,6 +8,7 @@ import http.cookiejarimport jsonimport osfrom pathlib import Path+import reimport shutilimport socketimport sqlite3@@ -18,7 +19,12 @@ from smoke_desktop import complete_first_run, smoke_directory, smoke_environmentdef validate_installer_host():- assert os.environ.get('GITHUB_ACTIONS') == 'true', '安装包验收只允许在干净的 Actions runner 上运行'+ gitlab_release = (os.environ.get('GITLAB_CI') == 'true'+ and os.environ.get('CI_JOB_NAME') == 'smoke-windows'+ and os.environ.get('CI_COMMIT_REF_PROTECTED') == 'true'+ and re.fullmatch(r'v[0-9]+\.[0-9]+\.[0-9]+', os.environ.get('CI_COMMIT_TAG', '')))+ assert os.environ.get('GITHUB_ACTIONS') == 'true' or gitlab_release, (+ '安装包验收仅允许 GitHub Actions 或受保护版本标签的 GitLab Windows 验收作业')import winregkey = r'Software\Microsoft\Windows\CurrentVersion\Uninstall\{02D9748A-78F6-4866-AC75-918177194DAB}_is1'try:diff --git a/tests/test_cloudflared_packaging.py b/tests/test_cloudflared_packaging.pyindex f3aa0c01b..97ff9eba3 100644--- a/tests/test_cloudflared_packaging.py+++ b/tests/test_cloudflared_packaging.py@@ -71,6 +71,23 @@ class CloudflaredFetchTests(unittest.TestCase):self.assertEqual(result.returncode, 0, result.stderr)self.assertEqual(self.destination.read_bytes(), b"pretend cloudflared")+ def test_relative_output_uses_the_powershell_location(self):+ project = self.root / 'project with spaces'+ project.mkdir()+ harness = self.root / 'fetch-from-location.ps1'+ harness.write_text(+ "param([string]$Project, [string]$Fetch, [string]$Source, [string]$Manifest)\n"+ "$ErrorActionPreference = 'Stop'\nSet-Location -LiteralPath $Project\n"+ "& $Fetch -OutputPath 'build/cloudflared.exe' -SourcePath $Source -ManifestPath $Manifest\n"+ "exit $LASTEXITCODE\n", encoding='utf-8')+ result = subprocess.run(+ [PWSH, '-NoProfile', '-File', str(harness), str(project), str(FETCH),+ str(self.source), str(self.manifest(self.digest))], cwd=self.root,+ capture_output=True, text=True, encoding='utf-8', timeout=120, check=False)+ self.assertEqual(result.returncode, 0, result.stderr)+ self.assertEqual((project / 'build/cloudflared.exe').read_bytes(), self.source.read_bytes())+ self.assertFalse((self.root / 'build/cloudflared.exe').exists())+def test_a_mismatched_hash_fails_and_leaves_nothing_behind(self):result = self.fetch("0" * 64)self.assertNotEqual(result.returncode, 0)diff --git a/tests/test_scripts.py b/tests/test_scripts.pyindex 934622994..9027a3a45 100644--- a/tests/test_scripts.py+++ b/tests/test_scripts.py@@ -213,6 +213,36 @@ class ProjectBoardTests(unittest.TestCase):class UpdateTaskSmokeTests(unittest.TestCase):+ @classmethod+ def setUpClass(cls):+ with mock.patch.dict(sys.modules, {'smoke_desktop': load_script('smoke_desktop')}):+ cls.script = load_script('smoke_update_tasks')++ def test_protected_gitlab_release_and_actions_require_an_unregistered_host(self):+ gitlab = {'GITLAB_CI': 'true', 'CI_JOB_NAME': 'smoke-windows',+ 'CI_COMMIT_REF_PROTECTED': 'true', 'CI_COMMIT_TAG': 'v1.2.3'}+ for environment in ({'GITHUB_ACTIONS': 'true'}, gitlab):+ with self.subTest(environment=environment), mock.patch.dict(os.environ, environment, clear=True):+ registry = SimpleNamespace(HKEY_CURRENT_USER=object(),+ OpenKey=mock.Mock(side_effect=FileNotFoundError))+ with mock.patch.dict(sys.modules, {'winreg': registry}):+ self.script.validate_installer_host()+ registry.OpenKey.assert_called_once()+ registry.OpenKey = mock.MagicMock()+ with mock.patch.dict(sys.modules, {'winreg': registry}), \+ self.assertRaisesRegex(AssertionError, '已有 Peach 安装登记'):+ self.script.validate_installer_host()++ def test_unprotected_or_unrecognized_jobs_cannot_run_installer_acceptance(self):+ gitlab = {'GITLAB_CI': 'true', 'CI_JOB_NAME': 'smoke-windows',+ 'CI_COMMIT_REF_PROTECTED': 'true', 'CI_COMMIT_TAG': 'v1.2.3'}+ for environment in ({}, {**gitlab, 'CI_COMMIT_REF_PROTECTED': 'false'},+ {**gitlab, 'CI_JOB_NAME': 'verify-windows'},+ {**gitlab, 'CI_COMMIT_TAG': ''}):+ with self.subTest(environment=environment), mock.patch.dict(os.environ, environment, clear=True), \+ self.assertRaisesRegex(AssertionError, '安装包验收仅允许'):+ self.script.validate_installer_host()+def test_dry_run_does_not_open_artifacts_or_create_installation_data(self):with mock.patch.dict(sys.modules, {'smoke_desktop': load_script('smoke_desktop')}):script = load_script('smoke_update_tasks')