|
| 1 | +# GitHub Workflows |
| 2 | + |
| 3 | +This directory contains GitHub Actions workflows for automated CI/CD. |
| 4 | + |
| 5 | +## Workflows |
| 6 | + |
| 7 | +### 🔄 CI (`ci.yml`) |
| 8 | + |
| 9 | +**Triggers:** Push to `main`/`develop`, Pull Requests |
| 10 | + |
| 11 | +**Purpose:** Continuous Integration checks for every code change |
| 12 | + |
| 13 | +**Jobs:** |
| 14 | +- ✅ **Test** - Runs tests on Linux, macOS, and Windows |
| 15 | +- ✅ **Validate Publish** - Ensures packages meet pub.dev requirements |
| 16 | +- ✅ **Check Versions** - Verifies version consistency across packages |
| 17 | + |
| 18 | +**What it does:** |
| 19 | +- Runs `flutter analyze` for code quality |
| 20 | +- Runs `dart format` to check formatting |
| 21 | +- Runs `flutter test` with coverage reporting |
| 22 | +- Validates packages with `dart pub publish --dry-run` |
| 23 | +- Uploads coverage to Codecov |
| 24 | + |
| 25 | +### 🚀 Publish (`publish.yml`) |
| 26 | + |
| 27 | +**Triggers:** |
| 28 | +- Version tags (e.g., `v0.0.1`, `v1.2.3`) |
| 29 | +- Manual workflow dispatch |
| 30 | + |
| 31 | +**Purpose:** Automated package publishing to pub.dev |
| 32 | + |
| 33 | +**Jobs:** |
| 34 | +1. **Validate** - Pre-flight checks on all packages |
| 35 | +2. **Publish gameframework** - Publishes core package first |
| 36 | +3. **Publish engine plugins** - Publishes Unity and Unreal plugins in parallel |
| 37 | +4. **Create Release** - Creates GitHub release with changelog |
| 38 | + |
| 39 | +**Publishing Order:** |
| 40 | +``` |
| 41 | +gameframework (core) |
| 42 | + ↓ |
| 43 | + ├─→ gameframework_unity |
| 44 | + └─→ gameframework_unreal |
| 45 | +``` |
| 46 | + |
| 47 | +**Configuration Required:** |
| 48 | +- GitHub Secret: `PUB_CREDENTIALS` (pub.dev credentials JSON) |
| 49 | + |
| 50 | +## Setup Instructions |
| 51 | + |
| 52 | +### 1. Configure pub.dev Credentials |
| 53 | + |
| 54 | +```bash |
| 55 | +# Generate credentials locally |
| 56 | +dart pub token add https://pub.dev |
| 57 | + |
| 58 | +# Extract credentials |
| 59 | +cat ~/.pub-cache/credentials.json |
| 60 | + |
| 61 | +# Add to GitHub: |
| 62 | +# Settings → Secrets → Actions → New repository secret |
| 63 | +# Name: PUB_CREDENTIALS |
| 64 | +# Value: <paste credentials.json content> |
| 65 | +``` |
| 66 | + |
| 67 | +### 2. Release Process |
| 68 | + |
| 69 | +#### Automated Release (Recommended) |
| 70 | + |
| 71 | +```bash |
| 72 | +# 1. Bump version |
| 73 | +make version-bump VERSION=1.0.0 |
| 74 | + |
| 75 | +# 2. Run pre-release checks |
| 76 | +make release-prepare |
| 77 | + |
| 78 | +# 3. Update CHANGELOG.md |
| 79 | +vim CHANGELOG.md |
| 80 | + |
| 81 | +# 4. Commit changes |
| 82 | +git add . |
| 83 | +git commit -m "chore: release v1.0.0" |
| 84 | + |
| 85 | +# 5. Create and push tag |
| 86 | +make release-tag VERSION=1.0.0 |
| 87 | +git push origin main --tags |
| 88 | +``` |
| 89 | + |
| 90 | +#### Manual Release |
| 91 | + |
| 92 | +1. Go to **Actions** → **Publish to pub.dev** |
| 93 | +2. Click **Run workflow** |
| 94 | +3. Select package and options |
| 95 | +4. Click **Run workflow** |
| 96 | + |
| 97 | +### 3. Local Testing |
| 98 | + |
| 99 | +```bash |
| 100 | +# Run CI checks locally |
| 101 | +make ci |
| 102 | + |
| 103 | +# Validate packages for pub.dev |
| 104 | +make publish-dry-run |
| 105 | + |
| 106 | +# Check version consistency |
| 107 | +make version-check |
| 108 | +``` |
| 109 | + |
| 110 | +## Workflow Files |
| 111 | + |
| 112 | +| File | Purpose | |
| 113 | +|------|---------| |
| 114 | +| `ci.yml` | Continuous Integration checks | |
| 115 | +| `publish.yml` | Package publishing automation | |
| 116 | +| `RELEASE_WORKFLOW.md` | Detailed release documentation | |
| 117 | + |
| 118 | +## Security |
| 119 | + |
| 120 | +- ⚠️ Never commit `credentials.json` to the repository |
| 121 | +- ✅ Always use GitHub Secrets for sensitive data |
| 122 | +- 🔒 Rotate credentials annually |
| 123 | +- 📝 Audit workflow runs regularly |
| 124 | + |
| 125 | +## Troubleshooting |
| 126 | + |
| 127 | +### Failed CI Checks |
| 128 | + |
| 129 | +```bash |
| 130 | +# Run locally to debug |
| 131 | +make ci |
| 132 | + |
| 133 | +# Check specific package |
| 134 | +cd packages/gameframework |
| 135 | +flutter analyze |
| 136 | +flutter test |
| 137 | +``` |
| 138 | + |
| 139 | +### Failed Publication |
| 140 | + |
| 141 | +1. Check GitHub Actions logs |
| 142 | +2. Verify credentials are correct |
| 143 | +3. Ensure version is incremented |
| 144 | +4. Run `make publish-dry-run` locally |
| 145 | + |
| 146 | +### Version Mismatch |
| 147 | + |
| 148 | +```bash |
| 149 | +# Check versions |
| 150 | +make version-check |
| 151 | + |
| 152 | +# Fix versions |
| 153 | +make version-bump VERSION=1.0.0 |
| 154 | +``` |
| 155 | + |
| 156 | +## Resources |
| 157 | + |
| 158 | +- [GitHub Actions Documentation](https://docs.github.com/en/actions) |
| 159 | +- [pub.dev Publishing Guide](https://dart.dev/tools/pub/publishing) |
| 160 | +- [Semantic Versioning](https://semver.org/) |
| 161 | + |
| 162 | +## Support |
| 163 | + |
| 164 | +For issues with workflows: |
| 165 | +1. Check [GitHub Actions logs](../actions) |
| 166 | +2. Review [RELEASE_WORKFLOW.md](RELEASE_WORKFLOW.md) |
| 167 | +3. Open an issue in this repository |
0 commit comments