forked from github/dev
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (80 loc) · 2.87 KB
/
android.yml
File metadata and controls
82 lines (80 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Android CI
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Set up Android SDK
uses: android-actions/setup-android@v2
with:
api-level: 33
components: build-tools;33.0.2,platforms;android-33,platform-tools
ndk: false
- name: Run Gradle (build android-app)
uses: gradle/gradle-build-action@v2
with:
arguments: -p android-app assembleDebug
gradle-version: '8.4'
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper/
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*','**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew || true
- name: Build debug APK
run: |
if [ -f gradlew ]; then
./gradlew assembleDebug --no-daemon
else
echo "No Gradle wrapper found — skipping build step"
fi
- name: Upload artifact (APK)
if: success() && always()
uses: actions/upload-artifact@v4
with:
name: app-apk
path: '**/app/build/outputs/**/*.apk'
- name: Create GitHub release and attach APK(s)
uses: ncipollo/release-action@v1
with:
tag: apk-${{ github.run_number }}
files: 'android-app/**/app/build/outputs/**/*.apk'
- name: Send APK to Telegram (optional)
if: ${{ secrets.TELEGRAM_BOT_TOKEN && secrets.TELEGRAM_CHAT_ID }}
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
run: |
apk="$(ls android-app/**/app/build/outputs/**/*.apk 2>/dev/null | head -n1)"
if [ -z "$apk" ]; then
echo "No APK found to send to Telegram"
exit 0
fi
echo "Sending $apk to Telegram..."
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendDocument" -F chat_id=${TELEGRAM_CHAT_ID} -F document=@${apk}
- name: Send APK to Discord (optional)
if: ${{ secrets.DISCORD_WEBHOOK }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
apk="$(ls android-app/**/app/build/outputs/**/*.apk 2>/dev/null | head -n1)"
if [ -z "$apk" ]; then
echo "No APK found to send to Discord"
exit 0
fi
echo "Sending $apk to Discord..."
curl -s -F "file=@${apk}" -F "payload_json={\"content\":\"New APK built by CI\"}" ${DISCORD_WEBHOOK}