-
-
Notifications
You must be signed in to change notification settings - Fork 15
98 lines (81 loc) · 3.23 KB
/
build_apk.yml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Android APK Build and Upload to Telegram & Artifacts
on:
push:
branches:
- 'master'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Get Version Info
id: version_info
run: |
VERSION_INFO=$(./gradlew printVersionInfo --quiet | grep 'VERSION_INFO:' | sed 's/VERSION_INFO: //;s/ (.*)//')
echo "VERSION_INFO=$VERSION_INFO" >> $GITHUB_ENV
- name: Get Commit SHA and URL
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
REPO_URL="https://github.com/${{ github.repository }}"
COMMIT_URL="${REPO_URL}/commit/${COMMIT_SHA}"
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV
echo "COMMIT_URL=$COMMIT_URL" >> $GITHUB_ENV
- name: Build APK (Debug)
run: ./gradlew assembleDebug
- name: Build APK (Release)
run: ./gradlew assembleRelease
- name: Find APK filenames
id: find_apks
run: |
DEBUG_APK=$(find app/build/outputs/apk/debug/ -name "*.apk")
RELEASE_APK=$(find app/build/outputs/apk/release/ -name "*.apk")
echo "DEBUG_APK=$DEBUG_APK" >> $GITHUB_ENV
echo "RELEASE_APK=$RELEASE_APK" >> $GITHUB_ENV
- name: Decode and Save Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > /tmp/keystore.jks
- name: Sign the Release APK
run: |
${ANDROID_HOME}/build-tools/$(ls "${ANDROID_HOME}/build-tools/" | sort -V | tail -n 1)/apksigner sign \
--ks /tmp/keystore.jks \
--ks-key-alias ${{ secrets.KEY_ALIAS }} \
--ks-pass pass:${{ secrets.KEYSTORE_PASSWORD }} \
--key-pass pass:${{ secrets.KEY_PASSWORD }} \
--out "${{ env.RELEASE_APK }}" \
"${{ env.RELEASE_APK }}"
- name: Verify the signed APK
run: |
${ANDROID_HOME}/build-tools/$(ls "${ANDROID_HOME}/build-tools/" | sort -V | tail -n 1)/apksigner verify \
"${{ env.RELEASE_APK }}"
- name: Upload Debug APK to Telegram
run: |
curl -F document=@"${{ env.DEBUG_APK }}" \
-F chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \
-F parse_mode=Markdown \
https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument
- name: Upload Signed Release APK to Telegram
run: |
curl -F document=@"${{ env.RELEASE_APK }}" \
-F chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \
-F parse_mode=Markdown \
https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument
- name: Upload Debug APK as Artifact
uses: actions/upload-artifact@v3
with:
name: "Debug APK - ${{ env.DATE_TODAY }}"
path: ${{ env.DEBUG_APK }}
- name: Upload Signed Release APK as Artifact
uses: actions/upload-artifact@v3
with:
name: "Signed Release APK - ${{ env.DATE_TODAY }}"
path: "${{ env.RELEASE_APK }}"