github-actions
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Actions Pipeline
GitHub Actions 流水线
- Use GitHub Actions as the primary CI/CD platform
- Trigger on to
pushand on all Pull Requestsmain - Pipeline MUST include these stages in order:
- 使用 GitHub Actions 作为主要的 CI/CD 平台
- 在向分支推送代码以及所有 Pull Request 时触发流水线
main - 流水线必须按顺序包含以下阶段:
Stage 1: Quality Gate
阶段1:质量门禁
yaml
- name: Analyze
run: flutter analyze --fatal-infos --fatal-warnings
- name: Format Check
run: dart format --set-exit-if-changed .
- name: Run Tests
run: flutter test --coverage- Zero warnings policy — ensures no info-level issues pass
--fatal-infos - Format check MUST use to enforce consistent formatting
--set-exit-if-changed
yaml
- name: Analyze
run: flutter analyze --fatal-infos --fatal-warnings
- name: Format Check
run: dart format --set-exit-if-changed .
- name: Run Tests
run: flutter test --coverage- 零警告策略——确保没有信息级别的问题通过
--fatal-infos - 格式检查必须使用来强制执行统一的代码格式
--set-exit-if-changed
Stage 2: Build
阶段2:构建
yaml
- name: Build APK
run: flutter build apk --flavor prod --dart-define-from-file=config/prod.json --release
- name: Build IPA
run: flutter build ipa --flavor prod --dart-define-from-file=config/prod.json --release --export-options-plist=ios/ExportOptions.plist- Always build with and
--flavor prod--dart-define-from-file=config/prod.json - Use a single — do NOT pass
main.dart-t lib/main_prod.dart
yaml
- name: Build APK
run: flutter build apk --flavor prod --dart-define-from-file=config/prod.json --release
- name: Build IPA
run: flutter build ipa --flavor prod --dart-define-from-file=config/prod.json --release --export-options-plist=ios/ExportOptions.plist- 始终使用和
--flavor prod进行构建--dart-define-from-file=config/prod.json - 使用单一的——不要传入
main.dart-t lib/main_prod.dart
Stage 3: Deploy (on main merge only)
阶段3:部署(仅在合并到main分支时执行)
- Upload to Firebase App Distribution for internal testing
- Upload to Google Play Internal Track / TestFlight for staging
- Production release requires manual approval gate
- 上传到 Firebase App Distribution 进行内部测试
- 上传到 Google Play 内部测试轨道 / TestFlight 进行预发布测试
- 生产环境发布需要手动审批环节
Versioning Strategy
版本控制策略
- Follow Semantic Versioning:
MAJOR.MINOR.PATCH+BUILD - Bump for bug fixes,
PATCHfor features,MINORfor breaking changesMAJOR - Set version in :
pubspec.yamlversion: 1.2.3+45 - The number MUST auto-increment in CI (use build number from CI environment)
+BUILD
- 遵循语义化版本控制(Semantic Versioning):
MAJOR.MINOR.PATCH+BUILD - 修复 bug 时升级版本,新增功能时升级
PATCH版本,有破坏性变更时升级MINOR版本MAJOR - 在中设置版本:
pubspec.yamlversion: 1.2.3+45 - 编号必须在CI中自动递增(使用CI环境中的构建编号)
+BUILD
Code Signing
代码签名
- Store signing keys and certificates in GitHub Secrets (never in repo)
- Android: Store keystore as base64-encoded secret, decode in CI
- iOS: Use App Store Connect API key for automated signing
- NEVER commit ,
*.jks,*.keystore, or*.p12files*.mobileprovision
- 将签名密钥和证书存储在 GitHub Secrets 中(绝不要存入代码仓库)
- Android:将 keystore 作为 base64 编码的密钥存储,在CI中解码使用
- iOS:使用 App Store Connect API 密钥进行自动签名
- 绝不要提交、
*.jks、*.keystore或*.p12文件*.mobileprovision
PR Requirements
Pull Request 要求
- All PRs MUST pass: analysis (0 warnings), formatting, and tests before merge
- Require at least 1 code review approval
- Branch protection on : no direct pushes, require status checks
main
- 所有 PR 在合并前必须通过:代码分析(零警告)、格式检查和测试
- 至少需要1次代码审核通过
- 分支保护:禁止直接推送代码,必须通过状态检查
main
Release Checklist
发布检查清单
- Version bumped in
pubspec.yaml - CHANGELOG.md updated
- All tests passing on CI
- Build succeeds for both Android and iOS
- Tested on physical device with production flavor
- Git tag created matching version ()
v1.2.3
- 中的版本已更新
pubspec.yaml - CHANGELOG.md 已更新
- CI上所有测试通过
- Android和iOS的构建均成功
- 已使用生产环境 flavor 在物理设备上测试
- 已创建与版本匹配的Git标签()
v1.2.3