🔄 ci(release): refactor APK release workflow with improved naming and… #31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # GitHub Actions Workflow: Continuous Integration | |
| # Validates pull requests with formatting, linting, tests, and build verification | |
| # Runs on: PR to main, push to any branch, manual trigger | |
| name: CI | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| push: | |
| branches: | |
| - '**' | |
| workflow_dispatch: | |
| inputs: | |
| debug_enabled: | |
| type: boolean | |
| description: 'Run with debug logging' | |
| required: false | |
| default: false | |
| # Cancel outdated runs for the same PR/branch | |
| concurrency: | |
| group: ci-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| FLUTTER_CHANNEL: stable | |
| jobs: | |
| # ============================================ | |
| # FORMAT CHECK | |
| # ============================================ | |
| format: | |
| name: 📝 Format Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Flutter SDK | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| cache: true | |
| - name: Get Flutter dependencies | |
| run: flutter pub get | |
| - name: Check code formatting | |
| id: format_check | |
| run: | | |
| echo "## 📝 Format Check Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Run dart format and capture output | |
| if dart format --set-exit-if-changed --output=none . 2>&1 | tee format_output.txt; then | |
| echo "✅ All files are properly formatted!" >> $GITHUB_STEP_SUMMARY | |
| echo "format_status=success" >> $GITHUB_OUTPUT | |
| else | |
| echo "❌ **Formatting issues found!**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "The following files need formatting:" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| # Find files that would be changed | |
| dart format --set-exit-if-changed . 2>&1 | grep -E "^Changed|^Would change" >> $GITHUB_STEP_SUMMARY || true | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Fix:** Run \`dart format .\` locally and commit the changes." >> $GITHUB_STEP_SUMMARY | |
| echo "format_status=failure" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| # ============================================ | |
| # STATIC ANALYSIS (LINTING) | |
| # ============================================ | |
| analyze: | |
| name: 🔍 Static Analysis | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Flutter SDK | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| cache: true | |
| - name: Get Flutter dependencies | |
| run: flutter pub get | |
| - name: Run Flutter analyze | |
| id: analyze | |
| run: | | |
| echo "## 🔍 Static Analysis Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Run flutter analyze and capture output | |
| if flutter analyze --no-fatal-infos 2>&1 | tee analyze_output.txt; then | |
| echo "✅ No analysis issues found!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| cat analyze_output.txt >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "analyze_status=success" >> $GITHUB_OUTPUT | |
| else | |
| echo "❌ **Analysis issues found!**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| cat analyze_output.txt >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Fix:** Address the issues listed above and commit the changes." >> $GITHUB_STEP_SUMMARY | |
| echo "analyze_status=failure" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| # ============================================ | |
| # UNIT TESTS | |
| # ============================================ | |
| test: | |
| name: 🧪 Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Flutter SDK | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| cache: true | |
| - name: Get Flutter dependencies | |
| run: flutter pub get | |
| - name: Create .env file for tests | |
| run: | | |
| # Create minimal .env file required by the app | |
| echo "# Test environment" > .env | |
| - name: Run Flutter tests | |
| id: test | |
| run: | | |
| echo "## 🧪 Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Run tests with coverage | |
| if flutter test --coverage 2>&1 | tee test_output.txt; then | |
| echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| tail -20 test_output.txt >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "test_status=success" >> $GITHUB_OUTPUT | |
| else | |
| echo "❌ **Some tests failed!**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| cat test_output.txt >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Fix:** Review the failing tests and fix the issues." >> $GITHUB_STEP_SUMMARY | |
| echo "test_status=failure" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| - name: Upload coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage/lcov.info | |
| retention-days: 7 | |
| if-no-files-found: ignore | |
| # ============================================ | |
| # BUILD VERIFICATION | |
| # ============================================ | |
| build: | |
| name: 🔨 Build Verification | |
| runs-on: ubuntu-latest | |
| needs: [format, analyze, test] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'gradle' | |
| - name: Set up Flutter SDK | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| cache: true | |
| - name: Get Flutter dependencies | |
| run: flutter pub get | |
| - name: Create .env file for build | |
| run: | | |
| # Create minimal .env file required by the app | |
| echo "# Build environment" > .env | |
| - name: Build debug APK | |
| id: build | |
| run: | | |
| echo "## 🔨 Build Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if flutter build apk --debug 2>&1 | tee build_output.txt; then | |
| echo "✅ Debug APK built successfully!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Get APK size | |
| APK_PATH="build/app/outputs/flutter-apk/app-debug.apk" | |
| if [ -f "$APK_PATH" ]; then | |
| APK_SIZE=$(du -h "$APK_PATH" | cut -f1) | |
| echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY | |
| echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| **APK Size** | $APK_SIZE |" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Build Type** | Debug |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "build_status=success" >> $GITHUB_OUTPUT | |
| else | |
| echo "❌ **Build failed!**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| tail -50 build_output.txt >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Fix:** Review the build errors above and fix the issues." >> $GITHUB_STEP_SUMMARY | |
| echo "build_status=failure" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| # ============================================ | |
| # CI STATUS SUMMARY | |
| # ============================================ | |
| ci-status: | |
| name: ✅ CI Status | |
| runs-on: ubuntu-latest | |
| needs: [format, analyze, test, build] | |
| if: always() | |
| steps: | |
| - name: Check CI status | |
| run: | | |
| echo "## 📊 CI Pipeline Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Check | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY | |
| # Check format job | |
| if [ "${{ needs.format.result }}" == "success" ]; then | |
| echo "| 📝 Format | ✅ Passed |" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "| 📝 Format | ❌ Failed |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| # Check analyze job | |
| if [ "${{ needs.analyze.result }}" == "success" ]; then | |
| echo "| 🔍 Analysis | ✅ Passed |" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "| 🔍 Analysis | ❌ Failed |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| # Check test job | |
| if [ "${{ needs.test.result }}" == "success" ]; then | |
| echo "| 🧪 Tests | ✅ Passed |" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "| 🧪 Tests | ❌ Failed |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| # Check build job | |
| if [ "${{ needs.build.result }}" == "success" ]; then | |
| echo "| 🔨 Build | ✅ Passed |" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "| 🔨 Build | ❌ Failed |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Overall status | |
| if [ "${{ needs.format.result }}" == "success" ] && \ | |
| [ "${{ needs.analyze.result }}" == "success" ] && \ | |
| [ "${{ needs.test.result }}" == "success" ] && \ | |
| [ "${{ needs.build.result }}" == "success" ]; then | |
| echo "### 🎉 All CI checks passed!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "This PR is ready for review and merge." >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "### ⚠️ Some CI checks failed" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Please fix the failing checks before merging." >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| fi |