# Copyright (C) 2026 ysicing # SPDX-License-Identifier: AGPL-3.0-or-later version: '3' vars: PROJECT: XStats.xcodeproj SCHEME: XStats CONFIG: '{{default "Release" .CONFIG}}' DERIVED: build/DerivedData-arm64 APP: '{{.DERIVED}}/Build/Products/{{.CONFIG}}/XStats.app' BUMP: '{{default "1" .BUMP}}' INSTALL: '{{default "1" .INSTALL}}' SIGN_ID: sh: | if [ -n "${SIGN_ID:-}" ]; then printf '%s\n' "$SIGN_ID" else security find-identity -v -p codesigning 2>/dev/null | awk '/Developer ID Application/ { print $2; exit }' || true fi TEAM_ID: sh: | if [ -n '{{.SIGN_ID}}' ]; then security find-identity -v -p codesigning 2>/dev/null \ | grep -F '{{.SIGN_ID}}' | head -1 | sed -nE 's/.*\(([A-Z0-9]+)\)"$/\1/p' || true fi tasks: generate: desc: 由 project.yml 生成 Xcode 工程 cmds: - xcodegen generate --quiet build: desc: 编译 App(含辅助工具)并安装 cmds: - | if [ "{{.INSTALL}}" != "0" ] && pgrep -x XStatsWidget >/dev/null; then pkill -x XStatsWidget 2>/dev/null || true for _ in $(seq 1 25); do pgrep -x XStatsWidget >/dev/null || break; sleep 0.2; done if pgrep -x XStatsWidget >/dev/null; then echo "error: XStatsWidget 尚未退出,无法安全构建安装" >&2 exit 1 fi fi - | if [ "{{.BUMP}}" != "0" ]; then ./scripts/version.sh build; fi - task: compile vars: CONFIG: '{{.CONFIG}}' SIGN_ID: '{{.SIGN_ID}}' - | if [ "{{.INSTALL}}" != "0" ]; then ./scripts/install_local.sh "{{.APP}}"; fi compile: desc: 只编译 App,不安装 deps: [generate] cmds: - | xcodebuild -project "{{.PROJECT}}" -scheme "{{.SCHEME}}" -configuration "{{.CONFIG}}" \ -derivedDataPath "{{.DERIVED}}" \ -destination 'generic/platform=macOS' ARCHS=arm64 ONLY_ACTIVE_ARCH=NO \ XSTATS_APP_PROFILE="${XSTATS_APP_PROFILE:-}" XSTATS_WIDGET_PROFILE="${XSTATS_WIDGET_PROFILE:-}" \ {{if .TEAM_ID}}CODE_SIGN_IDENTITY="{{.SIGN_ID}}" CODE_SIGN_STYLE=Manual DEVELOPMENT_TEAM={{.TEAM_ID}}{{if eq .CONFIG "Release"}} OTHER_CODE_SIGN_FLAGS=--timestamp CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO{{end}}{{else}}CODE_SIGNING_ALLOWED=NO ENABLE_HARDENED_RUNTIME=NO{{end}} \ build - bash scripts/sign_sparkle.sh "{{.APP}}" "{{.SIGN_ID}}" run: desc: 编译、安装并启动 App deps: [build] install: desc: 编译、安装并启动 App deps: [build] release: desc: 签名、公证、装订、打包 DMG 并生成 Homebrew cask cmds: - ./scripts/release.sh publish: desc: 发布已构建且已提交推送的制品 cmds: - ./scripts/publish_release.sh release-all: desc: 测试、构建、公证、提交推送并完成全部发布 cmds: - ./scripts/release_all.sh stop: desc: 停止正在运行的 App cmds: - pkill -x XStats ignore_error: true test: desc: 运行版本脚本、API 和 Swift 单元测试 cmds: - bash scripts/version_test.sh - bash scripts/arm64_release_test.sh - bash scripts/release_all_test.sh - python3 scripts/release_provenance_test.py - python3 scripts/publish_api_test.py - python3 scripts/sync_changelog_test.py - python3 scripts/sparkle_appcast_test.py - python3 scripts/github_release_notes_test.py - task: test-api - task: test-swift test-api: internal: true dir: server/api cmds: - go test ./... test-swift: internal: true dir: Packages/XStatsKit cmds: - swift test snapshot: desc: 用本机实时数据渲染页面截图 cmds: - /Applications/XStats.app/Contents/MacOS/XStats --snapshot build/snapshots open: desc: 生成工程并用 Xcode 打开 deps: [generate] cmds: - open "{{.PROJECT}}" clean: desc: 删除构建产物 cmds: - rm -rf build version: desc: 显示当前版本 cmds: - ./scripts/version.sh