Merge pull request #394 from frknkrc44/fix-21xx #281
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" ] | |
jobs: | |
build: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && !contains(github.event.head_commit.message, 'Merge') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Write key | |
if: github.event_name != 'pull_request' | |
run: | | |
if [ ! -z "${{ secrets.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 ${{ secrets.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-8`" >> $GITHUB_ENV | |
- name: Upload WhatsApp flavor artifacts | |
uses: actions/upload-artifact@v4 | |
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@v4 | |
with: | |
name: business-debug-app-${{ env.SHORT_SHA }} | |
path: app/build/outputs/apk/business/debug/app-business-debug.apk | |
- name: Post to Telegram channel | |
if: ${{ success() && github.ref == 'refs/heads/master' && github.ref_type != 'tag' }} | |
env: | |
CHANNEL_ID: ${{ secrets.CHANNEL_ID }} | |
BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
COMMIT_URL: ${{ github.event.head_commit.url }} | |
run: | | |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then | |
GITHUB_SHA_SHORT=$(git rev-parse --short HEAD) | |
export output_whatsapp=app/WaEnhancer_$GITHUB_SHA_SHORT.apk | |
export output_business=app/WaEnhancer_Business_$GITHUB_SHA_SHORT.apk | |
cp app/build/outputs/apk/whatsapp/debug/app-whatsapp-debug.apk $output_whatsapp | |
cp app/build/outputs/apk/business/debug/app-business-debug.apk $output_business | |
export LOG=$(cat changelog.txt) | |
ESCAPED=$(python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.getenv("LOG")); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.getenv("COMMIT_URL"))))') | |
# Send WhatsApp variant | |
curl "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2Fwa%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2Fw4b%22%2C%22caption%22%3A${ESCAPED}%7D%5D" -F wa="@$output_whatsapp" -F w4b="@$output_business" | |
fi | |
- 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 }} |