cc-haha/.github/workflows/release-desktop.yml
程序员阿江(Relakkes) 9719726cd2 feat: make quality gates observable and enforceable
The repository now has a measurable PR quality path instead of a loose set of
manual checks. Coverage, quarantine governance, provider smoke, desktop smoke,
and workflow wiring all produce durable reports that contributors and maintainers
can inspect without reconstructing terminal output.

This also fixes the desktop smoke current-runtime path so browser-driven smoke
runs use the desktop default active provider instead of forcing the official
current model, and records that runtime decision as an artifact.

Constraint: Default PR gates must remain non-live and contributor-safe while live model checks stay explicit.
Constraint: Release packaging is still GitHub Actions based, so release preflight must run before the build matrix.
Rejected: Make live provider or desktop smoke mandatory on every PR | secrets, quotas, and model availability are maintainer-controlled.
Rejected: Let PRs lower coverage baselines in the same change | base-branch ratchet comparison must remain authoritative.
Confidence: high
Scope-risk: moderate
Directive: Do not relax coverage or quarantine policy without a maintainer approval label and a fresh quality report.
Tested: ALLOW_CLI_CORE_CHANGE=1 ALLOW_COVERAGE_BASELINE_CHANGE=1 bun run quality:gate --mode pr
Tested: bun run quality:gate --mode baseline --allow-live --only provider-smoke:* --provider-model nvidia-custom:main:nvidia-custom-main --artifacts-dir /tmp/quality-gate-live-smoke
Tested: bun run quality:gate --mode baseline --allow-live --only desktop-smoke:* --provider-model current:current:current-runtime --artifacts-dir /tmp/quality-gate-desktop-smoke-fixed
Tested: git diff --check
Not-tested: Full live release mode with multiple providers in hosted CI; provider credentials and quota remain maintainer-controlled.
2026-05-06 16:25:10 +08:00

248 lines
7.8 KiB
YAML

name: Release Desktop
on:
push:
tags: ['v*.*.*']
workflow_dispatch:
inputs:
draft:
description: 'Create as draft release'
required: false
default: true
type: boolean
permissions:
contents: write
concurrency:
group: release-desktop-${{ github.ref }}
cancel-in-progress: true
jobs:
quality-preflight:
name: Quality preflight
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential curl wget file \
libxdo-dev libssl-dev \
libwebkit2gtk-4.1-dev \
libayatana-appindicator3-dev \
librsvg2-dev patchelf \
libfuse2
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install root dependencies
run: bun install
- name: Install desktop dependencies
working-directory: desktop
run: bun install
- name: Install adapter dependencies
working-directory: adapters
run: bun install
- name: Run release quality preflight
run: bun run quality:gate --mode pr --artifacts-dir artifacts/quality-runs
- name: Summarize quality report
if: always()
shell: bash
run: |
latest_report="$(find artifacts/quality-runs -name report.md -print | sort | tail -n 1)"
if [ -n "$latest_report" ]; then
cat "$latest_report" >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload quality report
if: always()
uses: actions/upload-artifact@v4
with:
name: release-quality-gate
path: artifacts/quality-runs/
retention-days: 14
build:
needs: quality-preflight
strategy:
fail-fast: false
matrix:
include:
# macOS Apple Silicon
- platform: macos-latest
rust_target: aarch64-apple-darwin
tauri_args: '--target aarch64-apple-darwin'
label: macOS-ARM64
asset_name_pattern: 'Claude-Code-Haha_[version]_macos_arm64_[bundle][ext]'
# macOS Intel
- platform: macos-latest
rust_target: x86_64-apple-darwin
tauri_args: '--target x86_64-apple-darwin'
label: macOS-x64
asset_name_pattern: 'Claude-Code-Haha_[version]_macos_x64_[bundle][ext]'
# Linux x64
- platform: ubuntu-22.04
rust_target: x86_64-unknown-linux-gnu
tauri_args: '--bundles deb'
label: Linux-x64
asset_name_pattern: 'Claude-Code-Haha_[version]_linux_x64_[bundle][ext]'
# Linux ARM64
- platform: ubuntu-22.04-arm
rust_target: aarch64-unknown-linux-gnu
tauri_args: '--bundles deb'
label: Linux-ARM64
asset_name_pattern: 'Claude-Code-Haha_[version]_linux_arm64_[bundle][ext]'
# Windows x64
- platform: windows-latest
rust_target: x86_64-pc-windows-msvc
tauri_args: '--bundles nsis'
label: Windows-x64
asset_name_pattern: 'Claude-Code-Haha_[version]_windows_x64_[bundle][ext]'
runs-on: ${{ matrix.platform }}
name: Build (${{ matrix.label }})
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read version
id: version
shell: bash
run: |
VERSION=$(jq -r '.version' desktop/src-tauri/tauri.conf.json)
echo "value=$VERSION" >> "$GITHUB_OUTPUT"
- name: Validate tag matches version
if: github.event_name == 'push'
shell: bash
run: |
EXPECTED_TAG="v${{ steps.version.outputs.value }}"
if [ "${GITHUB_REF_NAME}" != "$EXPECTED_TAG" ]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match app version ${EXPECTED_TAG}"
exit 1
fi
- name: Load release notes
id: release_notes
shell: bash
run: |
NOTES_FILE="release-notes/v${{ steps.version.outputs.value }}.md"
if [ ! -f "$NOTES_FILE" ]; then
echo "::error::Missing release notes file: $NOTES_FILE"
exit 1
fi
{
echo 'body<<__RELEASE_NOTES__'
cat "$NOTES_FILE"
echo
echo '__RELEASE_NOTES__'
} >> "$GITHUB_OUTPUT"
# ── System dependencies (Linux) ──────────────────────────
- name: Install Linux dependencies
if: contains(matrix.platform, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
curl \
wget \
file \
libxdo-dev \
libssl-dev \
libwebkit2gtk-4.1-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
patchelf \
libfuse2
# ── Bun ──────────────────────────────────────────────────
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
# ── Node.js (for tauri-action compatibility) ─────────────
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
# ── Rust ─────────────────────────────────────────────────
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: 'desktop/src-tauri -> target'
shared-key: ${{ matrix.rust_target }}
# ── Install dependencies ─────────────────────────────────
- name: Install root dependencies
run: bun install
- name: Install desktop dependencies
working-directory: desktop
run: bun install
- name: Install adapter dependencies
working-directory: adapters
run: bun install
# ── Build sidecars ───────────────────────────────────────
- name: Build sidecars
working-directory: desktop
env:
TAURI_ENV_TARGET_TRIPLE: ${{ matrix.rust_target }}
run: bun run build:sidecars
# ── Build Tauri app ──────────────────────────────────────
- name: Build Tauri app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
projectPath: desktop
tauriScript: bunx tauri
tagName: v__VERSION__
releaseName: 'Claude Code Haha v__VERSION__'
releaseBody: ${{ steps.release_notes.outputs.body }}
releaseDraft: ${{ github.event_name == 'workflow_dispatch' && inputs.draft || false }}
prerelease: false
updaterJsonPreferNsis: true
assetNamePattern: ${{ matrix.asset_name_pattern }}
args: ${{ matrix.tauri_args }} --ci --config src-tauri/tauri.release-ci.json