|
| 1 | +name: Build Android APK |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + tags: [ 'v*' ] |
| 7 | + pull_request: |
| 8 | + branches: [ main ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up JDK 17 |
| 20 | + uses: actions/setup-java@v4 |
| 21 | + with: |
| 22 | + java-version: '17' |
| 23 | + distribution: 'temurin' |
| 24 | + |
| 25 | + - name: Setup Gradle |
| 26 | + uses: gradle/actions/setup-gradle@v3 |
| 27 | + |
| 28 | + - name: Cache Gradle packages |
| 29 | + uses: actions/cache@v4 |
| 30 | + with: |
| 31 | + path: | |
| 32 | + ~/.gradle/caches |
| 33 | + ~/.gradle/wrapper |
| 34 | + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 35 | + restore-keys: | |
| 36 | + gradle-${{ runner.os }}- |
| 37 | +
|
| 38 | + - name: Grant execute permission for gradlew |
| 39 | + run: chmod +x gradlew |
| 40 | + |
| 41 | + - name: Build Debug APK |
| 42 | + run: ./gradlew assembleDebug |
| 43 | + |
| 44 | + - name: Build Release APK |
| 45 | + if: startsWith(github.ref, 'refs/tags/') |
| 46 | + run: ./gradlew assembleRelease |
| 47 | + |
| 48 | + - name: Upload Debug APK |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: debug-apk |
| 52 | + path: app/build/outputs/apk/debug/*.apk |
| 53 | + |
| 54 | + - name: Upload Release APK |
| 55 | + if: startsWith(github.ref, 'refs/tags/') |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: release-apk |
| 59 | + path: app/build/outputs/apk/release/*.apk |
| 60 | + |
| 61 | + - name: Create Release |
| 62 | + if: startsWith(github.ref, 'refs/tags/') |
| 63 | + uses: softprops/action-gh-release@v2 |
| 64 | + with: |
| 65 | + files: app/build/outputs/apk/release/*.apk |
| 66 | + generate_release_notes: true |
| 67 | + draft: false |
| 68 | + prerelease: false |
0 commit comments