Skip to content

Update android.yml

Update android.yml #32

Workflow file for this run

name: Android CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Notify Telegram - Build Start
- name: Notify Telegram - Build Start
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.bot_chat_id }}
token: ${{ secrets.bot_token }}
message: "Android CI build process has commenced and is expected to conclude within approximately 30 minutes ..."
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Decode google-services.json
run: echo "${{ secrets.GOOGLE_SERVICES_JSON }}" | base64 -d > ${{github.workspace}}/app/google-services.json
- name: Decode google-play-sign
run: echo "${{ secrets.GOOGLE_PLAY_SIGNFILE }}" | base64 -d > ${{github.workspace}}/app/portalgoogleplaysign.jks
- name: Build Release App Bundle
run: ./gradlew bundleRelease
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Build Release APK
run: ./gradlew assembleRelease
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
# - name: Build Debug APK
# run: ./gradlew assembleDebug
# - name: Upload Debug APK
# uses: actions/upload-artifact@v2
# with:
# name: appDebugBuild
# path: app/build/outputs/apk/debug/app-debug.apk
- name: Upload Release APK
uses: actions/upload-artifact@v2
with:
name: appReleaseBuild
path: app/build/outputs/apk/release/app-release.apk
# Get Version Code
- name: Get Version Code
run: echo "VERSION_CODE=$(./gradlew -q printVersionCode)" >> $GITHUB_ENV
# Get Version Name
- name: Get Version Name
run: echo "VERSION_NAME=$(./gradlew -q printVersionName)" >> $GITHUB_ENV
- name: Generate unique tag name
run: echo "UNIQUE_TAG=$(date +%Y%m%d%H%M%S)-${GITHUB_SHA::8}" >> $GITHUB_ENV
# Create GitHub Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.CLASSIC_PAT }}
with:
tag_name: ${{ env.UNIQUE_TAG }}
release_name: Release v${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}
draft: false
prerelease: false
body: |
### What's in this release
- Debug APK
- Release APK
- Source Code
# Send APKs to Telegram with renamed APK files
- name: Upload APKs to Telegram
run: |
# mv app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/debug/Debug_APK_Version_${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}.apk
mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/Release_APK_Version_${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}.apk
mv app/build/outputs/bundle/release/app-release.aab app/build/outputs/bundle/release/Release_Bundle_Version_${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}.aab
mv app/build/outputs/mapping/release/mapping.txt app/build/outputs/mapping/release/Mapping_Version_${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}.txt
# curl -F chat_id="${{ secrets.bot_chat_id }}" \
# -F document=@"app/build/outputs/apk/debug/Debug_APK_Version_${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}.apk" \
# -X POST "https://api.telegram.org/bot${{ secrets.bot_token }}/sendDocument"
curl -F chat_id="${{ secrets.bot_chat_id }}" \
-F document=@"app/build/outputs/apk/release/Release_APK_Version_${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}.apk" \
-X POST "https://api.telegram.org/bot${{ secrets.bot_token }}/sendDocument"
curl -F chat_id="${{ secrets.bot_chat_id }}" \
-F document=@"app/build/outputs/bundle/release/Release_Bundle_Version_${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}.aab" \
-X POST "https://api.telegram.org/bot${{ secrets.bot_token }}/sendDocument"
curl -F chat_id="${{ secrets.bot_chat_id }}" \
-F document=@"app/build/outputs/mapping/release/Mapping_Version_${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}.txt" \
-X POST "https://api.telegram.org/bot${{ secrets.bot_token }}/sendDocument"
env:
bot_chat_id: ${{ secrets.bot_chat_id }}
bot_token: ${{ secrets.bot_token }}
# Notify Telegram - Build Summary
- name: Notify Telegram - Build Summary
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.bot_chat_id }}
token: ${{ secrets.bot_token }}
message: "Android CI build completed : ${{ job.status }}"