name: CI/CD Pipeline on: push: branches: - '**' pull_request: branches: - main - master jobs: test: name: Run Tests runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17' cache: 'gradle' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Run Unit Tests run: ./gradlew test --stacktrace - name: Run Lint run: ./gradlew lint --stacktrace continue-on-error: true - name: Upload Test Reports uses: actions/upload-artifact@v3 if: always() with: name: test-reports path: app/build/reports/tests/ retention-days: 7 - name: Upload Lint Reports uses: actions/upload-artifact@v3 if: always() with: name: lint-reports path: app/build/reports/lint-results-*.html retention-days: 7 build: name: Build APK needs: test runs-on: ubuntu-latest if: github.event_name == 'push' steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17' cache: 'gradle' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Get version info id: version run: | VERSION_NAME=$(grep "versionName" app/build.gradle.kts | cut -d '"' -f 2) VERSION_CODE=$(grep "versionCode" app/build.gradle.kts | grep -o '[0-9]\+') echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_OUTPUT echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_OUTPUT - name: Build Debug APK run: ./gradlew assembleDebug --stacktrace - name: Build Release APK run: ./gradlew assembleRelease --stacktrace continue-on-error: true - name: Rename APKs run: | if [ -f app/build/outputs/apk/debug/app-debug.apk ]; then mv app/build/outputs/apk/debug/app-debug.apk \ app/build/outputs/apk/debug/iTartanas-${{ steps.version.outputs.VERSION_NAME }}-debug.apk fi if [ -f app/build/outputs/apk/release/app-release-unsigned.apk ]; then mv app/build/outputs/apk/release/app-release-unsigned.apk \ app/build/outputs/apk/release/iTartanas-${{ steps.version.outputs.VERSION_NAME }}-release-unsigned.apk fi - name: Upload Debug APK uses: actions/upload-artifact@v3 with: name: iTartanas-${{ steps.version.outputs.VERSION_NAME }}-debug path: app/build/outputs/apk/debug/*.apk retention-days: 30 - name: Upload Release APK uses: actions/upload-artifact@v3 if: success() with: name: iTartanas-${{ steps.version.outputs.VERSION_NAME }}-release path: app/build/outputs/apk/release/*.apk retention-days: 30 - name: Build Summary if: always() run: | echo "### 📱 iTartanas Build v${{ steps.version.outputs.VERSION_NAME }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY echo "**Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY echo "**Author:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY echo "**Version:** ${{ steps.version.outputs.VERSION_NAME }} (Build ${{ steps.version.outputs.VERSION_CODE }})" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "#### 📦 APK Files" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY if [ -f app/build/outputs/apk/debug/iTartanas-*.apk ]; then SIZE=$(du -h app/build/outputs/apk/debug/iTartanas-*.apk | cut -f1) echo "| Type | Status | Size |" >> $GITHUB_STEP_SUMMARY echo "|------|--------|------|" >> $GITHUB_STEP_SUMMARY echo "| Debug | ✅ Success | $SIZE |" >> $GITHUB_STEP_SUMMARY else echo "| Debug | ❌ Failed | - |" >> $GITHUB_STEP_SUMMARY fi if [ -f app/build/outputs/apk/release/iTartanas-*.apk ]; then SIZE=$(du -h app/build/outputs/apk/release/iTartanas-*.apk | cut -f1) echo "| Release | ✅ Success | $SIZE |" >> $GITHUB_STEP_SUMMARY else echo "| Release | ⚠️ Unsigned | - |" >> $GITHUB_STEP_SUMMARY fi echo "" >> $GITHUB_STEP_SUMMARY echo "#### 📊 Gradle Build Info" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY ./gradlew --version >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY