|
| 1 | +name: Build APK on Push |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + - master |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - develop |
| 13 | + - master |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up JDK 17 |
| 27 | + uses: actions/setup-java@v4 |
| 28 | + with: |
| 29 | + java-version: '17' |
| 30 | + distribution: 'temurin' |
| 31 | + cache: gradle |
| 32 | + |
| 33 | + - name: Grant execute permission for gradlew |
| 34 | + run: chmod +x gradlew |
| 35 | + |
| 36 | + - name: Build Debug APK |
| 37 | + run: ./gradlew assembleDebug --stacktrace --no-daemon |
| 38 | + |
| 39 | + - name: Build Release APK (if on main branch) |
| 40 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 41 | + run: ./gradlew assembleRelease --stacktrace --no-daemon |
| 42 | + env: |
| 43 | + KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} |
| 44 | + KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} |
| 45 | + |
| 46 | + - name: Upload Debug APK |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: patchwork-debug-${{ github.sha }} |
| 50 | + path: app/build/outputs/apk/debug/app-debug.apk |
| 51 | + retention-days: 30 |
| 52 | + |
| 53 | + - name: Upload Release APK (if on main branch) |
| 54 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: patchwork-release-${{ github.sha }} |
| 58 | + path: app/build/outputs/apk/release/app-release.apk |
| 59 | + retention-days: 90 |
| 60 | + |
| 61 | + - name: Comment on PR with APK |
| 62 | + if: github.event_name == 'pull_request' |
| 63 | + uses: actions/github-script@v7 |
| 64 | + with: |
| 65 | + script: | |
| 66 | + github.rest.issues.createComment({ |
| 67 | + issue_number: context.issue.number, |
| 68 | + owner: context.repo.owner, |
| 69 | + repo: context.repo.repo, |
| 70 | + body: '✅ APK built successfully! Download it from the artifacts section above.' |
| 71 | + }) |
0 commit comments