Skip to content

Commit 40adade

Browse files
committed
Actions
1 parent 6cb0411 commit 40adade

File tree

2 files changed

+128
-7
lines changed

2 files changed

+128
-7
lines changed

.github/workflows/app-on-push.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Automatic Build + Upload on push
2+
3+
on:
4+
push:
5+
branches: [ "new" ]
6+
paths-ignore:
7+
- '.gitignore'
8+
- 'app/.gitignore'
9+
- '*.md'
10+
- 'LICENSE'
11+
12+
13+
env:
14+
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
15+
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
16+
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
17+
18+
jobs:
19+
build:
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-java@v4
26+
with:
27+
distribution: 'corretto'
28+
java-version: '11'
29+
30+
- name: Decode the Keystore
31+
env:
32+
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
33+
run: |
34+
echo "$KEYSTORE_BASE64" | base64 --decode > $GITHUB_WORKSPACE/KEYSTORE.JKS
35+
36+
37+
- name: Build Release APK
38+
run: |
39+
./gradlew clean assembleRelease
40+
41+
- name: Build Debug APK
42+
run: |
43+
./gradlew assembleDebug
44+
45+
46+
- name: Find Release APK file
47+
id: find-release-apk
48+
run: |
49+
release_apk=$(ls -t $GITHUB_WORKSPACE/app/build/outputs/apk/release/*.apk | head -n1)
50+
release_apk_filename=$(basename "$release_apk" .apk)
51+
echo "release_apk_path=$release_apk" >> $GITHUB_OUTPUT
52+
echo "release_apk_filename=$release_apk_filename" >> $GITHUB_OUTPUT
53+
54+
- name: Find Debug APK file
55+
id: find-debug-apk
56+
run: |
57+
debug_apk=$(ls -t $GITHUB_WORKSPACE/app/build/outputs/apk/debug/*.apk | head -n1)
58+
debug_apk_filename=$(basename "$debug_apk" .apk)
59+
echo "debug_apk_path=$debug_apk" >> $GITHUB_OUTPUT
60+
echo "debug_apk_filename=$debug_apk_filename" >> $GITHUB_OUTPUT
61+
62+
63+
- name: Send commit info to Telegram
64+
uses: appleboy/telegram-action@master
65+
with:
66+
to: ${{ secrets.TELEGRAM_CHANNEL_ID}}
67+
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
68+
message: |
69+
New commit from: ${{ github.actor }}
70+
Commit message: ${{ github.event.commits[0].message }}
71+
72+
Changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
73+
74+
- name: Upload Release APK to Telegram
75+
uses: appleboy/telegram-action@master
76+
with:
77+
to: ${{ secrets.TELEGRAM_CHANNEL_ID }}
78+
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
79+
message: ' '
80+
document: ${{ steps.find-release-apk.outputs.release_apk_path }}
81+
82+
- name: Upload Debug APK to Telegram
83+
uses: appleboy/telegram-action@master
84+
with:
85+
to: ${{ secrets.TELEGRAM_CHANNEL_ID }}
86+
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
87+
message: ' '
88+
document: ${{ steps.find-debug-apk.outputs.debug_apk_path }}
89+
90+
91+
- name: Upload Release files to Artifacts
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: ${{ steps.find-release-apk.outputs.release_apk_filename }}
95+
path: app/build/outputs/apk/release/
96+
97+
- name: Upload Debug files to Artifacts
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: ${{ steps.find-debug-apk.outputs.debug_apk_filename }}
101+
path: app/build/outputs/apk/debug/

app/build.gradle

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,27 @@ android {
1919
versionName "1.5.1.4"
2020
archivesBaseName = "XPL-EX-v$versionName-$versionCode"
2121
}
22-
/signingConfigs {
22+
23+
signingConfigs {
2324
release {
24-
storeFile file(keystoreProperties['storeFile'])
25-
storePassword keystoreProperties['storePassword']
26-
keyAlias keystoreProperties['keyAlias']
27-
keyPassword keystoreProperties['keyPassword']
25+
if (System.getenv('GITHUB_WORKSPACE') != null) {
26+
storeFile file("${System.getenv('GITHUB_WORKSPACE')}/KEYSTORE.JKS")
27+
storePassword System.getenv('KEYSTORE_PASSWORD')
28+
keyAlias System.getenv('KEY_ALIAS')
29+
keyPassword System.getenv('KEY_PASSWORD')
30+
}
2831
}
29-
}/
32+
33+
// Keys from release are being used anyway but whatever
34+
debug {
35+
if (System.getenv('GITHUB_WORKSPACE') != null) {
36+
storeFile file("${System.getenv('GITHUB_WORKSPACE')}/KEYSTORE.JKS")
37+
storePassword System.getenv('KEYSTORE_PASSWORD')
38+
keyAlias System.getenv('KEY_ALIAS')
39+
keyPassword System.getenv('KEY_PASSWORD')
40+
}
41+
}
42+
}
3043

3144

3245

@@ -40,17 +53,24 @@ android {
4053
minifyEnabled false
4154
useProguard = false
4255
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
43-
//signingConfig signingConfigs.release
56+
if (signingConfigs.release.storeFile) {
57+
signingConfig signingConfigs.release
58+
}
4459
}
60+
4561
debug {
4662
debuggable true
4763
shrinkResources false
4864
minifyEnabled false
4965
useProguard = false
5066
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
67+
if (signingConfigs.release.storeFile) {
68+
signingConfig signingConfigs.release
69+
}
5170
}
5271
}
5372

73+
5474
packagingOptions {
5575
exclude 'META-INF/kotlinx_coroutines_core.version'
5676
exclude 'META-INF/versions/**'

0 commit comments

Comments
 (0)