|
| 1 | +name: Automatic Build + Upload on push |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "new" ] |
| 6 | + paths-ignore: |
| 7 | + - '.gitignore' |
| 8 | + - 'app/.gitignore' |
| 9 | + - '*.md' |
| 10 | + - 'LICENSE' |
| 11 | + |
| 12 | + |
| 13 | +env: |
| 14 | + KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} |
| 15 | + KEY_ALIAS: ${{ secrets.KEY_ALIAS }} |
| 16 | + KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - uses: actions/setup-java@v4 |
| 26 | + with: |
| 27 | + distribution: 'corretto' |
| 28 | + java-version: '11' |
| 29 | + |
| 30 | + - name: Decode the Keystore |
| 31 | + env: |
| 32 | + KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} |
| 33 | + run: | |
| 34 | + echo "$KEYSTORE_BASE64" | base64 --decode > $GITHUB_WORKSPACE/KEYSTORE.JKS |
| 35 | +
|
| 36 | +
|
| 37 | + - name: Build Release APK |
| 38 | + run: | |
| 39 | + ./gradlew clean assembleRelease |
| 40 | +
|
| 41 | + - name: Build Debug APK |
| 42 | + run: | |
| 43 | + ./gradlew assembleDebug |
| 44 | +
|
| 45 | +
|
| 46 | + - name: Find Release APK file |
| 47 | + id: find-release-apk |
| 48 | + run: | |
| 49 | + release_apk=$(ls -t $GITHUB_WORKSPACE/app/build/outputs/apk/release/*.apk | head -n1) |
| 50 | + release_apk_filename=$(basename "$release_apk" .apk) |
| 51 | + echo "release_apk_path=$release_apk" >> $GITHUB_OUTPUT |
| 52 | + echo "release_apk_filename=$release_apk_filename" >> $GITHUB_OUTPUT |
| 53 | +
|
| 54 | + - name: Find Debug APK file |
| 55 | + id: find-debug-apk |
| 56 | + run: | |
| 57 | + debug_apk=$(ls -t $GITHUB_WORKSPACE/app/build/outputs/apk/debug/*.apk | head -n1) |
| 58 | + debug_apk_filename=$(basename "$debug_apk" .apk) |
| 59 | + echo "debug_apk_path=$debug_apk" >> $GITHUB_OUTPUT |
| 60 | + echo "debug_apk_filename=$debug_apk_filename" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | +
|
| 63 | + - name: Send commit info to Telegram |
| 64 | + uses: appleboy/telegram-action@master |
| 65 | + with: |
| 66 | + to: ${{ secrets.TELEGRAM_CHANNEL_ID}} |
| 67 | + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
| 68 | + message: | |
| 69 | + New commit from: ${{ github.actor }} |
| 70 | + Commit message: ${{ github.event.commits[0].message }} |
| 71 | + |
| 72 | + Changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} |
| 73 | +
|
| 74 | + - name: Upload Release APK to Telegram |
| 75 | + uses: appleboy/telegram-action@master |
| 76 | + with: |
| 77 | + to: ${{ secrets.TELEGRAM_CHANNEL_ID }} |
| 78 | + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
| 79 | + message: ' ' |
| 80 | + document: ${{ steps.find-release-apk.outputs.release_apk_path }} |
| 81 | + |
| 82 | + - name: Upload Debug APK to Telegram |
| 83 | + uses: appleboy/telegram-action@master |
| 84 | + with: |
| 85 | + to: ${{ secrets.TELEGRAM_CHANNEL_ID }} |
| 86 | + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
| 87 | + message: ' ' |
| 88 | + document: ${{ steps.find-debug-apk.outputs.debug_apk_path }} |
| 89 | + |
| 90 | + |
| 91 | + - name: Upload Release files to Artifacts |
| 92 | + uses: actions/upload-artifact@v4 |
| 93 | + with: |
| 94 | + name: ${{ steps.find-release-apk.outputs.release_apk_filename }} |
| 95 | + path: app/build/outputs/apk/release/ |
| 96 | + |
| 97 | + - name: Upload Debug files to Artifacts |
| 98 | + uses: actions/upload-artifact@v4 |
| 99 | + with: |
| 100 | + name: ${{ steps.find-debug-apk.outputs.debug_apk_filename }} |
| 101 | + path: app/build/outputs/apk/debug/ |
0 commit comments