Merge pull request #566 from mubashardev/pr/release-v1 #326
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
| name: Android CI | |
| on: | |
| push: | |
| branches: [ "master", "feature/*" ] | |
| jobs: | |
| build: | |
| permissions: write-all | |
| runs-on: ubuntu-latest | |
| env: | |
| BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| CHANNEL_ID: ${{ secrets.CHANNEL_ID }} | |
| if: github.event_name == 'push' && !contains(github.event.head_commit.message, 'Merge') | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: set up JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Write key | |
| if: github.event_name != 'pull_request' | |
| env: | |
| KEY_STORE: ${{ secrets.KEY_STORE }} | |
| run: | | |
| if [ ! -z "$KEY_STORE" ]; then | |
| echo androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties | |
| echo androidKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties | |
| echo androidKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties | |
| echo androidStoreFile='key.jks' >> gradle.properties | |
| echo "$KEY_STORE" | base64 --decode > key.jks | |
| fi | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build all flavor variants | |
| run: | | |
| ./gradlew assembleWhatsappDebug assembleBusinessDebug -Pminify=true | |
| - name: Get short SHA | |
| run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV | |
| - name: Upload WhatsApp flavor artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: whatsapp-debug-app-${{ env.SHORT_SHA }} | |
| path: app/build/outputs/apk/whatsapp/debug/app-whatsapp-debug.apk | |
| - name: Upload Business flavor artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: business-debug-app-${{ env.SHORT_SHA }} | |
| path: app/build/outputs/apk/business/debug/app-business-debug.apk | |
| - name: Upload to GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| name: WaEnhancer ${{ env.SHORT_SHA }} | |
| body_path: changelog.txt | |
| files: | | |
| app/build/outputs/apk/whatsapp/debug/app-whatsapp-debug.apk | |
| app/build/outputs/apk/business/debug/app-business-debug.apk | |
| tag_name: debug-${{ env.SHORT_SHA }} | |
| - name: Read changelog | |
| if: ${{ success() && github.ref == 'refs/heads/master' && github.ref_type != 'tag' && env.BOT_TOKEN != '' }} | |
| id: changelog | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const changelog = fs.readFileSync('changelog.txt', 'utf8').trim(); | |
| core.setOutput('content', changelog); | |
| - name: Post to Telegram channel | |
| if: ${{ success() && github.ref == 'refs/heads/master' && github.ref_type != 'tag' && env.BOT_TOKEN != '' }} | |
| uses: Dev4Mod/telegram-github-action@master | |
| with: | |
| to: ${{ env.CHANNEL_ID }} | |
| token: ${{ env.BOT_TOKEN }} | |
| format: markdown | |
| disable_web_page_preview: true | |
| message: | | |
| ${{ steps.changelog.outputs.content }} | |
| Release: https://github.com/${{ github.repository }}/releases/tag/debug-${{ env.SHORT_SHA }} |