-
-
Notifications
You must be signed in to change notification settings - Fork 387
107 lines (103 loc) · 3.59 KB
/
android.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
99
100
101
102
103
104
105
106
107
name: Android
on:
workflow_call:
secrets:
ANDROID_KEYSTORE:
required: false
ANDROID_KEYSTORE_PASSWORD:
required: false
ANDROID_KEY_PASSWORD:
required: false
permissions:
contents: write
env:
KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE }}
jobs:
android:
name: Android
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Install dependencies
run: |
bash script/android/install_packages.sh
sudo apt-get -y update
sudo apt-get -y install gettext
- name: Generate translations
run: |
make -C files/lang -j "$(nproc)"
- name: Create keystore
if: ${{ github.event_name == 'push' && env.KEYSTORE_BASE64 != '' }}
run: |
mkdir android/app/.keystore
echo "$KEYSTORE_BASE64" | base64 -di > android/app/.keystore/fheroes2.keystore
- name: Build debug AAB and APK
if: ${{ github.event_name == 'pull_request' || env.KEYSTORE_BASE64 == '' }}
run: |
cd android
./gradlew assembleDebug bundleDebug
cp app/build/outputs/apk/debug/app-debug.apk ../fheroes2.apk
cp app/build/outputs/bundle/debug/app-debug.aab ../fheroes2.aab
- name: Build release AAB and APK
if: ${{ github.event_name == 'push' && env.KEYSTORE_BASE64 != '' }}
run: |
cd android
./gradlew assembleRelease bundleRelease
cp app/build/outputs/apk/release/app-release.apk ../fheroes2.apk
cp app/build/outputs/bundle/release/app-release.aab ../fheroes2.aab
env:
FHEROES2_KEYSTORE: .keystore/fheroes2.keystore
FHEROES2_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
FHEROES2_KEY_ALIAS: release
FHEROES2_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Lint
if: ${{ github.event_name == 'pull_request' }}
run: |
cd android
./gradlew app:lint isotools:lint
- uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'pull_request' && ( success() || failure() ) }}
with:
name: android-app-lint-report
path: android/app/build/reports/
- uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'pull_request' && ( success() || failure() ) }}
with:
name: android-isotools-lint-report
path: android/isotools/build/reports/
- name: Create packages
run: |
7z a -bb1 -tzip -- fheroes2_android.zip LICENSE changelog.txt fheroes2.apk ./docs/README.txt ./docs/README_android.md
7z a -bb1 -tzip -- fheroes2_android_aab.zip LICENSE fheroes2.aab
- uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'pull_request' }}
with:
name: fheroes2_android.zip
path: fheroes2_android.zip
if-no-files-found: error
- uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'pull_request' }}
with:
name: fheroes2_android_aab.zip
path: fheroes2_android_aab.zip
if-no-files-found: error
- uses: ncipollo/release-action@v1
if: ${{ github.event_name == 'push' }}
with:
artifacts: fheroes2_android.zip, fheroes2_android_aab.zip
body: ${{ github.event.head_commit.message }}
token: ${{ secrets.GITHUB_TOKEN }}
name: Android build (latest commit)
tag: fheroes2-android
allowUpdates: true
artifactErrorsFailBuild: true
prerelease: true
replacesArtifacts: true