108 lines
3.9 KiB
YAML
108 lines
3.9 KiB
YAML
# Copyright (c) 2026 GiantAccel, LLC
|
|
# XStats modifications Copyright (C) 2026 ysicing
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later AND MIT
|
|
|
|
name: CI
|
|
|
|
# 只改说明文档或 README 配图时不构建。CHANGELOG.md 决定版本号,不在忽略范围内;
|
|
# 应用内的隐私政策等 Markdown 在 Packages/ 下,同样照常触发。
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- 'README*.md'
|
|
- 'ARCHITECTURE.md'
|
|
- 'DEVELOPMENT.md'
|
|
- 'AGENTS.md'
|
|
- 'LICENSING.md'
|
|
- 'ThirdPartyNotices.md'
|
|
- 'Assets/readme/**'
|
|
- '.github/ISSUE_TEMPLATE/**'
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'README*.md'
|
|
- 'ARCHITECTURE.md'
|
|
- 'DEVELOPMENT.md'
|
|
- 'AGENTS.md'
|
|
- 'LICENSING.md'
|
|
- 'ThirdPartyNotices.md'
|
|
- 'Assets/readme/**'
|
|
- '.github/ISSUE_TEMPLATE/**'
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: macos-15
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Version information
|
|
id: version
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
read -r version build <<< "$(./scripts/version.sh show)"
|
|
build="${build#(}"
|
|
build="${build%)}"
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
echo "build=$build" >> "$GITHUB_OUTPUT"
|
|
{
|
|
echo "### XStats build"
|
|
echo "- Version: $version"
|
|
echo "- Build: $build"
|
|
echo "- Ref: $GITHUB_REF_NAME"
|
|
echo "- Commit: $GITHUB_SHA"
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
# CommandLineTools alone cannot expand SwiftUI's @Observable / @Entry
|
|
# macros — the plugins ship only with full Xcode. Pick the newest Xcode
|
|
# on the image rather than the default one or a pinned version that a
|
|
# future image may not carry.
|
|
- name: Select Xcode
|
|
run: |
|
|
find /Applications -maxdepth 1 -type d -name 'Xcode*.app' -print
|
|
XCODE=$(find /Applications -maxdepth 1 -type d -name 'Xcode_*.app' -print | sort -V | tail -1)
|
|
echo "Using $XCODE"
|
|
sudo xcode-select -s "$XCODE/Contents/Developer"
|
|
swift --version
|
|
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: server/api/go.mod
|
|
cache-dependency-path: server/api/go.sum
|
|
|
|
- name: Install build tools
|
|
run: brew install go-task xcodegen
|
|
|
|
- name: Test
|
|
run: task test
|
|
|
|
- name: Build app
|
|
run: task build CONFIG=Release BUMP=0 INSTALL=0
|
|
|
|
- name: Verify bundle
|
|
run: |
|
|
APP=build/DerivedData-arm64/Build/Products/Release/XStats.app
|
|
test -x "$APP/Contents/MacOS/XStats"
|
|
test -x "$APP/Contents/MacOS/XStatsHelper"
|
|
test -f "$APP/Contents/Library/LaunchDaemons/work.12306.xstats.helper.plist"
|
|
test -f "$APP/Contents/Resources/AppIcon.icns"
|
|
test "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")" = "$EXPECTED_VERSION"
|
|
test "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Contents/Info.plist")" = "$EXPECTED_BUILD"
|
|
codesign --verify --verbose "$APP"
|
|
env:
|
|
EXPECTED_VERSION: ${{ steps.version.outputs.version }}
|
|
EXPECTED_BUILD: ${{ steps.version.outputs.build }}
|
|
|
|
# Smoke test: there is no menu bar or window to drive in CI, so render
|
|
# every main-window page, popover and settings section off-screen. A view
|
|
# that traps on layout fails here rather than the first time a user opens it.
|
|
- name: Render UI snapshots
|
|
run: |
|
|
build/DerivedData-arm64/Build/Products/Release/XStats.app/Contents/MacOS/XStats --snapshot "$PWD/snapshots"
|
|
test "$(find snapshots -maxdepth 1 -type f -name '*.png' | wc -l | tr -d ' ')" -ge 20
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ui-snapshots-${{ steps.version.outputs.version }}-${{ steps.version.outputs.build }}
|
|
path: snapshots/
|