From d0eec8e5d1f7a2203039c02f265621131274a9c6 Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Fri, 23 Oct 2026 01:43:31 +0800 Subject: [PATCH 1/4] Gate desktop releases on verified packages and publisher signatures Re-enable scoped engineering builds for the existing platform matrix, add native smoke checks and signature evidence, preserve manual update semantics, and keep unreleased artifacts out of generated download catalogs. --- .github/workflows/ci.yml | 1 + .github/workflows/desktop-release.yml | 79 +++++++++- .github/workflows/release-docs.yml | 2 +- docs/desktop-release-status.md | 59 ++++++++ docs/desktop.md | 49 ++++-- docs/downloads.md | 3 +- scripts/desktop-signing.py | 201 +++++++++++++++++++++++++ scripts/release.py | 144 ++++++++++++++++-- static/downloads.json | 205 ++++++++++++++++++++++++++ tests/desktop-signing.test.py | 116 +++++++++++++++ tests/release.test.py | 74 +++++++++- 11 files changed, 907 insertions(+), 26 deletions(-) create mode 100644 docs/desktop-release-status.md create mode 100644 scripts/desktop-signing.py create mode 100644 static/downloads.json create mode 100644 tests/desktop-signing.test.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ad96be..f7153af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,7 @@ jobs: run: | python3 tests/cli-scripts.test.py python3 tests/release.test.py + python3 tests/desktop-signing.test.py python3 tests/aur.test.py python3 scripts/release.py docs --check diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml index 2e31137..c7c0183 100644 --- a/.github/workflows/desktop-release.yml +++ b/.github/workflows/desktop-release.yml @@ -3,7 +3,26 @@ name: Desktop and CLI packages on: push: tags: ['desktop-v*'] + pull_request: + paths: + - 'desktop/**' + - 'packaging/flatpak/**' + - 'packaging/aur/**' + - 'release/**' + - 'scripts/release.py' + - 'scripts/desktop-signing.py' + - 'scripts/aur.py' + - 'scripts/package-flatpak.sh' + - 'tests/release.test.py' + - 'tests/desktop-signing.test.py' + - 'tests/aur.test.py' + - '.github/workflows/desktop-release.yml' workflow_dispatch: + inputs: + require_signing: + description: Require real Windows publisher signing and macOS Developer ID notarization (does not publish) + type: boolean + default: false permissions: contents: read @@ -32,6 +51,8 @@ jobs: - name: Verify catalog, generated docs and package boundaries run: | python3 tests/release.test.py + python3 tests/desktop-signing.test.py + python3 tests/aur.test.py python3 scripts/release.py docs --check bash -n scripts/package-flatpak.sh cargo fmt --manifest-path desktop/src-tauri/Cargo.toml -- --check @@ -70,11 +91,31 @@ jobs: matrix: ${{ fromJSON(needs.prepare.outputs.desktop) }} runs-on: ${{ matrix.runner }} timeout-minutes: 60 + env: + # PR code never receives signing secrets. Tag releases always require them. + DESKTOP_REQUIRE_SIGNATURES: ${{ github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) }} + WINDOWS_CERTIFICATE: ${{ matrix.platform == 'Windows' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.WINDOWS_CERTIFICATE || '' }} + WINDOWS_CERTIFICATE_PASSWORD: ${{ matrix.platform == 'Windows' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.WINDOWS_CERTIFICATE_PASSWORD || '' }} + WINDOWS_CERTIFICATE_THUMBPRINT: ${{ matrix.platform == 'Windows' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.WINDOWS_CERTIFICATE_THUMBPRINT || '' }} + WINDOWS_TIMESTAMP_URL: ${{ matrix.platform == 'Windows' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && vars.WINDOWS_TIMESTAMP_URL || '' }} + APPLE_CERTIFICATE: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_CERTIFICATE || '' }} + APPLE_CERTIFICATE_PASSWORD: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_CERTIFICATE_PASSWORD || '' }} + APPLE_SIGNING_IDENTITY: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_SIGNING_IDENTITY || '' }} + APPLE_ID: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_ID || '' }} + APPLE_PASSWORD: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_PASSWORD || '' }} + APPLE_TEAM_ID: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_TEAM_ID || '' }} + APPLE_API_ISSUER: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_API_ISSUER || '' }} + APPLE_API_KEY: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_API_KEY || '' }} + APPLE_API_KEY_BASE64: ${{ matrix.platform == 'macOS' && github.event_name != 'pull_request' && (github.ref_type == 'tag' || inputs.require_signing == true) && secrets.APPLE_API_KEY_BASE64 || '' }} defaults: run: shell: bash steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - name: Check required signing credentials before building + env: + TARGET: ${{ matrix.target }} + run: python3 scripts/desktop-signing.py configure --target "$TARGET" --out "$RUNNER_TEMP/desktop-signing.json" - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 with: node-version: '24' @@ -117,7 +158,15 @@ jobs: TARGET: ${{ matrix.target }} BUNDLES: ${{ matrix.bundles }} APPIMAGE_EXTRACT_AND_RUN: '1' - run: npm run tauri -- build --ci --target "$TARGET" --bundles "$BUNDLES" -- --locked + run: | + # Empty secrets must be absent: Tauri treats set-but-empty Apple env + # variables as supplied signing inputs on some paths. + for name in APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD APPLE_SIGNING_IDENTITY \ + APPLE_ID APPLE_PASSWORD APPLE_TEAM_ID APPLE_API_ISSUER APPLE_API_KEY APPLE_API_KEY_PATH; do + if [[ -z ${!name:-} ]]; then unset "$name"; fi + done + unset WINDOWS_CERTIFICATE WINDOWS_CERTIFICATE_PASSWORD APPLE_API_KEY_BASE64 + npm run tauri -- build --ci --target "$TARGET" --bundles "$BUNDLES" --config "$RUNNER_TEMP/desktop-signing.json" -- --locked - name: Start the Linux desktop launcher under a real WebKit view if: runner.os == 'Linux' env: @@ -125,12 +174,27 @@ jobs: run: | dbus-run-session -- xvfb-run -a \ "desktop/src-tauri/target/$TARGET/release/hireferry-desktop" --smoke-test + - name: Start the Windows or macOS launcher under its native WebView + if: runner.os != 'Linux' + env: + TARGET: ${{ matrix.target }} + run: | + python3 - <<'PY' + import os, pathlib, subprocess, sys + suffix = '.exe' if sys.platform == 'win32' else '' + binary = pathlib.Path('desktop/src-tauri/target')/os.environ['TARGET']/'release'/('hireferry-desktop'+suffix) + subprocess.run([str(binary.resolve()), '--smoke-test'], check=True, timeout=45) + PY - name: Normalize packages and record checksums env: TARGET: ${{ matrix.target }} run: | python3 scripts/release.py stage-desktop --target "$TARGET" \ --bundle-dir "desktop/src-tauri/target/$TARGET/release/bundle" --out dist/desktop + python3 scripts/desktop-signing.py verify --target "$TARGET" --directory dist/desktop + - name: Delete temporary notarization key + if: always() + run: rm -f "$RUNNER_TEMP/hireferry-notary-key.p8" "$RUNNER_TEMP/desktop-signing.json" - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: desktop-release-${{ matrix.target }} @@ -199,9 +263,10 @@ jobs: - name: Validate every required package and generate Markdown, SVG and JSON env: RELEASE_TAG: ${{ needs.prepare.outputs.tag }} + DISTRIBUTION: ${{ github.event_name == 'push' && github.ref_type == 'tag' && 'release' || 'engineering' }} run: | python3 scripts/release.py assemble artifacts/release dist/release \ - --tag "$RELEASE_TAG" --repository "$GITHUB_REPOSITORY" --commit "$GITHUB_SHA" + --tag "$RELEASE_TAG" --repository "$GITHUB_REPOSITORY" --commit "$GITHUB_SHA" --distribution "$DISTRIBUTION" - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: complete-desktop-release @@ -218,6 +283,7 @@ jobs: permissions: contents: write steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: complete-desktop-release @@ -228,7 +294,7 @@ jobs: GH_REPO: ${{ github.repository }} RELEASE_TAG: ${{ needs.prepare.outputs.tag }} run: | - (cd dist/release && sha256sum -c SHA256SUMS) + python3 scripts/release.py verify-publication dist/release state=$(gh release view "$RELEASE_TAG" --json isDraft --jq .isDraft 2>/dev/null || printf missing) if [[ "$state" == false ]]; then echo 'This release is already published; bump the desktop version.' >&2 @@ -248,3 +314,10 @@ jobs: uses: ./.github/workflows/release-docs.yml with: tag: ${{ needs.prepare.outputs.tag }} + + update-aur: + needs: [prepare, publish] + uses: ./.github/workflows/aur.yml + secrets: inherit + with: + tag: ${{ needs.prepare.outputs.tag }} diff --git a/.github/workflows/release-docs.yml b/.github/workflows/release-docs.yml index c5af563..85ebe4a 100644 --- a/.github/workflows/release-docs.yml +++ b/.github/workflows/release-docs.yml @@ -67,7 +67,7 @@ jobs: run: | git config user.name 'github-actions[bot]' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' - git add docs/downloads.md docs/assets/release-matrix.svg release/latest.json + git add docs/downloads.md docs/assets/release-matrix.svg release/latest.json static/downloads.json if git diff --cached --quiet; then exit 0; fi git commit -m "docs: refresh download matrix for $RELEASE_TAG" git pull --rebase origin "$DEFAULT_BRANCH" diff --git a/docs/desktop-release-status.md b/docs/desktop-release-status.md new file mode 100644 index 0000000..49b3b86 --- /dev/null +++ b/docs/desktop-release-status.md @@ -0,0 +1,59 @@ +# 桌面发行验收记录 + +本记录于 **2026-10-22 UTC** 核对,用来区分已发布软件包、已完成的工程验证和仍需真实凭据完成的发布条件。持续更新的正式下载入口是 [下载矩阵](downloads.md),其数据来自仓库的 `release/latest.json`。 + +## 当前正式产品入口 + +| 产品 | 核对时的正式版本 | 已发布资产 | +| --- | --- | --- | +| hfy CLI | [0.1.3](https://github.com/TokenNotIncluded/hireferry/releases/tag/cli-v0.1.3) | Windows、macOS、Linux,各 x64 / ARM64,共 6 个归档 | +| 服务端 | [0.1.0](https://github.com/TokenNotIncluded/hireferry/releases/tag/server-v0.1.0) | Linux x64 / ARM64,共 2 个归档 | +| 桌面 GUI | 尚无正式 Release | 已有构建验证产物;临时 Actions artifact 不是正式发布入口 | +| 移动端 | 尚无正式 Release | 不列出未发布的 APK、IPA 或商店下载地址 | + +GitHub 仓库通用 `/releases/latest` 用于现有 CLI 安装器。桌面、服务端保持独立标签与下载入口;桌面发布使用 `--latest=false`,不会改变 CLI 的 latest。 + +## 已经完成的一轮桌面工程构建 + +证据:[Desktop and CLI packages,run 39735931535](https://github.com/TokenNotIncluded/hireferry/actions/runs/39735931535),源码提交 `4bd3963c295e68960b00d7df51e878c000a2baea`。这是本次补齐之前的 PR 验证记录,不代表随后修改过的提交已经通过同样检查。 + +| 平台 / 架构 | 构建及单元测试 | 当时的原生界面启动验证 | 包格式 | +| --- | --- | --- | --- | +| Linux x64 | 通过 | WebKit 启动器通过 | `.deb`、`.rpm`、`.AppImage` | +| Linux ARM64 | 通过 | WebKit 启动器通过 | `.deb`、`.rpm`、`.AppImage` | +| Windows x64 | 通过 | 当时未运行 GUI smoke | NSIS `.exe`、`.msi` | +| Windows ARM64 | 通过 | 当时未运行 GUI smoke | NSIS `.exe` | +| macOS Intel x64 | 通过 | 当时未运行 GUI smoke | `.dmg`、`.app.tar.gz` | +| macOS Apple Silicon | 通过 | 当时未运行 GUI smoke | `.dmg`、`.app.tar.gz` | +| Flatpak x64 / ARM64 | 两者通过 | 运行时依赖、版本检查与启动器 smoke 通过 | 各一个 `.flatpak` | + +该轮完整产物汇总成功,发布 job 被跳过。构建未配置维护者的 Apple / Windows 证书,因此没有被记为平台发行签名通过。CI artifact 的有效期和可下载性由 GitHub 保留策略决定,文档不把它当作永久安装地址。 + +## 此次新增的验证门槛 + +- 相关路径 PR 自动运行六平台原生构建、单元测试、各自 WebView 启动器 smoke,以及两架构 Flatpak;Windows / macOS GUI smoke 是本次新增,只有新提交的工作流成功后才能在上表新增结果。 +- PR 与普通手动构建标记 `distribution=engineering`;工程清单禁止自动写入公开下载页或生成 AUR 二进制配方。PR 不接收签名 secrets。 +- `desktop-vX.Y.Z` 正式标签构建必须先通过凭据完整性检查,再实际验签最终包。Windows 要求有效 Authenticode 与时间戳;macOS 要求 Developer ID 签名和 stapler 验证,验证对象是最终 DMG 与 `.app.tar.gz` 内的应用。 +- 每个原生目标输出包含最终包名、大小、SHA-256、签名分类的报告。汇总再次检查报告与包字节一致;发布步骤再次验证完整目录,不允许工程清单转为正式发布。 +- Linux 报告明确为 `checksum-only`,不把完整性校验称作平台发布者签名。Flatpak 是单文件分发,不表示已经上架 Flathub。 +- AUR 验证工作流在 Arch `base-devel` 中以普通用户执行真实 `makepkg --printsrcinfo` 与配方文件安装边界测试;桌面 source 配方与 Release 二进制配方分别处理,后者只从正式清单取两个 Linux `.deb` 的校验和。 + +本地签名策略测试使用模拟的原生命令结果来验证拒绝条件,不代表已经有真实签名证书。此次环境只运行 Python 发布门槛测试、真实 makepkg 元数据生成和 bsdtar 文件安装测试;六平台运行与真实签名必须以对应 GitHub 工作流和最终包验签结果为准。 + +## 实际发布还需要什么 + +1. 本次最终提交的跨平台 PR 验证通过。此前成功 run 不能替代新提交的结果。 +2. 维护者提供可用的 Windows 签名证书、时间戳服务及 Apple Developer ID / 公证凭据。当前 PFX 接口适用于可导出证书;硬件或云签名需按提供商接入,不假设已存在账户。 +3. 按 [桌面发布说明](desktop.md)同步版本并触发正式标签工作流。只有完整、验签通过的产物才进入草稿、公开 Release、下载矩阵与 AUR binary 发布。 +4. 若采用移动端发行,还需独立的移动签名、平台账号及安装/商店渠道验收;桌面验签不能替代这些条件。 + +桌面当前采用下载新包后安装的手动更新路径。应用内 updater 没有配置,下载目录 JSON 也不是 updater feed。 + +## 官方协议与平台依据 + +- [Tauri Windows 安装包](https://v2.tauri.app/distribute/windows-installer/):NSIS / MSI 构建与 WebView2 选项。 +- [Tauri Windows 签名](https://v2.tauri.app/distribute/sign/windows/):平台签名、时间戳及硬件 / 云签名接入。 +- [Tauri macOS 签名与公证](https://v2.tauri.app/distribute/sign/macos/):Developer ID、证书与公证凭据。 +- [Apple 自定义公证流程](https://developer.apple.com/documentation/security/customizing-the-notarization-workflow):公证票据与 stapler 验证。 +- [Tauri updater](https://v2.tauri.app/plugin/updater/):独立更新签名和更新协议。 +- [Tauri AUR 分发](https://v2.tauri.app/distribute/aur/):源码与 Debian 二进制 payload 的 Arch 打包方式。 diff --git a/docs/desktop.md b/docs/desktop.md index 1ba9747..9cdfb61 100644 --- a/docs/desktop.md +++ b/docs/desktop.md @@ -8,6 +8,10 @@ `hfy` 是独立的用户端 CLI,不需要安装桌面版。服务器程序仍名为 `hireferry`,与桌面程序 `hireferry-desktop`、用户 CLI `hfy` 分开发布。 +## 当前可安装版本 + +下载入口以 [自动生成的下载矩阵](downloads.md) 为准。2026-10-22 核对时,正式 Release 为 **CLI 0.1.3、服务端 0.1.0**,尚无正式桌面 Release。六个平台已有一轮工程构建成功记录,但临时 CI artifact 不作为正式下载安装入口。详细证据和待验证项见 [桌面发行验收记录](desktop-release-status.md)。 + ## 选择安装包 | 系统 | 架构 | 桌面包 | 用户 CLI | @@ -29,7 +33,8 @@ Linux 使用多种包格式覆盖主流发行版系列,不能仅凭扩展名 | --- | --- | --- | | Ubuntu、Debian、Mint、Pop!_OS、Zorin、elementary | `.deb` | 原生构建基线 Ubuntu 22.04;需要 WebKitGTK 4.1。Debian 12 和提供相同依赖的后续版本可安装 | | Fedora、openSUSE、RHEL、Rocky、Alma | `.rpm`;必要时用 Flatpak | 安装器必须能满足所需库;旧企业发行版缺少 WebKitGTK 4.1 时使用 Flatpak | -| Arch、Manjaro、EndeavourOS、Gentoo | AppImage 或 Flatpak | 图形会话、宿主 glibc 与运行时需兼容;不是所有历史版本的兼容承诺 | +| Arch、Manjaro、EndeavourOS | AUR 源码配方;正式桌面发布后可用二进制配方 | 当前仓库提供 `hireferry-desktop-git`;AUR 上架状态及构建命令见 [AUR 指南](aur.md) | +| Gentoo | AppImage 或 Flatpak | 图形会话、宿主 glibc 与运行时需兼容;不是所有历史版本的兼容承诺 | | NixOS、SteamOS、不可变桌面 | Flatpak | 通过发行版配置安装 Flatpak、运行时及桌面 portal | | Alpine / musl | CLI 用 musl 压缩包;桌面使用可用的 Flatpak 环境 | glibc `.deb`、`.rpm` 和 AppImage 不适用于原生 musl 环境 | @@ -37,7 +42,7 @@ Tauri 2 原生 Linux 构建依赖 WebKitGTK 4.1。原生包在 **Ubuntu 22.04 Flatpak 使用独立共享运行时提供图形依赖,通过 `.flatpak` 附件分发。**生成 Flatpak 附件不表示已上架 Flathub。** 安装运行时需要可用的软件源;部分受限或旧系统需要先配置相应服务。参考 [Flatpak 安装帮助](https://flatpak.org/setup/)及 [Tauri Flatpak 文档](https://v2.tauri.app/distribute/flatpak/)。 -本仓库的 CI 验证构建、打包、包集合和校验信息;没有把每个发行版都实际运行过的结果记录为通过。32 位 x86、ARMv7 和 RISC-V 暂不在当前发布矩阵中。 +本仓库的 CI 验证六个平台构建、包集合、校验和与启动器加载;Linux 还在两个架构运行 Flatpak 启动检查。验收记录区分旧工作流已有的测试结果与本次新增检查,只有对应提交的工作流成功后才能计为通过。并没有把每个 Linux 发行版都记录为实机运行通过。32 位 x86、ARMv7 和 RISC-V 暂不在当前发布矩阵中。 ## 安装与校验 @@ -91,11 +96,20 @@ CLI 的一键安装、登录、升级与卸载见 [CLI 文档](cli.md)。它继 桌面窗口内可使用站点提供的邮箱验证码登录。Google 等第三方提供方可能拒绝嵌入式 WebView;系统浏览器与桌面窗口的会话也不自动共享。此版本没有加入浏览器 OAuth 会话回传桥接,使用此类登录时应在浏览器里继续访问站点。不要把“浏览器成功登录”误认为桌面窗口也已登录。 -桌面壳的更新通过下载新版本安装包完成,Flatpak 通过重新安装新附件更新。这里的“自动更新”指**发布文档和下载矩阵自动生成**,并没有配置未签名的应用内自动更新器。 +## 手动更新 + +桌面壳当前通过新安装包更新: + +1. 打开 [下载矩阵](downloads.md),选择“桌面版”对应 Release 和当前 CPU 架构。仓库通用 `releases/latest` 保留给 CLI,不是桌面更新入口。 +2. 下载该 Release 的安装包和 `SHA256SUMS`,按前面的命令校验。Windows、macOS 正式 Release 还必须通过发布工作流的原生签名与公证验证。 +3. 关闭桌面应用。Windows 运行新安装器;macOS 用新应用替换 Applications 中的旧版本;Linux 使用原有包管理器安装较新的本地包。业务数据保存在所连接的站点,不在安装包内。 +4. 使用 Flatpak 附件时运行 `flatpak install --user --reinstall ./新版本.flatpak`;这不会建立 Flathub 上架关系。AUR 包由相应 AUR 配方更新后使用包管理器升级;`-git` 版本需重新构建以跟随源码。 + +当前没有安装 Tauri updater 插件或应用内自动更新端点。`release/latest.json` 是多产品下载目录,**不是** Tauri updater 的 `version/platforms/url/signature` 更新协议;不能把它当作更新 feed。将来启用自动更新需要单独的持久签名密钥、客户端公钥以及对应的 `.sig` 产物,不能用 SHA-256 或平台代码签名替代。[Tauri updater 官方说明](https://v2.tauri.app/plugin/updater/)列出了这一要求。 ## 本地构建 -桌面包独立于服务器 Cargo workspace,避免普通服务器或 CLI 测试被迫安装 GTK / WebKit 开发依赖。请先按 [Tauri 官方前置条件](https://v2.tauri.app/start/prerequisites/)安装当前系统所需工具。 +桌面包独立于服务器 Cargo workspace,避免普通服务器或 CLI 测试被迫安装 GTK / WebKit 开发依赖。Rust 需要 **1.90 或更新版本**,与当前锁定的 Tauri opener 依赖要求一致。请先按 [Tauri 官方前置条件](https://v2.tauri.app/start/prerequisites/)安装当前系统所需工具。 ```sh cd desktop @@ -111,12 +125,12 @@ npm run tauri -- build 发布目标由 [`release/targets.json`](../release/targets.json) 定义。CI 矩阵、预期包集合、Markdown、JSON 和 SVG 都读取这个目录,新增平台时不需要分别维护多张表。 1. 在 `desktop/src-tauri/Cargo.toml`、`desktop/src-tauri/tauri.conf.json` 和 `desktop/package.json` 中保持桌面版本一致;更新相应锁文件。 -2. 提交源码,等待 [桌面发布工作流](../.github/workflows/desktop-release.yml) 的验证构建通过。手动运行可验证构建,不会把分支名称当作正式版本发布。 +2. 提交源码,等待 [桌面发布工作流](../.github/workflows/desktop-release.yml) 的相关路径 PR 验证通过。PR 不接收签名 secrets,产物标记 `distribution=engineering`。手动运行可以选择 `require_signing=true` 验证真实签名,但仍不公开发布。 3. 创建与桌面版本完全一致的 `desktop-v<版本>` 标签并推送。CLI 仍可通过原有 `cli-v<版本>` 标签单独发布。 -4. 各操作系统原生构建;Linux 另外生成 Flatpak。发布任务只在全部包成功后运行。 -5. 汇总脚本拒绝缺失平台、重复包、额外陈旧文件或 SHA-256 不匹配,生成完整的 `downloads.json`、`downloads.md`、`release-matrix.svg`、`VERSION` 和 `SHA256SUMS`。 +4. 各操作系统原生构建;Linux 另外生成 Flatpak。Windows / macOS 在构建前检查签名凭据,缺失时正式标签任务失败;不能把未签名结果降级当正式 Release 继续。 +5. 每个原生目标对最终包生成 `desktop-signing-.json`,报告绑定具体包名、SHA-256 和大小。汇总脚本拒绝缺失平台、重复包、陈旧文件、字节不符或不满足正式签名要求的报告。工程模式清单不能导入公开文档或 AUR 二进制配方。 6. 资产先传入草稿 Release,确认上传完成后公开。已公开的版本不被覆盖,修复需提升版本。 -7. 桌面版和独立 CLI Release 均从已发布清单自动更新下载文档,按各自稳定版本保留最新条目;仓库分支保护可能要求通过 PR 接受文档变更,Release 自身仍包含准确的矩阵与完整清单。 +7. 正式发布后调用下载文档与 AUR 更新工作流,`hireferry-desktop-bin` 只取本次 Linux `.deb` 的真实 URL 和 SHA-256。文档按各产品稳定版本保留最新条目;分支保护不允许直接写回时,文档更新任务会失败,维护者需从已发布清单重新生成并通过 PR 合入;Release 自身的清单仍可使用。 桌面 Release 使用 `--latest=false`,保留现有 CLI 一键安装器依赖的 GitHub `latest` 通道。用户从[下载矩阵](downloads.md)进入桌面 Release;不要用仓库通用 `/releases/latest` 代替桌面版下载入口。 @@ -145,6 +159,21 @@ python3 scripts/release.py docs --manifest /path/to/downloads.json Release 上传使用 GitHub Actions 自带的 `GITHUB_TOKEN`。最终发布任务和下载文档写回任务获得 `contents: write`;一般构建任务只读仓库。 -初始工作流不导入签名证书,也不配置代码签名 secrets。Windows 包未签名;macOS 仅采用构建工具默认的本地签名方式,不包含 Apple Developer ID 签名或公证。系统可能提示来源未验证,生成的包也不等于已完成商店审核。维护者可在获得自己的证书与账户凭据后添加签名步骤。配置 Apple 签名及公证方式见 [Tauri macOS 签名](https://v2.tauri.app/distribute/sign/macos/),Windows 见 [Tauri Windows 签名](https://v2.tauri.app/distribute/sign/windows/)。 +正式桌面发布需要维护者实际持有的平台凭据。脚本只检查配置是否完整,随后由操作系统验签;凭据存在本身不代表签名有效。 + +| 平台 | 仓库 secrets / variables | 构建与发布条件 | +| --- | --- | --- | +| Windows | secrets:`WINDOWS_CERTIFICATE`(base64 PFX)、`WINDOWS_CERTIFICATE_PASSWORD`、`WINDOWS_CERTIFICATE_THUMBPRINT`;variable:`WINDOWS_TIMESTAMP_URL` | 导入 CurrentUser 证书库,校验所选证书包含私钥且未过期;Tauri 用 SHA-256 与 RFC 3161 时间戳签名;最终 `.exe` / `.msi` 必须 `Get-AuthenticodeSignature` 为 Valid 且包含时间戳证书 | +| macOS | secrets:`APPLE_CERTIFICATE`(base64 P12)、`APPLE_CERTIFICATE_PASSWORD`、`APPLE_SIGNING_IDENTITY`(Developer ID Application) | Tauri 导入维护者证书并完成签名;同时配置下方一组公证凭据;最终 DMG 内与压缩包解出后的 `.app` 都要通过 `codesign --verify --deep --strict` 和 `xcrun stapler validate` | +| Linux | 不要求 Apple / Windows 凭据 | 记录每个最终包的 SHA-256;结果明确为 `checksum-only`,不称作发布者代码签名 | + +macOS 公证凭据**二选一**: + +- Apple ID:`APPLE_ID`、`APPLE_PASSWORD`(app-specific password)、`APPLE_TEAM_ID`。 +- App Store Connect API:`APPLE_API_ISSUER`、`APPLE_API_KEY`、`APPLE_API_KEY_BASE64`(P8 私钥文件的 base64)。工作流仅在临时目录生成文件并设置 `APPLE_API_KEY_PATH`,结束时删除。 + +凭据只传入对应平台的正式标签或主动要求验签的手动任务;PR 不接收。未启用签名的工程构建在 macOS 显式使用 ad-hoc 签名,Windows 结果标记 unsigned。对应 artifact 的清单、Markdown 和图片均标明工程状态,不能自动进入下载页。 + +当前 Windows 接口支持维护者已有的可导出 PFX 证书。新签发 OV / EV 证书常要求硬件或云签名;这类服务需要按证书颁发方接入 Tauri 的 `signCommand`,本工作流没有假设 HSM、Azure 账户或私钥存在,也不代为创建凭据。**代码签名不保证 SmartScreen 立即建立信誉。** 参考 [Tauri Windows 签名](https://v2.tauri.app/distribute/sign/windows/)与 [macOS 签名及公证](https://v2.tauri.app/distribute/sign/macos/)。 -SHA-256 用于检测下载损坏和包清单不一致;它不替代平台代码签名。应用内更新签名另有独立密钥要求,当前流程不配置自动执行更新。 +SHA-256 用于检测下载损坏和清单不一致;不替代平台代码签名。此仓库当前没有记录一轮带维护者真实证书的正式桌面发布结果,配置预检和模拟测试通过也不会被记录为平台签名验收通过。 diff --git a/docs/downloads.md b/docs/downloads.md index 095d217..f15e4b9 100644 --- a/docs/downloads.md +++ b/docs/downloads.md @@ -25,12 +25,13 @@ ## Arch Linux / AUR -服务端与客户端 CLI 独立安装,支持 x86_64 和 aarch64。同一组件的 `-git` 与 `-bin` 互斥,服务端与 CLI 可以共存。 +服务端、CLI 与桌面 GUI 独立安装,支持 x86_64 和 aarch64。同一组件的 `-git` 与 `-bin` 互斥,不同组件可以共存。 | 组件 | 跟随 main 编译 | 安装 Release 二进制 | | --- | --- | --- | | 服务端 | [hireferry-server-git](https://aur.archlinux.org/packages/hireferry-server-git) | [hireferry-server-bin](https://aur.archlinux.org/packages/hireferry-server-bin) | | hfy CLI | [hireferry-cli-git](https://aur.archlinux.org/packages/hireferry-cli-git) | [hireferry-cli-bin](https://aur.archlinux.org/packages/hireferry-cli-bin) | +| 桌面 GUI | 仓库提供 `hireferry-desktop-git` 配方;AUR 可用性见指南 | `hireferry-desktop-bin` 必须依据正式桌面 Release 生成;可用性见指南 | 安装、服务初始化与发布流程见 [AUR 指南](aur.md)。AUR 配方不计入上面的 Release 二进制数量。 diff --git a/scripts/desktop-signing.py b/scripts/desktop-signing.py new file mode 100644 index 0000000..c96029f --- /dev/null +++ b/scripts/desktop-signing.py @@ -0,0 +1,201 @@ +#!/usr/bin/env python3 +"""Configure native signing, then verify the final packages on their native OS. + +No credentials are printed or stored in release artifacts. Unsigned builds are +engineering artifacts; a formal desktop release requires native verification. +""" +import argparse +import base64 +import json +import os +from pathlib import Path +import re +import subprocess +import sys +import tarfile +import tempfile + +import release + + +def required(): + return os.environ.get('DESKTOP_REQUIRE_SIGNATURES', '').lower() == 'true' + + +def run(command, *, check=True, env=None): + result = subprocess.run(command, text=True, capture_output=True, env=env) + if check and result.returncode: + # Native signing errors can contain account details. Do not echo secrets. + raise ValueError(f'{Path(command[0]).name} failed (exit {result.returncode}); inspect the native signing configuration') + return result + + +def present(names): + return all(os.environ.get(name) for name in names) + + +def configure(args): + row = release.find_target(release.catalog(), 'desktop', args.target) + if row is None: + raise ValueError('Unknown desktop target') + config = {} + args.out.parent.mkdir(parents=True, exist_ok=True) + platform = row['platform'] + if platform == 'Windows': + names = ('WINDOWS_CERTIFICATE', 'WINDOWS_CERTIFICATE_PASSWORD', + 'WINDOWS_CERTIFICATE_THUMBPRINT', 'WINDOWS_TIMESTAMP_URL') + supplied = any(os.environ.get(name) for name in names) + if supplied and not present(names): + raise ValueError('Incomplete Windows signing settings: configure all four WINDOWS_* inputs') + if required() and not supplied: + raise ValueError('Formal desktop release requires Windows certificate, password, thumbprint and timestamp URL') + if supplied: + thumbprint = os.environ['WINDOWS_CERTIFICATE_THUMBPRINT'].replace(' ', '').upper() + if not re.fullmatch(r'[0-9A-F]{40}', thumbprint): + raise ValueError('Windows certificate thumbprint must contain 40 hexadecimal characters') + timestamp = os.environ['WINDOWS_TIMESTAMP_URL'] + if not re.fullmatch(r'https?://[^\s]+', timestamp): + raise ValueError('Windows timestamp URL must be an HTTP(S) timestamp service') + # Import-PfxCertificate reads its password from the environment, never argv. + with tempfile.TemporaryDirectory(prefix='hireferry-pfx-') as temporary: + certificate = Path(temporary)/'certificate.pfx' + certificate.write_bytes(base64.b64decode(os.environ['WINDOWS_CERTIFICATE'], validate=True)) + certificate.chmod(0o600) + env = dict(os.environ, HF_PFX_FILE=str(certificate), HF_SIGN_THUMBPRINT=thumbprint) + script = r'''$ErrorActionPreference = 'Stop' +$pw = ConvertTo-SecureString $env:WINDOWS_CERTIFICATE_PASSWORD -AsPlainText -Force +$certs = Import-PfxCertificate -FilePath $env:HF_PFX_FILE -CertStoreLocation Cert:\CurrentUser\My -Password $pw +$cert = @($certs | Where-Object { $_.Thumbprint -eq $env:HF_SIGN_THUMBPRINT -and $_.HasPrivateKey -and $_.NotAfter -gt (Get-Date) }) +if ($cert.Count -ne 1) { throw 'Requested signing certificate/private key was not imported or has expired' } +''' + run(['pwsh', '-NoProfile', '-NonInteractive', '-Command', script], env=env) + config = {'bundle': {'windows': {'certificateThumbprint':thumbprint, + 'digestAlgorithm':'sha256', 'timestampUrl':timestamp, 'tsp':True}}} + elif platform == 'macOS': + certificate = ('APPLE_CERTIFICATE', 'APPLE_CERTIFICATE_PASSWORD', 'APPLE_SIGNING_IDENTITY') + password_auth = ('APPLE_ID', 'APPLE_PASSWORD', 'APPLE_TEAM_ID') + api_auth = ('APPLE_API_ISSUER', 'APPLE_API_KEY', 'APPLE_API_KEY_BASE64') + supplied = any(os.environ.get(name) for name in certificate + password_auth + api_auth) + partial_password = any(os.environ.get(name) for name in password_auth) and not present(password_auth) + partial_api = any(os.environ.get(name) for name in api_auth) and not present(api_auth) + if supplied and (not present(certificate) or partial_password or partial_api or not (present(password_auth) ^ present(api_auth))): + raise ValueError('macOS requires a Developer ID certificate and exactly one complete notarization credential set') + if required() and not supplied: + raise ValueError('Formal desktop release requires Apple Developer ID signing and notarization credentials') + if supplied: + if not os.environ['APPLE_SIGNING_IDENTITY'].startswith('Developer ID Application:'): + raise ValueError('Use a Developer ID Application identity for direct macOS distribution') + # Tauri imports the certificate itself. For API authentication it expects a key file. + if present(api_auth): + key = args.out.parent/'hireferry-notary-key.p8' + key.write_bytes(base64.b64decode(os.environ['APPLE_API_KEY_BASE64'], validate=True)) + key.chmod(0o600) + with open(os.environ['GITHUB_ENV'], 'a') as output: + output.write(f'APPLE_API_KEY_PATH={key.resolve()}\n') + config = {'bundle': {'macOS': {'signingIdentity':os.environ['APPLE_SIGNING_IDENTITY']}}} + else: + config = {'bundle': {'macOS': {'signingIdentity':'-'}}} + args.out.write_text(json.dumps(config) + '\n') + print(f'{platform}: {"release signing required" if required() else "engineering build; publication disabled"}') + + +def windows_verification(path): + env = dict(os.environ, HF_VERIFY_FILE=str(path.resolve())) + script = r'''$ErrorActionPreference = 'Stop' +$s = Get-AuthenticodeSignature -LiteralPath $env:HF_VERIFY_FILE +@{status=$s.Status.ToString(); publisher=if($s.SignerCertificate){$s.SignerCertificate.Subject}else{''}; timestamped=($null -ne $s.TimeStamperCertificate)} | ConvertTo-Json -Compress +''' + result = json.loads(run(['pwsh', '-NoProfile', '-NonInteractive', '-Command', script], env=env).stdout) + if result['status'] == 'NotSigned': + return {'verification':'unsigned'} + if result['status'] != 'Valid' or not result['timestamped']: + raise ValueError(f'Windows package lacks a valid, timestamped Authenticode signature: {path.name}') + return {'verification':'authenticode', 'publisher':result['publisher']} + + +def verify_app(app): + run(['codesign', '--verify', '--deep', '--strict', str(app)]) + detail = run(['codesign', '--display', '--verbose=4', str(app)]).stderr + authority = next((line.removeprefix('Authority=') for line in detail.splitlines() + if line.startswith('Authority=Developer ID Application:')), None) + if authority: + run(['xcrun', 'stapler', 'validate', str(app)]) + return {'verification':'developer-id-notarized', 'publisher':authority} + if 'Signature=adhoc' in detail: + return {'verification':'ad-hoc'} + raise ValueError('macOS app is neither ad-hoc nor a stapled Developer ID signed app') + + +def macos_verification(path): + with tempfile.TemporaryDirectory(prefix='hireferry-verify-') as temporary: + folder = Path(temporary) + if path.name.endswith('.app.tar.gz'): + # This is our staged artifact. Validate paths before native extraction, + # which also restores macOS metadata preserved by native tar. + with tarfile.open(path) as archive: + for member in archive.getmembers(): + if member.name.startswith('/') or '..' in Path(member.name).parts: + raise ValueError('Unsafe macOS app archive path') + run(['tar', '-xzf', str(path.resolve()), '-C', str(folder)]) + apps = list(folder.glob('*.app')) + if len(apps) != 1: + raise ValueError('Expected one app in macOS archive') + return verify_app(apps[0]) + mount = folder/'mounted' + mount.mkdir() + run(['hdiutil', 'attach', '-nobrowse', '-readonly', '-mountpoint', str(mount), str(path.resolve())]) + try: + apps = list(mount.glob('*.app')) + if len(apps) != 1: + raise ValueError('Expected one app in macOS disk image') + return verify_app(apps[0]) + finally: + run(['hdiutil', 'detach', str(mount)]) + + +def verify(args): + data = release.catalog() + row = release.find_target(data, 'desktop', args.target) + if row is None: + raise ValueError('Unknown desktop target') + name = release.signing_report_name(args.target) + assets = {} + wanted = release.expected(data, {'desktop':release.package_version('desktop')}, ('desktop',)) + for file, metadata in wanted.items(): + if metadata['target'] != args.target or metadata['format'] == 'flatpak': + continue + path = args.directory/file + if not path.is_file() or path.is_symlink() or not path.stat().st_size: + raise ValueError(f'Missing package to verify: {file}') + if row['platform'] == 'Windows': + checked = windows_verification(path) + elif row['platform'] == 'macOS': + checked = macos_verification(path) + else: + checked = {'verification':'checksum-only'} + assets[file] = dict(checked, sha256=release.digest(path), size=path.stat().st_size) + report = {'schema_version':1, 'target':args.target, 'assets':assets} + release.validate_signing_report(report, {n:m for n,m in wanted.items() + if m['target']==args.target and m['format']!='flatpak'}, + {n:args.directory/n for n in assets}, require_signed=required()) + (args.directory/name).write_text(json.dumps(report, indent=2) + '\n') + release.checksums(args.directory) + print(f'Native verification recorded for {len(assets)} {args.target} packages') + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + commands = parser.add_subparsers(dest='command', required=True) + config = commands.add_parser('configure') + config.add_argument('--target', required=True) + config.add_argument('--out', required=True, type=Path) + config.set_defaults(run=configure) + check = commands.add_parser('verify') + check.add_argument('--target', required=True) + check.add_argument('--directory', required=True, type=Path) + check.set_defaults(run=verify) + args = parser.parse_args() + try: + args.run(args) + except (ValueError, KeyError, OSError, subprocess.SubprocessError) as error: + parser.exit(1, f'desktop-signing: {error}\n') diff --git a/scripts/release.py b/scripts/release.py index 4da2371..492fb73 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -11,6 +11,7 @@ from pathlib import Path import re import shutil +import subprocess import sys import tarfile import tempfile @@ -171,8 +172,14 @@ def stage_desktop(args): for fmt, source in sources.items(): destination = args.out / filename('desktop', release_version, args.target, fmt) if fmt == 'app.tar.gz': - with tarfile.open(destination, 'w:gz') as archive: - archive.add(source, arcname=source.name) + if sys.platform == 'darwin': + # Preserve Apple metadata/stapled tickets. This is a manual-install + # archive, not an updater payload. Verification reopens this archive. + subprocess.run(['tar', '-czf', str(destination.resolve()), '-C', + str(source.parent.resolve()), source.name], check=True) + else: + with tarfile.open(destination, 'w:gz') as archive: + archive.add(source, arcname=source.name) else: shutil.copyfile(source, destination) checksums(args.out) @@ -243,6 +250,62 @@ def verified_inputs(source, wanted): return found +def signing_report_name(target): + return f'desktop-signing-{target}.json' + + +def validate_signing_report(report, wanted, files=None, require_signed=False): + if (not isinstance(report, dict) or set(report) != {'schema_version', 'target', 'assets'} + or report['schema_version'] != 1 or not isinstance(report['assets'], dict) + or set(report['assets']) != set(wanted) or not wanted + or any(item['target'] != report['target'] for item in wanted.values())): + raise ValueError('Invalid or incomplete desktop signing report') + allowed = {'Windows':{'authenticode','unsigned'}, + 'macOS':{'developer-id-notarized','ad-hoc'}, 'Linux':{'checksum-only'}} + required = {'Windows':'authenticode', 'macOS':'developer-id-notarized', 'Linux':'checksum-only'} + for name, entry in report['assets'].items(): + if (not isinstance(entry, dict) or not {'sha256','size','verification'} <= set(entry) + or set(entry) - {'sha256','size','verification','publisher'} + or not isinstance(entry['sha256'], str) or not re.fullmatch(r'[0-9a-f]{64}', entry['sha256']) + or not isinstance(entry['size'], int) or isinstance(entry['size'], bool) or entry['size'] <= 0 + or not isinstance(entry['verification'], str) + or entry['verification'] not in allowed[wanted[name]['platform']]): + raise ValueError(f'Invalid native verification metadata: {name}') + if entry['verification'] in ('authenticode','developer-id-notarized'): + publisher = entry.get('publisher') + if not isinstance(publisher, str) or not publisher or len(publisher) > 1000 or '\n' in publisher: + raise ValueError('Native signing publisher must be recorded') + elif 'publisher' in entry: + raise ValueError('Unsigned/checksum-only packages cannot claim a signing publisher') + if require_signed and entry['verification'] != required[wanted[name]['platform']]: + raise ValueError(f'Formal desktop release requires native publisher signing: {name}') + if files is not None and (entry['sha256'] != digest(files[name]) or entry['size'] != files[name].stat().st_size): + raise ValueError(f'Signing report does not match package bytes: {name}') + return report + + +def validate_desktop_signing(manifest, require_signed=False): + reports = manifest.get('desktop_signing') + targets = {row['target'] for row in manifest['catalog']['desktop']} + if not isinstance(reports, dict) or set(reports) != targets or not targets: + raise ValueError('Complete native desktop signing reports are required') + for target, report in reports.items(): + wanted = {asset['name']:asset for asset in manifest['assets'] + if asset['product']=='desktop' and asset['target']==target and asset['format']!='flatpak'} + validate_signing_report(report, wanted, require_signed=require_signed) + for name, entry in report['assets'].items(): + if entry['sha256'] != wanted[name]['sha256'] or entry['size'] != wanted[name]['size']: + raise ValueError('Manifest and desktop signing report differ') + + +def require_publishable(manifest): + if manifest.get('distribution', 'release') != 'release': + raise ValueError('Engineering artifacts cannot update public downloads or AUR binary packages') + if 'desktop' in manifest['versions']: + validate_desktop_signing(manifest, require_signed=True) + return manifest + + def make_manifest(data, wanted, files, tag, repo, commit=''): published_catalog = json.loads(json.dumps(data)) published_catalog['repository'] = repository(repo) @@ -265,6 +328,8 @@ def make_manifest(data, wanted, files, tag, repo, commit=''): def validate_manifest(manifest): if not isinstance(manifest, dict) or manifest.get('schema_version') != 1: raise ValueError('Unsupported download manifest schema') + if manifest.get('distribution', 'release') not in ('release','engineering'): + raise ValueError('Invalid distribution state') repo = repository(manifest['repository']) data = validate_catalog(manifest['catalog']) if data['repository'] != repo: @@ -310,6 +375,10 @@ def validate_manifest(manifest): raise ValueError('Invalid package size') if not isinstance(asset['sha256'], str) or not re.fullmatch(r'[0-9a-f]{64}', asset['sha256']): raise ValueError('Invalid package checksum') + if 'desktop_signing' in manifest: + if 'desktop' not in products: + raise ValueError('Signing reports require desktop assets') + validate_desktop_signing(manifest, require_signed=manifest.get('distribution','release')=='release') return manifest @@ -348,6 +417,8 @@ def merge_manifests(current, incoming): for group in (('desktop', 'flatpak') if product == 'desktop' else (product,)): merged['catalog'][group] = source['catalog'][group] merged['assets'].extend(asset for asset in source['assets'] if asset['product'] == product) + if product == 'desktop' and 'desktop_signing' in source: + merged['desktop_signing'] = source['desktop_signing'] merged['assets'].sort(key=lambda asset: asset['name']) commits = set(merged['source_commits'].values()) if len(commits) == 1: @@ -364,6 +435,8 @@ def svg(data, manifest=None): if manifest: data = manifest['catalog'] count = len(manifest['assets']) if manifest else sum(len(row['formats']) for group in GROUPS for row in data.get(group, [])) subtitle = ('RELEASE ASSETS VERIFIED · ' + ' / '.join(dict.fromkeys(manifest['releases'][p] for p in PRODUCTS if p in manifest['releases']))) if manifest else 'BUILD TARGETS · DOWNLOADS APPEAR AFTER A COMPLETE RELEASE' + if manifest and manifest.get('distribution') == 'engineering': + subtitle = 'ENGINEERING ARTIFACTS · NOT A PUBLISHED RELEASE' subtitle = html.escape(subtitle) headline = 'HireFerry · Every desktop, one ferry.' if not manifest or 'desktop' in manifest['versions'] else ('HireFerry · Your service. Your ferry.' if 'server' in manifest['versions'] else 'HireFerry · One CLI. Every platform.') cards = [] @@ -402,16 +475,18 @@ def markdown(data, manifest=None, image='assets/release-matrix.svg', docs_url='' repo = manifest['repository'] if manifest else data['repository'] guide = docs_url + 'desktop.md' cli_guide = docs_url + 'cli.md' + engineering = manifest and manifest.get('distribution') == 'engineering' lines = ['', '# 聘渡 · 桌面版、CLI 与服务端下载', '', f'![HireFerry 发布矩阵]({image})', '', f'[安装与发布说明]({guide}) · [CLI 使用指南]({cli_guide}) · ' f'[所有 Releases](https://github.com/{repo}/releases)', ''] if manifest: - lines += ['下表来自已汇总校验的发布资产;大小为实际下载体积,SHA-256 见对应 Release 的 `SHA256SUMS`。', ''] + lines += [('**工程验证产物,未发布为正式安装包。** 仅用于本次 CI 验证;不能导入公开下载页或生成 AUR 二进制配方。' + if engineering else '下表来自已汇总校验的发布资产;大小为实际下载体积,SHA-256 见对应 Release 的 `SHA256SUMS`。'), ''] if 'desktop' not in manifest['versions']: lines += ['**尚未收录已发布的桌面安装包。** 桌面构建目标见 `release/targets.json`。', ''] for product in PRODUCTS: - if product in manifest['versions']: + if product in manifest['versions'] and not engineering: tag = manifest['releases'][product] lines.append(f"- **{PRODUCT_LABELS[product]} {manifest['versions'][product]}**:[Release](https://github.com/{repo}/releases/tag/{tag}) · [校验文件](https://github.com/{repo}/releases/download/{tag}/SHA256SUMS)") else: @@ -419,17 +494,27 @@ def markdown(data, manifest=None, image='assets/release-matrix.svg', docs_url='' lines += ['', '| 组件 | 系统 | 架构 | 软件包 | 下载体积 |', '| --- | --- | --- | --- | --- |'] if manifest: for a in sorted(manifest['assets'], key=lambda a:(a['product'],a['platform'],a['architecture'],a['format'])): - lines.append(f"| {PRODUCT_LABELS[a['product']]} | {a['platform']} | {ARCH_LABELS.get(a['architecture'], a['architecture'])} | [{LABELS[a['format']]}]({a['url']}) | {human_size(a['size'])} |") + package = f"`{a['name']}`" if engineering else f"[{LABELS[a['format']]}]({a['url']})" + lines.append(f"| {PRODUCT_LABELS[a['product']]} | {a['platform']} | {ARCH_LABELS.get(a['architecture'], a['architecture'])} | {package} | {human_size(a['size'])} |") else: for group in GROUPS: for row in data.get(group, []): lines.append(f"| {PRODUCT_LABELS[group_product(group)]} | {row['platform']} | {ARCH_LABELS.get(row['architecture'], row['architecture'])} | {'、'.join(LABELS[f] for f in row['formats'])} | 发布后生成 |") lines += ['', '## Arch Linux / AUR', '', - '服务端与客户端 CLI 独立安装,支持 x86_64 和 aarch64。同一组件的 `-git` 与 `-bin` 互斥,服务端与 CLI 可以共存。', '', + '服务端、CLI 与桌面 GUI 独立安装,支持 x86_64 和 aarch64。同一组件的 `-git` 与 `-bin` 互斥,不同组件可以共存。', '', '| 组件 | 跟随 main 编译 | 安装 Release 二进制 |', '| --- | --- | --- |'] for product in ('server', 'cli'): names = [f'hireferry-{product}-{variant}' for variant in ('git', 'bin')] lines.append(f"| {PRODUCT_LABELS[product]} | [{names[0]}](https://aur.archlinux.org/packages/{names[0]}) | [{names[1]}](https://aur.archlinux.org/packages/{names[1]}) |") + lines += ['| 桌面 GUI | 仓库提供 `hireferry-desktop-git` 配方;AUR 可用性见指南 | `hireferry-desktop-bin` 必须依据正式桌面 Release 生成;可用性见指南 |'] + if manifest and 'desktop_signing' in manifest: + labels = {'authenticode':'已验 Authenticode 与时间戳', 'developer-id-notarized':'已验 Developer ID 与公证票据', + 'checksum-only':'SHA-256;无平台发布者签名', 'unsigned':'未签名工程构建', 'ad-hoc':'临时本地签名工程构建'} + lines += ['', '## 桌面包签名与更新', '', '| 系统 / 目标 | 实际包验签结果 |', '| --- | --- |'] + for target, report in sorted(manifest['desktop_signing'].items()): + states = sorted({labels[entry['verification']] for entry in report['assets'].values()}) + lines.append(f"| `{target}` | {'、'.join(states)} |") + lines += ['', '桌面更新通过下载并安装新版本完成;未启用应用内自动更新。Flatpak 附件更新需重新安装新附件。SHA-256 不代替平台签名,签名也不承诺免除 Windows SmartScreen 的信誉提示。'] lines += ['', f'安装、服务初始化与发布流程见 [AUR 指南]({docs_url}aur.md)。AUR 配方不计入上面的 Release 二进制数量。', ''] lines += ['', '## Linux 选包建议', '', '| 发行版系列 | 桌面版优先选择 | 适用范围 |', '| --- | --- | --- |', @@ -453,17 +538,31 @@ def assemble(args, products=('desktop', 'cli')): raise ValueError(f'Release tag must match the {primary} Cargo package version') repo = repository(args.repository or data['repository']) wanted = expected(data, versions, products) - files = verified_inputs(args.source, wanted) - manifest = validate_manifest(make_manifest(data, wanted, files, args.tag, repo, args.commit)) + reports = {signing_report_name(row['target']):row for row in data['desktop']} if 'desktop' in products else {} + files = verified_inputs(args.source, {**wanted, **reports}) + manifest = make_manifest(data, wanted, files, args.tag, repo, args.commit) + manifest['distribution'] = getattr(args, 'distribution', 'release') + if reports: + manifest['desktop_signing'] = {} + for name, row in reports.items(): + target = row['target'] + report = json.loads(files[name].read_text()) + target_assets = {n:m for n,m in wanted.items() if m['product']=='desktop' and m['target']==target and m['format']!='flatpak'} + validate_signing_report(report, target_assets, files, require_signed=manifest['distribution']=='release') + manifest['desktop_signing'][target] = report + validate_manifest(manifest) + if manifest['distribution'] == 'release': + require_publishable(manifest) args.destination.mkdir(parents=True, exist_ok=False) for name, path in files.items(): shutil.copyfile(path, args.destination/name) (args.destination/'VERSION').write_text(versions.get('cli', versions[primary]) + '\n') (args.destination/'downloads.json').write_text(json.dumps(manifest, indent=2) + '\n') - (args.destination/'downloads.md').write_text(markdown(data, manifest, f'https://github.com/{repo}/releases/download/{args.tag}/release-matrix.svg', f'https://github.com/{repo}/blob/{args.tag}/docs/')) + image = 'release-matrix.svg' if manifest['distribution']=='engineering' else f'https://github.com/{repo}/releases/download/{args.tag}/release-matrix.svg' + (args.destination/'downloads.md').write_text(markdown(data, manifest, image, f'https://github.com/{repo}/blob/{args.commit if manifest["distribution"]=="engineering" and args.commit else args.tag}/docs/')) (args.destination/'release-matrix.svg').write_text(svg(data, manifest)) checksums(args.destination) - print(f'Verified {len(files)} package assets for {args.tag}') + print(f'Verified {len(wanted)} package assets for {args.tag} ({manifest["distribution"]})') def assemble_cli(args): @@ -474,14 +573,35 @@ def assemble_server(args): assemble(args, ('server',)) +def verify_publication(args): + manifest = require_publishable(validate_manifest(json.loads((args.directory/'downloads.json').read_text()))) + allowed = {asset['name']:asset for asset in manifest['assets']} + allowed.update({name:{} for name in ('VERSION','downloads.json','downloads.md','release-matrix.svg')}) + if 'desktop_signing' in manifest: + allowed.update({signing_report_name(target):{} for target in manifest['desktop_signing']}) + files = verified_inputs(args.directory, allowed) + for asset in manifest['assets']: + if digest(files[asset['name']]) != asset['sha256'] or files[asset['name']].stat().st_size != asset['size']: + raise ValueError('Download manifest does not match final package bytes') + for target, report in manifest.get('desktop_signing', {}).items(): + if json.loads(files[signing_report_name(target)].read_text()) != report: + raise ValueError('Final desktop signing report differs from download manifest') + print('Complete formal release and native verification reports are ready to publish') + + def docs(args): manifest_path = args.manifest or (SNAPSHOT if SNAPSHOT.exists() else None) manifest = validate_manifest(json.loads(manifest_path.read_text())) if manifest_path else None + if manifest and manifest.get('distribution', 'release') != 'release': + raise ValueError('Engineering artifacts cannot update public downloads or AUR binary packages') if args.manifest: + require_publishable(manifest) current = json.loads(SNAPSHOT.read_text()) if SNAPSHOT.exists() else None manifest = merge_manifests(current, manifest) data = manifest['catalog'] if manifest else catalog() outputs = {ROOT/'docs/downloads.md':markdown(data, manifest), ROOT/'docs/assets/release-matrix.svg':svg(data, manifest)} + if manifest: + outputs[ROOT/'static/downloads.json'] = json.dumps(manifest, indent=2) + '\n' if args.manifest: outputs[SNAPSHOT] = json.dumps(manifest, indent=2) + '\n' stale = [] @@ -516,7 +636,11 @@ def main(): build.add_argument('--tag', required=True) build.add_argument('--repository') build.add_argument('--commit', default='') + build.add_argument('--distribution', choices=('release','engineering'), default='release') build.set_defaults(run=fn) + verify = commands.add_parser('verify-publication') + verify.add_argument('directory', type=Path) + verify.set_defaults(run=verify_publication) generate = commands.add_parser('docs') generate.add_argument('--manifest', type=Path) generate.add_argument('--check', action='store_true') diff --git a/static/downloads.json b/static/downloads.json new file mode 100644 index 0000000..590f485 --- /dev/null +++ b/static/downloads.json @@ -0,0 +1,205 @@ +{ + "schema_version": 1, + "repository": "TokenNotIncluded/hireferry", + "catalog": { + "schema_version": 1, + "repository": "TokenNotIncluded/hireferry", + "desktop": [], + "flatpak": [], + "cli": [ + { + "platform": "Linux", + "architecture": "x86_64", + "target": "x86_64-unknown-linux-musl", + "formats": [ + "tar.gz" + ], + "runner": "ubuntu-24.04" + }, + { + "platform": "Linux", + "architecture": "aarch64", + "target": "aarch64-unknown-linux-musl", + "formats": [ + "tar.gz" + ], + "runner": "ubuntu-24.04-arm" + }, + { + "platform": "macOS", + "architecture": "x86_64", + "target": "x86_64-apple-darwin", + "formats": [ + "tar.gz" + ], + "runner": "macos-15-intel" + }, + { + "platform": "macOS", + "architecture": "aarch64", + "target": "aarch64-apple-darwin", + "formats": [ + "tar.gz" + ], + "runner": "macos-14" + }, + { + "platform": "Windows", + "architecture": "x86_64", + "target": "x86_64-pc-windows-msvc", + "formats": [ + "zip" + ], + "runner": "windows-2022" + }, + { + "platform": "Windows", + "architecture": "aarch64", + "target": "aarch64-pc-windows-msvc", + "formats": [ + "zip" + ], + "runner": "windows-11-arm" + } + ], + "server": [ + { + "platform": "Linux", + "architecture": "x86_64", + "target": "x86_64-unknown-linux-gnu", + "formats": [ + "tar.gz" + ], + "runner": "ubuntu-22.04" + }, + { + "platform": "Linux", + "architecture": "aarch64", + "target": "aarch64-unknown-linux-gnu", + "formats": [ + "tar.gz" + ], + "runner": "ubuntu-22.04-arm" + } + ] + }, + "source_commit": "d3c12144ffe6041057557cd5df11448e2c804407", + "source_commits": { + "cli": "d3c12144ffe6041057557cd5df11448e2c804407", + "server": "d3c12144ffe6041057557cd5df11448e2c804407" + }, + "versions": { + "cli": "0.1.3", + "server": "0.1.0" + }, + "releases": { + "cli": "cli-v0.1.3", + "server": "server-v0.1.0" + }, + "assets": [ + { + "platform": "macOS", + "architecture": "aarch64", + "target": "aarch64-apple-darwin", + "product": "cli", + "version": "0.1.3", + "format": "tar.gz", + "name": "hireferry-cli-0.1.3-aarch64-apple-darwin.tar.gz", + "size": 1918502, + "sha256": "6f631861ab8e376898d7588d7eb7110b201c4ce5115401b554d2a185f50f367e", + "tag": "cli-v0.1.3", + "url": "https://github.com/TokenNotIncluded/hireferry/releases/download/cli-v0.1.3/hireferry-cli-0.1.3-aarch64-apple-darwin.tar.gz" + }, + { + "platform": "Windows", + "architecture": "aarch64", + "target": "aarch64-pc-windows-msvc", + "product": "cli", + "version": "0.1.3", + "format": "zip", + "name": "hireferry-cli-0.1.3-aarch64-pc-windows-msvc.zip", + "size": 1987462, + "sha256": "027f5acf49e2e6308addb2363c602ef18e112edbe998d859b85ff3b97b4821f0", + "tag": "cli-v0.1.3", + "url": "https://github.com/TokenNotIncluded/hireferry/releases/download/cli-v0.1.3/hireferry-cli-0.1.3-aarch64-pc-windows-msvc.zip" + }, + { + "platform": "Linux", + "architecture": "aarch64", + "target": "aarch64-unknown-linux-musl", + "product": "cli", + "version": "0.1.3", + "format": "tar.gz", + "name": "hireferry-cli-0.1.3-aarch64-unknown-linux-musl.tar.gz", + "size": 2033846, + "sha256": "903bd2f3cf66e6f6eba45190c02f12e168aeb1c476a47f2fa4dc63e41cd49f3e", + "tag": "cli-v0.1.3", + "url": "https://github.com/TokenNotIncluded/hireferry/releases/download/cli-v0.1.3/hireferry-cli-0.1.3-aarch64-unknown-linux-musl.tar.gz" + }, + { + "platform": "macOS", + "architecture": "x86_64", + "target": "x86_64-apple-darwin", + "product": "cli", + "version": "0.1.3", + "format": "tar.gz", + "name": "hireferry-cli-0.1.3-x86_64-apple-darwin.tar.gz", + "size": 2030321, + "sha256": "1d07d7eb9b60b53d011c09cc925fd84d71c6e76f3cfceb80d58c2477a4d2119f", + "tag": "cli-v0.1.3", + "url": "https://github.com/TokenNotIncluded/hireferry/releases/download/cli-v0.1.3/hireferry-cli-0.1.3-x86_64-apple-darwin.tar.gz" + }, + { + "platform": "Windows", + "architecture": "x86_64", + "target": "x86_64-pc-windows-msvc", + "product": "cli", + "version": "0.1.3", + "format": "zip", + "name": "hireferry-cli-0.1.3-x86_64-pc-windows-msvc.zip", + "size": 2104447, + "sha256": "e60b949674cb1dc7b1c148865bbb43584d896e5f95b1af84b06ba221a462e3e3", + "tag": "cli-v0.1.3", + "url": "https://github.com/TokenNotIncluded/hireferry/releases/download/cli-v0.1.3/hireferry-cli-0.1.3-x86_64-pc-windows-msvc.zip" + }, + { + "platform": "Linux", + "architecture": "x86_64", + "target": "x86_64-unknown-linux-musl", + "product": "cli", + "version": "0.1.3", + "format": "tar.gz", + "name": "hireferry-cli-0.1.3-x86_64-unknown-linux-musl.tar.gz", + "size": 2176425, + "sha256": "8111e5fe8256f3d31fb60d2a64a86a1534cd5170fdd0d72b80b758b70af89177", + "tag": "cli-v0.1.3", + "url": "https://github.com/TokenNotIncluded/hireferry/releases/download/cli-v0.1.3/hireferry-cli-0.1.3-x86_64-unknown-linux-musl.tar.gz" + }, + { + "platform": "Linux", + "architecture": "aarch64", + "target": "aarch64-unknown-linux-gnu", + "product": "server", + "version": "0.1.0", + "format": "tar.gz", + "name": "hireferry-server-0.1.0-aarch64-unknown-linux-gnu.tar.gz", + "size": 6765947, + "sha256": "78768b3ba19c335caeb43f01fdb064395d20bf624b660e597ffbeaa213337038", + "tag": "server-v0.1.0", + "url": "https://github.com/TokenNotIncluded/hireferry/releases/download/server-v0.1.0/hireferry-server-0.1.0-aarch64-unknown-linux-gnu.tar.gz" + }, + { + "platform": "Linux", + "architecture": "x86_64", + "target": "x86_64-unknown-linux-gnu", + "product": "server", + "version": "0.1.0", + "format": "tar.gz", + "name": "hireferry-server-0.1.0-x86_64-unknown-linux-gnu.tar.gz", + "size": 7119499, + "sha256": "562012f7801f26637289e27913870486893cf5b46f0c73495d9ec2f31a94774c", + "tag": "server-v0.1.0", + "url": "https://github.com/TokenNotIncluded/hireferry/releases/download/server-v0.1.0/hireferry-server-0.1.0-x86_64-unknown-linux-gnu.tar.gz" + } + ] +} diff --git a/tests/desktop-signing.test.py b/tests/desktop-signing.test.py new file mode 100644 index 0000000..672f024 --- /dev/null +++ b/tests/desktop-signing.test.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +"""Signing policy tests; mocked native commands are not evidence of OS signing.""" +import argparse +import base64 +import importlib.util +import json +import os +from pathlib import Path +import sys +import tempfile +from types import SimpleNamespace +import unittest +from unittest.mock import patch + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT/'scripts')) +spec = importlib.util.spec_from_file_location('signing', ROOT/'scripts/desktop-signing.py') +signing = importlib.util.module_from_spec(spec) +spec.loader.exec_module(signing) + + +class SigningPolicy(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory() + self.addCleanup(self.temporary.cleanup) + self.root = Path(self.temporary.name) + self.clean = patch.dict(os.environ, {}, clear=True) + self.clean.start() + self.addCleanup(self.clean.stop) + + def args(self, target): + return argparse.Namespace(target=target, out=self.root/'config.json') + + def test_unsigned_engineering_build_has_explicit_ad_hoc_macos_config(self): + args = self.args('aarch64-apple-darwin') + signing.configure(args) + self.assertEqual(json.loads(args.out.read_text()), {'bundle':{'macOS':{'signingIdentity':'-'}}}) + signing.configure(self.args('aarch64-pc-windows-msvc')) + self.assertEqual(json.loads(args.out.read_text()), {}) + + def test_formal_windows_and_macos_fail_before_build_without_credentials(self): + os.environ['DESKTOP_REQUIRE_SIGNATURES'] = 'true' + for target in ('x86_64-apple-darwin','aarch64-pc-windows-msvc'): + with self.subTest(target=target), self.assertRaisesRegex(ValueError, 'Formal desktop release requires'): + signing.configure(self.args(target)) + signing.configure(self.args('x86_64-unknown-linux-gnu')) + + def test_partial_or_ambiguous_notarization_configuration_fails(self): + credentials = {'APPLE_CERTIFICATE':'fixture', 'APPLE_CERTIFICATE_PASSWORD':'secret', + 'APPLE_SIGNING_IDENTITY':'Developer ID Application: Fixture', + 'APPLE_ID':'fixture@example.invalid', 'APPLE_PASSWORD':'private', 'APPLE_TEAM_ID':'ABCDE12345'} + with patch.dict(os.environ, {'APPLE_CERTIFICATE':'fixture'}): + with self.assertRaisesRegex(ValueError, 'complete notarization'): + signing.configure(self.args('aarch64-apple-darwin')) + with patch.dict(os.environ, dict(credentials, APPLE_API_KEY='PARTIAL')): + with self.assertRaisesRegex(ValueError, 'complete notarization'): + signing.configure(self.args('aarch64-apple-darwin')) + with patch.dict(os.environ, credentials): + signing.configure(self.args('aarch64-apple-darwin')) + config = (self.root/'config.json').read_text() + self.assertNotIn('private', config) + self.assertNotIn('secret', config) + self.assertIn('Developer ID Application:', config) + + def test_api_key_is_private_temporary_file_not_in_overlay(self): + os.environ.update({'APPLE_CERTIFICATE':'fixture', 'APPLE_CERTIFICATE_PASSWORD':'secret', + 'APPLE_SIGNING_IDENTITY':'Developer ID Application: Fixture', + 'APPLE_API_ISSUER':'issuer', 'APPLE_API_KEY':'keyid', + 'APPLE_API_KEY_BASE64':base64.b64encode(b'private-key-fixture').decode(), + 'GITHUB_ENV':str(self.root/'environment')}) + signing.configure(self.args('x86_64-apple-darwin')) + key = self.root/'hireferry-notary-key.p8' + self.assertEqual(key.read_bytes(), b'private-key-fixture') + if os.name != 'nt': + self.assertEqual(key.stat().st_mode & 0o777, 0o600) + self.assertNotIn('private-key-fixture', (self.root/'config.json').read_text()) + self.assertIn('APPLE_API_KEY_PATH=', (self.root/'environment').read_text()) + + def test_windows_certificate_import_uses_env_password_and_erases_pfx(self): + os.environ.update({'WINDOWS_CERTIFICATE':base64.b64encode(b'pfx-fixture').decode(), + 'WINDOWS_CERTIFICATE_PASSWORD':'not-in-argv', + 'WINDOWS_CERTIFICATE_THUMBPRINT':'A'*40, + 'WINDOWS_TIMESTAMP_URL':'http://timestamp.example.invalid'}) + with patch.object(signing, 'run') as native: + signing.configure(self.args('x86_64-pc-windows-msvc')) + args, kwargs = native.call_args + self.assertNotIn('not-in-argv', ' '.join(args[0])) + self.assertFalse(Path(kwargs['env']['HF_PFX_FILE']).exists()) + config = json.loads((self.root/'config.json').read_text())['bundle']['windows'] + self.assertEqual(config['certificateThumbprint'], 'A'*40) + self.assertEqual(config['digestAlgorithm'], 'sha256') + self.assertTrue(config['tsp']) + + def test_windows_verification_requires_valid_signature_and_timestamp(self): + file = self.root/'test.exe' + for status, timestamped, expected in [('NotSigned',False,'unsigned'),('Valid',True,'authenticode'), + ('Valid',False,None),('HashMismatch',True,None)]: + result = SimpleNamespace(stdout=json.dumps({'status':status, 'timestamped':timestamped, 'publisher':'CN=Fixture'})) + with self.subTest(status=status,timestamped=timestamped), patch.object(signing,'run',return_value=result): + if expected: + self.assertEqual(signing.windows_verification(file)['verification'], expected) + else: + with self.assertRaises(ValueError): signing.windows_verification(file) + + def test_macos_developer_id_requires_stapled_ticket(self): + details = SimpleNamespace(stderr='Authority=Developer ID Application: Fixture\n') + with patch.object(signing,'run',side_effect=[SimpleNamespace(),details,SimpleNamespace()]) as native: + result = signing.verify_app(self.root/'HireFerry.app') + self.assertEqual(result['verification'], 'developer-id-notarized') + self.assertEqual(native.call_args.args[0][:3], ['xcrun','stapler','validate']) + with patch.object(signing,'run',side_effect=[SimpleNamespace(),details,ValueError('not stapled')]): + with self.assertRaisesRegex(ValueError,'not stapled'): + signing.verify_app(self.root/'HireFerry.app') + + +if __name__ == '__main__': unittest.main() diff --git a/tests/release.test.py b/tests/release.test.py index f4a7db6..9c3be15 100644 --- a/tests/release.test.py +++ b/tests/release.test.py @@ -30,6 +30,33 @@ def setUp(self): (folder/name).write_bytes(('real bytes for '+name).encode()) release.checksums(folder) + def signing_reports(self, files, wanted): + reports = {} + for name, item in wanted.items(): + if item['product'] != 'desktop' or item['format'] == 'flatpak': + continue + state = {'Windows':'authenticode','macOS':'developer-id-notarized','Linux':'checksum-only'}[item['platform']] + entry = dict(verification=state, sha256=release.digest(files[name]), size=files[name].stat().st_size) + if item['platform'] != 'Linux': entry['publisher'] = 'Test fixture; not a real signing assertion' + report = reports.setdefault(item['target'], dict(schema_version=1,target=item['target'],assets={})) + report['assets'][name] = entry + return reports + + def add_signing_reports(self, unsigned=False): + files = release.verified_inputs(self.source, self.wanted) + reports = self.signing_reports(files, self.wanted) + for index, (target, report) in enumerate(reports.items()): + if unsigned: + for entry in report['assets'].values(): + if entry['verification']=='authenticode': entry['verification']='unsigned' + elif entry['verification']=='developer-id-notarized': entry['verification']='ad-hoc' + entry.pop('publisher', None) + folder = self.source/f'report-{index}' + folder.mkdir() + (folder/release.signing_report_name(target)).write_text(json.dumps(report)) + release.checksums(folder) + return reports + def test_complete_release_has_exact_links_hashes_and_sizes(self): files = release.verified_inputs(self.source, self.wanted) self.assertEqual(len(files), 21) @@ -95,6 +122,7 @@ def test_failed_assembly_writes_no_partial_release(self): self.assertFalse(args.destination.exists()) def test_assembly_preserves_cli_version_and_hashes_metadata(self): + self.add_signing_reports() args=argparse.Namespace(source=self.source,destination=self.root/'out',tag='desktop-v0.1.0',repository=None,commit='abc') with patch.object(release,'package_version',side_effect=lambda product:self.versions[product]): release.assemble(args) self.assertEqual((args.destination/'VERSION').read_text(),'0.1.2\n') @@ -102,6 +130,46 @@ def test_assembly_preserves_cli_version_and_hashes_metadata(self): for name in ('VERSION','downloads.md','downloads.json','release-matrix.svg'): self.assertIn(release.digest(args.destination/name)+' '+name,sums) self.assertEqual(json.loads((args.destination/'downloads.json').read_text())['source_commit'],'abc') + release.verify_publication(argparse.Namespace(directory=args.destination)) + + def test_formal_desktop_assembly_rejects_missing_or_unsigned_reports(self): + args=argparse.Namespace(source=self.source,destination=self.root/'out',tag='desktop-v0.1.0',repository=None,commit='abc') + with patch.object(release,'package_version',side_effect=lambda product:self.versions[product]): + with self.assertRaisesRegex(ValueError, 'Incomplete release'): + release.assemble(args) + self.add_signing_reports(unsigned=True) + with self.assertRaisesRegex(ValueError, 'native publisher signing'): + release.assemble(args) + self.assertFalse(args.destination.exists()) + + def test_engineering_artifacts_never_become_public_downloads(self): + self.add_signing_reports(unsigned=True) + args=argparse.Namespace(source=self.source,destination=self.root/'out',tag='desktop-v0.1.0',repository=None,commit='abc',distribution='engineering') + with patch.object(release,'package_version',side_effect=lambda product:self.versions[product]): + release.assemble(args) + manifest_path = args.destination/'downloads.json' + manifest = release.validate_manifest(json.loads(manifest_path.read_text())) + self.assertEqual(manifest['distribution'], 'engineering') + text = (args.destination/'downloads.md').read_text() + self.assertIn('工程验证产物', text) + self.assertNotIn('/releases/download/', text) + with self.assertRaisesRegex(ValueError, 'Engineering artifacts'): + release.verify_publication(argparse.Namespace(directory=args.destination)) + with self.assertRaisesRegex(ValueError, 'Engineering artifacts'): + release.docs(argparse.Namespace(manifest=manifest_path, check=False)) + + def test_signing_report_is_bound_to_final_asset_bytes(self): + self.add_signing_reports() + report_path = next(self.source.rglob('desktop-signing-*.json')) + report = json.loads(report_path.read_text()) + next(iter(report['assets'].values()))['sha256'] = '0'*64 + report_path.write_text(json.dumps(report)) + release.checksums(report_path.parent) + args=argparse.Namespace(source=self.source,destination=self.root/'out',tag='desktop-v0.1.0',repository=None,commit='abc') + with patch.object(release,'package_version',side_effect=lambda product:self.versions[product]): + with self.assertRaisesRegex(ValueError, 'does not match package bytes'): + release.assemble(args) + self.assertFalse(args.destination.exists()) def test_macos_app_archive_is_created_without_updater(self): bundles=self.root/'bundle'; app=bundles/'macos/HireFerry.app/Contents/MacOS' @@ -173,7 +241,10 @@ def released_fixture(self, versions, tag, data=None, commit='abc'): (folder/name).write_bytes(('package '+name).encode()) release.checksums(folder) files = release.verified_inputs(source, wanted) - return release.make_manifest(data, wanted, files, tag, data['repository'], commit), source + manifest = release.make_manifest(data, wanted, files, tag, data['repository'], commit) + if 'desktop' in versions: + manifest['desktop_signing'] = self.signing_reports(files, wanted) + return manifest, source def test_standalone_cli_assembly_has_six_assets_and_no_desktop_claim(self): _, source = self.released_fixture({'cli':'0.1.2'}, 'cli-v0.1.2') @@ -245,6 +316,7 @@ def test_newer_cli_updates_without_replacing_desktop(self): self.assertEqual(release.merge_manifests(merged, older), merged) self.assertEqual([a for a in merged['assets'] if a['product']=='desktop'], [a for a in desktop['assets'] if a['product']=='desktop']) + self.assertEqual(merged['desktop_signing'], desktop['desktop_signing']) def test_documentation_merge_rejects_prereleases_and_cross_repository(self): stable, _ = self.released_fixture({'cli':'0.1.2'}, 'cli-v0.1.2') From e97e72e9228b050b3297a36d87dad3540488881d Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Fri, 23 Oct 2026 01:43:52 +0800 Subject: [PATCH 2/4] Add desktop AUR recipes with real release checksum gates Keep source and binary distribution separate, generate binary recipes only from published verified assets, and validate metadata and package boundaries with makepkg and bsdtar. --- .github/workflows/aur.yml | 33 ++++++++-- docs/aur.md | 29 +++++++-- packaging/aur/hireferry-desktop-git/.SRCINFO | 28 +++++++++ packaging/aur/hireferry-desktop-git/PKGBUILD | 48 ++++++++++++++ scripts/aur.py | 61 ++++++++++++++---- scripts/publish-aur.sh | 4 +- tests/aur.test.py | 66 +++++++++++++++++++- 7 files changed, 245 insertions(+), 24 deletions(-) create mode 100644 packaging/aur/hireferry-desktop-git/.SRCINFO create mode 100644 packaging/aur/hireferry-desktop-git/PKGBUILD diff --git a/.github/workflows/aur.yml b/.github/workflows/aur.yml index 67aebf8..daaaf6e 100644 --- a/.github/workflows/aur.yml +++ b/.github/workflows/aur.yml @@ -1,6 +1,15 @@ name: Publish AUR packages on: + pull_request: + paths: + - 'packaging/arch/**' + - 'packaging/aur/**' + - 'scripts/aur.py' + - 'scripts/release.py' + - 'scripts/publish-aur.sh' + - 'tests/aur.test.py' + - '.github/workflows/aur.yml' push: branches: [main] paths: @@ -12,7 +21,7 @@ on: workflow_dispatch: inputs: tag: - description: Stable server-v or cli-v tag for -bin; leave empty for both -git packages + description: Stable server-v, cli-v or desktop-v tag for -bin; leave empty for all -git packages type: string default: '' workflow_call: @@ -34,8 +43,24 @@ concurrency: queue: max jobs: + verify: + name: Verify recipes with Arch makepkg + runs-on: ubuntu-24.04 + container: archlinux:base-devel + timeout-minutes: 10 + steps: + - name: Install recipe validation tools + run: pacman -Syu --noconfirm --needed git python + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - name: Verify metadata and component file boundaries without root + run: | + useradd -m builder + runuser -u builder -- python tests/aur.test.py + bash -n scripts/publish-aur.sh + publish: - if: vars.AUR_PUBLISH_ENABLED == 'true' + needs: verify + if: github.event_name != 'pull_request' && vars.AUR_PUBLISH_ENABLED == 'true' runs-on: ubuntu-24.04 container: archlinux:base-devel timeout-minutes: 15 @@ -66,14 +91,14 @@ jobs: RELEASE_TAG: ${{ inputs.tag }} run: | if [[ -n "$RELEASE_TAG" ]]; then - [[ "$RELEASE_TAG" =~ ^(server|cli)-v[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1 + [[ "$RELEASE_TAG" =~ ^(server|cli|desktop)-v[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1 product=${RELEASE_TAG%%-v*} python scripts/fetch-release-manifest.py "$RELEASE_TAG" "$RUNNER_TEMP/aur-manifest" chmod -R a+rX "$RUNNER_TEMP/aur-manifest" runuser -u builder -- python scripts/aur.py --product "$product" --variant bin \ --manifest "$RUNNER_TEMP/aur-manifest/downloads.json" --out dist/aur else - for product in server cli; do + for product in server cli desktop; do runuser -u builder -- python scripts/aur.py --product "$product" --variant git --out dist/aur done fi diff --git a/docs/aur.md b/docs/aur.md index 96f17ad..6fe0fdb 100644 --- a/docs/aur.md +++ b/docs/aur.md @@ -2,14 +2,17 @@ [下载矩阵](downloads.md) · [CLI](cli.md) · [自托管](self-hosting.md) -服务端和客户端 CLI 是独立软件包,都支持 x86_64 与 aarch64: +服务端、客户端 CLI 与桌面 GUI 独立打包,都面向 x86_64 与 aarch64: | 组件 | 从 main 编译 | 安装正式 Release 二进制 | | --- | --- | --- | | 服务端 `hireferry` | `hireferry-server-git` | `hireferry-server-bin` | | 客户端 `hfy` | `hireferry-cli-git` | `hireferry-cli-bin` | +| 桌面 GUI `hireferry-desktop` | 仓库已提供 `hireferry-desktop-git` 配方 | 正式桌面 Release 成功后生成 `hireferry-desktop-bin` | -同一组件的 `-git` 和 `-bin` 提供相同命令,因此互斥。服务端与 CLI 的文件互不重叠,可以同时安装,也可以混用不同变体。安装 CLI 不会安装、编译或启动服务端。桌面 GUI 继续使用[桌面安装包](desktop.md)。 +同一组件的 `-git` 和 `-bin` 提供相同命令,因此互斥。不同组件使用独立的可执行文件与文档目录,可以同时安装,也可以混用不同变体。安装 CLI 或桌面 GUI 不会安装、编译或启动服务端。桌面 GUI 连接已有站点。 + +**桌面 AUR 当前状态:** 此次变更新增配方与发布流程,尚未把“仓库中有 PKGBUILD”视为 AUR 已上架。2026-10-22 核对时没有正式桌面 Release,因此不提交占位的 `-bin` URL 或校验和。main 合入后 AUR 工作流才能更新源码配方;`-bin` 必须等待完整、通过签名门槛的桌面 Release。实际 AUR 发布成功后才能使用对应包名安装。 ```sh # 连接现有站点,只需要 CLI @@ -26,6 +29,14 @@ yay -S hireferry-server-git 也可克隆对应 AUR 仓库,用 `makepkg -si` 构建安装。`-git` 使用锁定依赖,版本由 Cargo 版本、提交数和提交 ID 组成;`-bin` 固定版本和两个架构各自的 SHA-256,不在安装时查询 latest,也不跳过二进制校验。 +## 桌面源码配方与二进制配方 + +源码配方位于 [`packaging/aur/hireferry-desktop-git`](../packaging/aur/hireferry-desktop-git/PKGBUILD)。在 Arch 系统上复制该目录,检查配方后运行 `makepkg --cleanbuild -si`。它使用独立的 `desktop/src-tauri/Cargo.toml`、锁定依赖与 `custom-protocol` feature,仅构建 `hireferry-desktop`,不要求 Node 构建步骤或服务器 Cargo workspace。Rust 需至少 1.90;运行依赖包含 GTK 3、WebKitGTK 4.1、libsoup 3、OpenSSL 和桌面图标支持。桌面菜单与 SVG 图标分别安装到标准的 applications 与 icons 目录。 + +二进制生成器只从经过验证的正式 `downloads.json` 选择两种 Linux 架构的 `.deb`;AUR 的 `makepkg` 下载并按 `sha256sums_` 校验后解出 Debian 容器,`package()` 再用 `bsdtar` 安装其中的 `data.tar.*`。配方不执行 `.deb` 的安装维护脚本,不查询 latest,不将校验设置为 SKIP。它只接受单个 payload,并检查桌面程序存在、服务端与 CLI 可执行文件不存在。 + +Windows / macOS 的签名策略属于整个正式桌面 Release 的门槛;Linux `.deb` 仍明确只提供 SHA-256 校验,没有因此宣称 Linux 包也具有 Authenticode 或 Apple 签名。签名工程产物和没有验签报告的候选清单不能用于生成公开二进制配方。 + ## 服务端初始化 包安装 `/usr/bin/hireferry`、`hireferry.service`、systemd sysusers 与 tmpfiles 配置。它不自动开启服务、不生成管理员凭据,也不写入生产密钥。配置模板位于 `/usr/share/hireferry/config.example.toml`。 @@ -53,9 +64,9 @@ CLI 的 Agent Skill 位于 `/usr/share/hireferry-cli/skills/hireferry`,可用 | --- | --- | --- | --- | | 服务端 | 根 `Cargo.toml` | `server-vX.Y.Z` | Linux x86_64 / aarch64 归档、下载矩阵、`hireferry-server-bin` | | CLI | `crates/hireferry-cli/Cargo.toml` | `cli-vX.Y.Z` | 六个平台归档、下载矩阵、`hireferry-cli-bin` | -| 桌面 | Tauri / Cargo / npm 同步版本 | `desktop-vX.Y.Z` | 桌面与所含 CLI 归档、下载矩阵 | +| 桌面 | Tauri / Cargo / npm 同步版本 | `desktop-vX.Y.Z` | 桌面与所含 CLI 归档、下载矩阵、`hireferry-desktop-bin` | -发布工作流汇总全部目标,通过完整性和 SHA-256 校验后才发布 GitHub Release。AUR 工作流下载已发布的 `downloads.json` 并用 `SHA256SUMS` 校验,然后生成固定版本的 `PKGBUILD` 和 `.SRCINFO`。旧版本重跑不会降级 AUR 包。修改 AUR 配方、公共 Arch 安装文件或生成器后,main 分支推送会更新两个 `-git` 包。 +发布工作流汇总全部目标,通过完整性和 SHA-256 校验后才发布 GitHub Release。AUR 工作流下载已发布的 `downloads.json` 并用 `SHA256SUMS` 校验,然后生成固定版本的 `PKGBUILD` 和 `.SRCINFO`。旧版本重跑不会降级 AUR 包。修改 AUR 配方、公共 Arch 安装文件或生成器后,main 分支推送会更新三个 `-git` 包。PR 在 Arch `base-devel` 容器中以非 root 用户检查 `.SRCINFO` 和实际配方的文件安装边界;该测试不代替完整编译、安装和图形会话实测。 GitHub 仓库需要配置: @@ -63,14 +74,22 @@ GitHub 仓库需要配置: - `AUR_SSH_PRIVATE_KEY`:已登记到维护者 AUR 账户的自动发布 SSH 私钥。 - `AUR_KNOWN_HOSTS`:通过可信渠道核实的 `aur.archlinux.org` 主机记录。工作流强制核验主机,不临时信任扫描结果。 -发布仅推送配方与必要的 systemd 文件,不上传二进制到 AUR,不强制推送。每个包发布后核对 AUR 远端提交。也可手动生成并发布: +发布仅推送配方、必要的 systemd 文件与桌面二进制包的许可证,不上传二进制到 AUR,不强制推送。每个包发布后核对 AUR 远端提交。也可手动生成并发布: ```sh python3 scripts/aur.py --product server --variant git python3 scripts/aur.py --product cli --variant git +python3 scripts/aur.py --product desktop --variant git python3 scripts/fetch-release-manifest.py server-v0.1.0 dist/server-manifest python3 scripts/aur.py --product server --variant bin --manifest dist/server-manifest/downloads.json bash scripts/publish-aur.sh packaging/aur/hireferry-server-bin ``` 日常验证在本地完成:`python3 tests/release.test.py`、`python3 tests/aur.test.py`、`python3 scripts/release.py docs --check`。实际构建可运行 `makepkg --cleanbuild`;ARM64 包需要在对应架构构建和运行后,才能声称完成该架构的运行验收。 + +桌面正式 Release 发布后,再执行以下同样的校验入口;版本必须换成实际已发布标签: + +```sh +python3 scripts/fetch-release-manifest.py desktop-vX.Y.Z dist/desktop-manifest +python3 scripts/aur.py --product desktop --variant bin --manifest dist/desktop-manifest/downloads.json +``` diff --git a/packaging/aur/hireferry-desktop-git/.SRCINFO b/packaging/aur/hireferry-desktop-git/.SRCINFO new file mode 100644 index 0000000..d796e74 --- /dev/null +++ b/packaging/aur/hireferry-desktop-git/.SRCINFO @@ -0,0 +1,28 @@ +pkgbase = hireferry-desktop-git + pkgdesc = HireFerry desktop workspace, built with Tauri and the system WebView + pkgver = 0.1.0.r1.g16ceda1 + pkgrel = 1 + url = https://github.com/TokenNotIncluded/hireferry + arch = x86_64 + arch = aarch64 + license = AGPL-3.0-or-later + makedepends = cargo + makedepends = git + makedepends = pkgconf + depends = glibc + depends = gcc-libs + depends = openssl + depends = ca-certificates + depends = gtk3 + depends = webkit2gtk-4.1 + depends = libsoup3 + depends = hicolor-icon-theme + depends = desktop-file-utils + depends = xdg-utils + provides = hireferry-desktop + conflicts = hireferry-desktop + options = !lto + source = hireferry::git+https://github.com/TokenNotIncluded/hireferry.git#branch=main + sha256sums = SKIP + +pkgname = hireferry-desktop-git diff --git a/packaging/aur/hireferry-desktop-git/PKGBUILD b/packaging/aur/hireferry-desktop-git/PKGBUILD new file mode 100644 index 0000000..f32f52e --- /dev/null +++ b/packaging/aur/hireferry-desktop-git/PKGBUILD @@ -0,0 +1,48 @@ +# Maintainer: HireFerry contributors +# Generated by scripts/aur.py; edit the generator in the upstream repository. +pkgname=hireferry-desktop-git +pkgver=0.1.0.r1.g16ceda1 +pkgrel=1 +pkgdesc='HireFerry desktop workspace, built with Tauri and the system WebView' +arch=('x86_64' 'aarch64') +url='https://github.com/TokenNotIncluded/hireferry' +license=('AGPL-3.0-or-later') +depends=('glibc' 'gcc-libs' 'openssl' 'ca-certificates' 'gtk3' 'webkit2gtk-4.1' 'libsoup3' 'hicolor-icon-theme' 'desktop-file-utils' 'xdg-utils') +provides=('hireferry-desktop') +conflicts=('hireferry-desktop') +makedepends=('cargo' 'git' 'pkgconf') +options=('!lto') +source=('hireferry::git+https://github.com/TokenNotIncluded/hireferry.git#branch=main') +sha256sums=('SKIP') +_target="$CARCH-unknown-linux-gnu" + +pkgver() { + cd "$srcdir/hireferry" + local version + version=$(sed -n 's/^version = "\([^"]*\)"$/\1/p' desktop/src-tauri/Cargo.toml | head -n 1) + printf '%s.r%s.g%s' "${version//-/.}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +prepare() { + cd "$srcdir/hireferry" + cargo fetch --locked --target "$_target" --manifest-path desktop/src-tauri/Cargo.toml +} + +build() { + cd "$srcdir/hireferry" + CARGO_TARGET_DIR=target cargo build --frozen --release --target "$_target" --manifest-path desktop/src-tauri/Cargo.toml --bin hireferry-desktop --features custom-protocol +} + +check() { + cd "$srcdir/hireferry" + CARGO_TARGET_DIR=target cargo test --frozen --target "$_target" --manifest-path desktop/src-tauri/Cargo.toml --bin hireferry-desktop --features custom-protocol +} + +package() { + cd "$srcdir/hireferry" + install -Dm755 target/$_target/release/hireferry-desktop "$pkgdir/usr/bin/hireferry-desktop" + install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" + install -Dm644 packaging/flatpak/best.lmm.hireferry.desktop "$pkgdir/usr/share/applications/best.lmm.hireferry.desktop" + install -Dm644 desktop/src-tauri/icons/icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/best.lmm.hireferry.svg" + install -Dm644 docs/desktop.md "$pkgdir/usr/share/doc/hireferry-desktop/README.md" +} diff --git a/scripts/aur.py b/scripts/aur.py index 93fb1e2..fa84915 100644 --- a/scripts/aur.py +++ b/scripts/aur.py @@ -12,6 +12,26 @@ def package_body(product, source): + if product == 'desktop': + if source == '$srcdir/hireferry': + return '\n'.join([ + f' cd "{source}"', + ' install -Dm755 target/$_target/release/hireferry-desktop "$pkgdir/usr/bin/hireferry-desktop"', + ' install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"', + ' install -Dm644 packaging/flatpak/best.lmm.hireferry.desktop "$pkgdir/usr/share/applications/best.lmm.hireferry.desktop"', + ' install -Dm644 desktop/src-tauri/icons/icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/best.lmm.hireferry.svg"', + ' install -Dm644 docs/desktop.md "$pkgdir/usr/share/doc/hireferry-desktop/README.md"', + ]) + return '\n'.join([ + ' local archives=("$srcdir"/data.tar.*)', + ' (( ${#archives[@]} == 1 )) || return 1', + ' [[ -f ${archives[0]} ]] || return 1', + ' bsdtar -xpf "${archives[0]}" -C "$pkgdir"', + ' test -x "$pkgdir/usr/bin/hireferry-desktop"', + ' test ! -e "$pkgdir/usr/bin/hireferry"', + ' test ! -e "$pkgdir/usr/bin/hfy"', + ' install -Dm644 "$srcdir/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"', + ]) lines = [f' cd "{source}"', f' install -Dm755 {"target/$_target/release/" if source == "$srcdir/hireferry" else ""}{"hireferry" if product == "server" else "hfy"} "$pkgdir/usr/bin/{"hireferry" if product == "server" else "hfy"}"', ' install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"'] @@ -34,8 +54,14 @@ def package_body(product, source): def render(product, variant, pkgver, manifest=None): base = f'hireferry-{product}' name = f'{base}-{variant}' - description = 'Self-hosted recruitment server with an embedded web UI' if product == 'server' else 'Command-line client for HireFerry (hfy)' - dependencies = "'glibc' 'gcc-libs' 'openssl' 'ca-certificates' 'systemd'" if product == 'server' else ("'ca-certificates'" if variant == 'bin' else "'glibc' 'gcc-libs' 'ca-certificates'") + if product not in ('server', 'cli', 'desktop') or variant not in ('git', 'bin'): + raise ValueError('Unsupported AUR product or variant') + description = {'server':'Self-hosted recruitment server with an embedded web UI', + 'cli':'Command-line client for HireFerry (hfy)', + 'desktop':'HireFerry desktop workspace, built with Tauri and the system WebView'}[product] + dependencies = {'server':"'glibc' 'gcc-libs' 'openssl' 'ca-certificates' 'systemd'", + 'cli':"'ca-certificates'" if variant == 'bin' else "'glibc' 'gcc-libs' 'ca-certificates'", + 'desktop':"'glibc' 'gcc-libs' 'openssl' 'ca-certificates' 'gtk3' 'webkit2gtk-4.1' 'libsoup3' 'hicolor-icon-theme' 'desktop-file-utils' 'xdg-utils'"}[product] text = f'''# Maintainer: HireFerry contributors # Generated by scripts/aur.py; edit the generator in the upstream repository. pkgname={name} @@ -53,8 +79,10 @@ def render(product, variant, pkgver, manifest=None): text += "optdepends=('xdg-utils: open browser for interactive login')\n" if variant == 'git': cargo_package = 'hireferry' if product == 'server' else 'hireferry-cli' - cargo_toml = 'Cargo.toml' if product == 'server' else 'crates/hireferry-cli/Cargo.toml' - text += f'''makedepends=('cargo' 'git'{" 'pkgconf'" if product == 'server' else ''}) + cargo_toml = {'server':'Cargo.toml','cli':'crates/hireferry-cli/Cargo.toml','desktop':'desktop/src-tauri/Cargo.toml'}[product] + manifest_arg = ' --manifest-path desktop/src-tauri/Cargo.toml' if product == 'desktop' else '' + build_arg = '--manifest-path desktop/src-tauri/Cargo.toml --bin hireferry-desktop --features custom-protocol' if product == 'desktop' else f'-p {cargo_package}' + text += f'''makedepends=('cargo' 'git'{" 'pkgconf'" if product in ('server', 'desktop') else ''}) options=('!lto') source=('hireferry::git+https://github.com/TokenNotIncluded/hireferry.git#branch=main') sha256sums=('SKIP') @@ -69,17 +97,17 @@ def render(product, variant, pkgver, manifest=None): prepare() {{ cd "$srcdir/hireferry" - cargo fetch --locked --target "$_target" + cargo fetch --locked --target "$_target"{manifest_arg} }} build() {{ cd "$srcdir/hireferry" - CARGO_TARGET_DIR=target cargo build --frozen --release --target "$_target" -p {cargo_package} + CARGO_TARGET_DIR=target cargo build --frozen --release --target "$_target" {build_arg} }} check() {{ cd "$srcdir/hireferry" - CARGO_TARGET_DIR=target cargo test --frozen --target "$_target" -p {cargo_package} + CARGO_TARGET_DIR=target cargo test --frozen --target "$_target" {build_arg} }} package() {{ @@ -87,19 +115,23 @@ def render(product, variant, pkgver, manifest=None): }} ''' else: - assets = {a['architecture']:a for a in manifest['assets'] if a['product'] == product and a['platform'] == 'Linux'} - if set(assets) != {'x86_64', 'aarch64'}: + linux = [a for a in manifest['assets'] if a['product'] == product and a['platform'] == 'Linux' + and (product != 'desktop' or a['format'] == 'deb')] + assets = {a['architecture']:a for a in linux} + if set(assets) != {'x86_64', 'aarch64'} or len(linux) != 2: raise ValueError('Binary AUR packages require exactly x86_64 and aarch64 Linux assets') for arch, asset in assets.items(): - expected = f'{arch}-unknown-linux-' + ('gnu' if product == 'server' else 'musl') - if asset['target'] != expected or asset['format'] != 'tar.gz': + expected = f'{arch}-unknown-linux-' + ('musl' if product == 'cli' else 'gnu') + if asset['target'] != expected or asset['format'] != ('deb' if product == 'desktop' else 'tar.gz'): raise ValueError('Unexpected AUR binary target or archive format') text += f"source_{arch}=('{asset['url']}')\nsha256sums_{arch}=('{asset['sha256']}')\n" text += "options=('!strip' '!debug')\n" if product == 'server': text += "source=('hireferry.service' 'hireferry.sysusers' 'hireferry.tmpfiles')\n" text += 'sha256sums=(' + ' '.join("'"+release.digest(ROOT/'packaging/arch'/f)+"'" for f in ('hireferry.service','hireferry.sysusers','hireferry.tmpfiles')) + ')\n' - target = '$CARCH-unknown-linux-' + ('gnu' if product == 'server' else 'musl') + elif product == 'desktop': + text += "source=('LICENSE')\nsha256sums=('" + release.digest(ROOT/'LICENSE') + "')\n" + target = '$CARCH-unknown-linux-' + ('musl' if product == 'cli' else 'gnu') text += f'''\npackage() {{ {package_body(product, f'$srcdir/hireferry-{product}-{manifest["versions"][product]}-{target}')} }} @@ -114,6 +146,7 @@ def generate(args): raise ValueError('A binary recipe requires a verified manifest for the product') if manifest['repository'] != 'TokenNotIncluded/hireferry': raise ValueError('AUR recipes require the official upstream repository') + release.require_publishable(manifest) pkgver = manifest['versions'][args.product] release.stable_version(pkgver) else: @@ -127,6 +160,8 @@ def generate(args): if args.product == 'server' and args.variant == 'bin': for file in ('hireferry.service','hireferry.sysusers','hireferry.tmpfiles'): shutil.copyfile(ROOT/'packaging/arch'/file, folder/file) + if args.product == 'desktop' and args.variant == 'bin': + shutil.copyfile(ROOT/'LICENSE', folder/'LICENSE') info = subprocess.check_output(['makepkg','--printsrcinfo'], cwd=folder, text=True) (folder/'.SRCINFO').write_text(info) print(folder) @@ -134,7 +169,7 @@ def generate(args): if __name__ == '__main__': parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('--product', choices=('server','cli'), required=True) + parser.add_argument('--product', choices=('server','cli','desktop'), required=True) parser.add_argument('--variant', choices=('git','bin'), required=True) parser.add_argument('--manifest', type=Path) parser.add_argument('--out', type=Path, default=ROOT/'packaging/aur') diff --git a/scripts/publish-aur.sh b/scripts/publish-aur.sh index 8c29f8e..209a62f 100755 --- a/scripts/publish-aur.sh +++ b/scripts/publish-aur.sh @@ -7,7 +7,7 @@ trap 'rm -rf -- "$work"' EXIT for recipe in "$@"; do recipe=$(realpath "$recipe") name=$(basename "$recipe") - [[ $name =~ ^hireferry-(server|cli)-(git|bin)$ ]] || { echo "Unexpected package: $name" >&2; exit 1; } + [[ $name =~ ^hireferry-(server|cli|desktop)-(git|bin)$ ]] || { echo "Unexpected package: $name" >&2; exit 1; } (cd "$recipe" && makepkg --printsrcinfo) > "$work/SRCINFO" cmp "$work/SRCINFO" "$recipe/.SRCINFO" version=$(sed -n 's/^[[:space:]]*pkgver = //p' "$recipe/.SRCINFO") @@ -23,6 +23,8 @@ for recipe in "$@"; do allowed=(PKGBUILD .SRCINFO) if [[ $name == hireferry-server-bin ]]; then allowed+=(hireferry.service hireferry.sysusers hireferry.tmpfiles) + elif [[ $name == hireferry-desktop-bin ]]; then + allowed+=(LICENSE) fi for file in "${allowed[@]}"; do [[ -f $recipe/$file && ! -L $recipe/$file ]] diff --git a/tests/aur.test.py b/tests/aur.test.py index 59978f0..5bdc3b2 100644 --- a/tests/aur.test.py +++ b/tests/aur.test.py @@ -1,10 +1,13 @@ #!/usr/bin/env python3 """Exercise actual PKGBUILD package functions in an isolated filesystem.""" from pathlib import Path +import argparse +import json import shutil import subprocess import sys import tempfile +import tarfile import unittest ROOT = Path(__file__).resolve().parents[1] @@ -74,6 +77,64 @@ def test_git_recipes_build_only_requested_cargo_package(self): self.assertIn('cargo build --frozen',text) self.assertNotIn('--workspace',text) + def test_desktop_git_builds_the_isolated_shell_and_installs_desktop_integration(self): + name, text = aur.render('desktop','git','0.1.0.r1.gabc') + self.assertIn('--manifest-path desktop/src-tauri/Cargo.toml --bin hireferry-desktop --features custom-protocol',text) + self.assertNotIn('--workspace',text) + folder = self.root/name + source = folder/'src/hireferry' + binary = source/'target/x86_64-unknown-linux-gnu/release/hireferry-desktop' + binary.parent.mkdir(parents=True) + binary.write_text('#!/bin/sh\nexit 0\n') + for file in ('LICENSE','packaging/flatpak/best.lmm.hireferry.desktop','desktop/src-tauri/icons/icon.svg','docs/desktop.md'): + destination = source/file + destination.parent.mkdir(parents=True,exist_ok=True) + shutil.copyfile(ROOT/file,destination) + (folder/'PKGBUILD').write_text(text) + out = folder/'pkg' + subprocess.run(['bash','-eu','-c','CARCH=x86_64; source ./PKGBUILD; srcdir=$1; pkgdir=$2; package', + 'package-test',str(folder/'src'),str(out)],cwd=folder,check=True,capture_output=True) + self.assertTrue((out/'usr/bin/hireferry-desktop').is_file()) + self.assertFalse((out/'usr/bin/hfy').exists()) + self.assertFalse((out/'usr/bin/hireferry').exists()) + self.assertTrue((out/'usr/share/applications/best.lmm.hireferry.desktop').is_file()) + self.assertTrue((out/'usr/share/icons/hicolor/scalable/apps/best.lmm.hireferry.svg').is_file()) + + def test_desktop_bin_extracts_deb_payload_without_installing_server_or_cli(self): + if not shutil.which('bsdtar'): + self.skipTest('bsdtar is not available on this platform') + manifest = self.manifest('desktop') + name, text = aur.render('desktop','bin',manifest['versions']['desktop'],manifest) + folder = self.root/name + source = folder/'src' + source.mkdir(parents=True) + binary = self.root/'payload/usr/bin/hireferry-desktop' + binary.parent.mkdir(parents=True) + binary.write_text('#!/bin/sh\nexit 0\n'); binary.chmod(0o755) + with tarfile.open(source/'data.tar.gz','w:gz') as archive: + archive.add(binary,arcname='usr/bin/hireferry-desktop') + shutil.copyfile(ROOT/'LICENSE',source/'LICENSE') + (folder/'PKGBUILD').write_text(text) + out = folder/'pkg'; out.mkdir() + subprocess.run(['bash','-eu','-c','CARCH=x86_64; source ./PKGBUILD; srcdir=$1; pkgdir=$2; package', + 'package-test',str(source),str(out)],cwd=folder,check=True,capture_output=True) + self.assertTrue((out/'usr/bin/hireferry-desktop').is_file()) + self.assertTrue((out/f'usr/share/licenses/{name}/LICENSE').is_file()) + self.assertFalse((out/'usr/bin/hfy').exists()) + self.assertNotIn('.AppImage',text) + self.assertNotIn('SKIP',text) + self.assertNotIn('cargo ',text) + + def test_desktop_bin_generator_rejects_unpublished_and_unsigned_inputs(self): + for distribution in ('engineering','release'): + manifest = self.manifest('desktop') + manifest['distribution'] = distribution + path = self.root/'manifest.json'; path.write_text(json.dumps(manifest)) + args = argparse.Namespace(product='desktop',variant='bin',manifest=path,out=self.root/'out') + with self.subTest(distribution=distribution), self.assertRaises(ValueError): + aur.generate(args) + self.assertFalse(args.out.exists()) + def test_binary_generator_rejects_missing_or_wrong_architecture(self): manifest = self.manifest('server') manifest['assets'] = manifest['assets'][:1] @@ -88,7 +149,10 @@ def test_checked_in_srcinfo_matches_makepkg(self): if not shutil.which('makepkg'): self.skipTest('makepkg is not available on this platform') for folder in (ROOT/'packaging/aur').glob('hireferry-*'): - generated = subprocess.check_output(['makepkg','--printsrcinfo'],cwd=folder,text=True) + # Read-only source checkouts are supported; makepkg expects a writable cwd. + temporary = self.root/folder.name + shutil.copytree(folder,temporary) + generated = subprocess.check_output(['makepkg','--printsrcinfo'],cwd=temporary,text=True) self.assertEqual(generated,(folder/'.SRCINFO').read_text(),str(folder)) From 2d5b8cb1038014cdb9f3c47f71315564164509a4 Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Fri, 23 Oct 2026 02:21:57 +0800 Subject: [PATCH 3/4] Label engineering artifacts accurately in release matrix accessibility text --- docs/assets/release-matrix.svg | 2 +- scripts/release.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/assets/release-matrix.svg b/docs/assets/release-matrix.svg index 9f2d7ff..f25e0c1 100644 --- a/docs/assets/release-matrix.svg +++ b/docs/assets/release-matrix.svg @@ -1,5 +1,5 @@ -HireFerry release matrixPackage availability by operating system and architecture; 8 package variants. Published package checksums are verified. +HireFerry release matrixPackage availability by operating system and architecture; 8 package variants. Package integrity recorded with SHA-256. diff --git a/scripts/release.py b/scripts/release.py index 492fb73..0050737 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -457,7 +457,7 @@ def svg(data, manifest=None): products = ' + '.join(label for label, present in (('Desktop', desktop_rows), ('hfy CLI', cli_rows), ('Server', server_rows)) if present) or 'No published packages' cards.append(f'{mark}{platform}{html.escape(architectures)}{html.escape(formats)}{products}') return f''' -HireFerry release matrixPackage availability by operating system and architecture; {count} package variants. {'Published package checksums are verified.' if manifest else 'Configured build targets, not a claim of published or tested packages.'} +HireFerry release matrixPackage availability by operating system and architecture; {count} package variants. {'Package integrity recorded with SHA-256.' if manifest else 'Configured build targets, not a claim of published or tested packages.'} From d2a5ef9b1fe0deae1548ca8ddb343e6c69f47d3c Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Fri, 23 Oct 2026 02:21:59 +0800 Subject: [PATCH 4/4] Record verified six-platform desktop packages and engineering signing status --- docs/desktop-release-status.md | 32 +++++++++++++++++++------------- docs/desktop.md | 2 +- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/docs/desktop-release-status.md b/docs/desktop-release-status.md index 49b3b86..0f75268 100644 --- a/docs/desktop-release-status.md +++ b/docs/desktop-release-status.md @@ -13,32 +13,38 @@ GitHub 仓库通用 `/releases/latest` 用于现有 CLI 安装器。桌面、服务端保持独立标签与下载入口;桌面发布使用 `--latest=false`,不会改变 CLI 的 latest。 -## 已经完成的一轮桌面工程构建 +## 本次提交的桌面工程验收 -证据:[Desktop and CLI packages,run 39735931535](https://github.com/TokenNotIncluded/hireferry/actions/runs/39735931535),源码提交 `4bd3963c295e68960b00d7df51e878c000a2baea`。这是本次补齐之前的 PR 验证记录,不代表随后修改过的提交已经通过同样检查。 +证据:[Desktop and CLI packages,run 39827315512](https://github.com/TokenNotIncluded/hireferry/actions/runs/39827315512),分支提交 `bb2f513dd14f9d2c16e760b65f9498d8de06fe82`,2026-10-22 全部构建与汇总成功。该记录对应桌面发行分支;随后把移动端共享 Tauri 代码合入的集成提交仍须独立运行同样工作流。 -| 平台 / 架构 | 构建及单元测试 | 当时的原生界面启动验证 | 包格式 | +| 平台 / 架构 | 构建、单元测试及原生界面启动 | 已生成并校验的包 | 本轮签名状态 | | --- | --- | --- | --- | -| Linux x64 | 通过 | WebKit 启动器通过 | `.deb`、`.rpm`、`.AppImage` | -| Linux ARM64 | 通过 | WebKit 启动器通过 | `.deb`、`.rpm`、`.AppImage` | -| Windows x64 | 通过 | 当时未运行 GUI smoke | NSIS `.exe`、`.msi` | -| Windows ARM64 | 通过 | 当时未运行 GUI smoke | NSIS `.exe` | -| macOS Intel x64 | 通过 | 当时未运行 GUI smoke | `.dmg`、`.app.tar.gz` | -| macOS Apple Silicon | 通过 | 当时未运行 GUI smoke | `.dmg`、`.app.tar.gz` | -| Flatpak x64 / ARM64 | 两者通过 | 运行时依赖、版本检查与启动器 smoke 通过 | 各一个 `.flatpak` | +| Linux x64 | 通过,真实 WebKit 启动器 | `.deb`、`.rpm`、`.AppImage` | SHA-256 完整性校验 | +| Linux ARM64 | 通过,真实 WebKit 启动器 | `.deb`、`.rpm`、`.AppImage` | SHA-256 完整性校验 | +| Windows x64 | 通过,原生 WebView2 启动器 | NSIS `.exe`、`.msi` | unsigned,工程验证 | +| Windows ARM64 | 通过,原生 WebView2 启动器 | NSIS `.exe` | unsigned,工程验证 | +| macOS Intel x64 | 通过,原生 WebKit 启动器 | `.dmg`、`.app.tar.gz` | ad-hoc;未使用 Developer ID / 公证 | +| macOS Apple Silicon | 通过,原生 WebKit 启动器 | `.dmg`、`.app.tar.gz` | ad-hoc;未使用 Developer ID / 公证 | +| Flatpak x64 / ARM64 | 两者通过,运行时与启动器 smoke | 各一个 `.flatpak` | 单文件工程包,未上架 Flathub | -该轮完整产物汇总成功,发布 job 被跳过。构建未配置维护者的 Apple / Windows 证书,因此没有被记为平台发行签名通过。CI artifact 的有效期和可下载性由 GitHub 保留策略决定,文档不把它当作永久安装地址。 +本轮实际生成 **15 个桌面包与 6 个 CLI 归档**。汇总步骤成功验证全部包名、大小、SHA-256,以及与最终包字节绑定的签名分类报告,生成 Markdown、SVG 和 JSON。macOS 最终 DMG 挂载验证已修正许可证分页与确认交互;两种架构均通过。正式发布、下载页写回和 AUR 发布 job 均按工程构建规则跳过。 + +验收产物保存在上述 run 的 Actions artifacts 中,清单标记 `distribution=engineering`。它们不是正式 Releases 下载入口;其有效期及下载权限受 GitHub artifact 保留策略控制。不能将 Windows unsigned、macOS ad-hoc 结果写成维护者证书签名或公证成功。 + +AUR 另有 [run 39827315453](https://github.com/TokenNotIncluded/hireferry/actions/runs/39827315453) 成功记录:真实 Arch `base-devel` 下的配方元数据与安装边界验证通过。本次没有向 AUR 发布包。 + +历史基线 [run 39735931535](https://github.com/TokenNotIncluded/hireferry/actions/runs/39735931535) 只作追溯,不能替代上述提交的结果。 ## 此次新增的验证门槛 -- 相关路径 PR 自动运行六平台原生构建、单元测试、各自 WebView 启动器 smoke,以及两架构 Flatpak;Windows / macOS GUI smoke 是本次新增,只有新提交的工作流成功后才能在上表新增结果。 +- 相关路径 PR 自动运行六平台原生构建、单元测试、各自 WebView 启动器 smoke,以及两架构 Flatpak;Windows / macOS GUI smoke 已在上述提交实际通过。 - PR 与普通手动构建标记 `distribution=engineering`;工程清单禁止自动写入公开下载页或生成 AUR 二进制配方。PR 不接收签名 secrets。 - `desktop-vX.Y.Z` 正式标签构建必须先通过凭据完整性检查,再实际验签最终包。Windows 要求有效 Authenticode 与时间戳;macOS 要求 Developer ID 签名和 stapler 验证,验证对象是最终 DMG 与 `.app.tar.gz` 内的应用。 - 每个原生目标输出包含最终包名、大小、SHA-256、签名分类的报告。汇总再次检查报告与包字节一致;发布步骤再次验证完整目录,不允许工程清单转为正式发布。 - Linux 报告明确为 `checksum-only`,不把完整性校验称作平台发布者签名。Flatpak 是单文件分发,不表示已经上架 Flathub。 - AUR 验证工作流在 Arch `base-devel` 中以普通用户执行真实 `makepkg --printsrcinfo` 与配方文件安装边界测试;桌面 source 配方与 Release 二进制配方分别处理,后者只从正式清单取两个 Linux `.deb` 的校验和。 -本地签名策略测试使用模拟的原生命令结果来验证拒绝条件,不代表已经有真实签名证书。此次环境只运行 Python 发布门槛测试、真实 makepkg 元数据生成和 bsdtar 文件安装测试;六平台运行与真实签名必须以对应 GitHub 工作流和最终包验签结果为准。 +本地签名策略测试使用模拟的原生命令结果来验证拒绝条件,不代表已经有真实签名证书。本地运行 Python 发布门槛测试;真实 makepkg 元数据、bsdtar 安装边界、六平台原生启动及最终包验证以上述 GitHub 工作流为证。维护者真实签名与公证尚未运行。 ## 实际发布还需要什么 diff --git a/docs/desktop.md b/docs/desktop.md index 9cdfb61..baee745 100644 --- a/docs/desktop.md +++ b/docs/desktop.md @@ -10,7 +10,7 @@ ## 当前可安装版本 -下载入口以 [自动生成的下载矩阵](downloads.md) 为准。2026-10-22 核对时,正式 Release 为 **CLI 0.1.3、服务端 0.1.0**,尚无正式桌面 Release。六个平台已有一轮工程构建成功记录,但临时 CI artifact 不作为正式下载安装入口。详细证据和待验证项见 [桌面发行验收记录](desktop-release-status.md)。 +下载入口以 [自动生成的下载矩阵](downloads.md) 为准。2026-10-22 核对时,正式 Release 为 **CLI 0.1.3、服务端 0.1.0**,尚无正式桌面 Release。本次发行分支已通过六平台原生启动、15 个桌面包与两架构 Flatpak 的工程验收,但临时 CI artifact 不作为正式下载安装入口。详细证据和待验证项见 [桌面发行验收记录](desktop-release-status.md)。 ## 选择安装包