cc-haha/.github/workflows/build-desktop-dev.yml
2026-07-14 03:16:12 +08:00

155 lines
6.1 KiB
YAML

name: Build Desktop (Dev)
on:
workflow_dispatch:
inputs:
platforms:
description: 'Build platforms'
required: true
default: 'all'
type: choice
options:
- all
- macos-arm64
- macos-x64
- windows-x64
- windows-arm64
- linux-x64
- linux-arm64
permissions:
contents: read
concurrency:
group: build-desktop-dev-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
ALL='[{"platform":"macos-latest","target_triple":"aarch64-apple-darwin","builder_args":"--mac dmg zip --arm64","label":"macOS-ARM64","artifact_name":"macos-arm64","smoke_platform":"macos","arch":"arm64"},{"platform":"macos-latest","target_triple":"x86_64-apple-darwin","builder_args":"--mac dmg zip --x64","label":"macOS-x64","artifact_name":"macos-x64","smoke_platform":"macos","arch":"x64"},{"platform":"windows-latest","target_triple":"x86_64-pc-windows-msvc","builder_args":"--win nsis --x64","label":"Windows-x64","artifact_name":"windows-x64","smoke_platform":"windows","arch":"x64"},{"platform":"windows-latest","target_triple":"aarch64-pc-windows-msvc","builder_args":"--win nsis --arm64","label":"Windows-ARM64","artifact_name":"windows-arm64","smoke_platform":"windows","arch":"arm64"},{"platform":"ubuntu-22.04","target_triple":"x86_64-unknown-linux-gnu","builder_args":"--linux AppImage deb --x64","label":"Linux-x64","artifact_name":"linux-x64","smoke_platform":"linux","arch":"x64"},{"platform":"ubuntu-22.04-arm","target_triple":"aarch64-unknown-linux-gnu","builder_args":"--linux AppImage deb --arm64","label":"Linux-ARM64","artifact_name":"linux-arm64","smoke_platform":"linux","arch":"arm64"}]'
SELECTED="${{ inputs.platforms }}"
if [ "$SELECTED" = "all" ]; then
MATRIX=$(echo "$ALL" | jq -c '{include: .}')
else
MATRIX=$(echo "$ALL" | jq -c --arg sel "$SELECTED" '{include: [.[] | select(
($sel == "macos-arm64" and .label == "macOS-ARM64") or
($sel == "macos-x64" and .label == "macOS-x64") or
($sel == "windows-x64" and .label == "Windows-x64") or
($sel == "windows-arm64" and .label == "Windows-ARM64") or
($sel == "linux-x64" and .label == "Linux-x64") or
($sel == "linux-arm64" and .label == "Linux-ARM64")
)]}')
fi
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
build:
needs: prepare
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
runs-on: ${{ matrix.platform }}
name: Build (${{ matrix.label }})
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read version
id: version
shell: bash
run: |
VERSION=$(node -p "require('./desktop/package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Install Linux dependencies
if: contains(matrix.platform, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y build-essential curl wget file libfuse2
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- 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: Verify Windows legacy data recovery
if: matrix.smoke_platform == 'windows'
working-directory: desktop
run: bun run test:windows-storage-recovery
- name: Build sidecars
working-directory: desktop
env:
BUN_INSTALL_CACHE_DIR: ${{ runner.temp }}/bun-install-cache
SIDECAR_TARGET_TRIPLE: ${{ matrix.target_triple }}
run: bun run build:sidecars
- name: Build renderer and Electron bundles
working-directory: desktop
run: |
bun run build
bun run build:electron
- name: Build Electron app
working-directory: desktop
env:
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
run: node ./node_modules/electron-builder/out/cli/cli.js ${{ matrix.builder_args }} --publish never
- name: Verify Windows installer execution
if: matrix.smoke_platform == 'windows' && matrix.arch == 'x64'
timeout-minutes: 10
working-directory: desktop
run: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File ./scripts/windows-installer-smoke.ps1 -ArtifactsDir ./build-artifacts/electron -Arch x64
- name: Verify packaged app structure
run: bun run test:package-smoke --platform ${{ matrix.smoke_platform }} --arch ${{ matrix.arch }} --package-kind release --artifacts-dir desktop/build-artifacts/electron
- name: Collect artifacts
id: collect
shell: bash
run: |
STAGING="desktop/build-artifacts/ci-Claude-Code-Haha-v${{ steps.version.outputs.version }}-${{ matrix.artifact_name }}"
mkdir -p "$STAGING"
find desktop/build-artifacts/electron -maxdepth 1 -type f \
\( -name "*.dmg" -o -name "*.exe" -o -name "*.deb" -o -name "*.AppImage" -o -name "*.yml" \) \
| while read -r artifact; do
cp -f "$artifact" "$STAGING/"
done
if [ "${{ matrix.smoke_platform }}" = "macos" ]; then
cp -f desktop/scripts/install-macos-unsigned.sh "$STAGING/"
fi
echo "staging_dir=$STAGING" >> "$GITHUB_OUTPUT"
ls -lh "$STAGING/" 2>/dev/null || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Claude-Code-Haha-v${{ steps.version.outputs.version }}-${{ matrix.artifact_name }}
path: ${{ steps.collect.outputs.staging_dir }}
retention-days: 7
if-no-files-found: warn