Android CI #1
This file contains 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: | |
- main | |
- dev | |
paths-ignore: | |
- '**/*.md' | |
workflow_dispatch: | |
jobs: | |
build-release: | |
name: Build Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Decode and create xed.keystore | |
run: echo "${{ secrets.KEYSTORE }}" | base64 -d > /tmp/xed.keystore | |
- name: Decode and create signing.properties | |
run: echo "${{ secrets.PROP }}" | base64 -d > /tmp/signing.properties | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Set Commit Hash | |
id: commit_hash | |
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Build with Gradle | |
run: ./gradlew assembleRelease && mv app/build/outputs/apk/release/*.apk app/karbon-${{ env.COMMIT_HASH }}.apk | |
env: | |
KEYSTORE_FILE: /tmp/xed.keystore | |
SIGNING_PROPERTIES_FILE: /tmp/signing.properties | |
continue-on-error: false | |
- name: Archive APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Karbon-Release | |
path: app/karbon-${{ env.COMMIT_HASH }}.apk | |
- name: Delete xed.keystore and signing.properties | |
run: rm /tmp/xed.keystore /tmp/signing.properties | |
- name: Send APK to Telegram | |
if: ${{ success() }} | |
run: | | |
curl -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument" \ | |
-F chat_id="-1002408175863" \ | |
-F message_thread_id="582" \ | |
-F caption="${{ github.event.head_commit.message }} by ${{ github.actor }}" \ | |
-F document=@"app/karbon-${{ env.COMMIT_HASH }}.apk" | |
build_debug_apk: | |
name: Build Debug | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Validate Gradle wrapper | |
uses: gradle/actions/wrapper-validation@v4 | |
- name: Build with Gradle | |
run: ./gradlew assembleDebug && mv app/build/outputs/apk/debug/*.apk app/karbon-debug.apk | |
- name: Archive APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Karbon-Debug | |
path: app/karbon-debug.apk |