-
-
Notifications
You must be signed in to change notification settings - Fork 39
182 lines (155 loc) · 6.21 KB
/
android-ci.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Android CI
on:
push:
branches:
- master
- stable
- devel
- versus-ci-android
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: Engine/android-project
jobs:
build:
runs-on: ubuntu-latest
name: Build release-apk
steps:
- uses: actions/checkout@v3
- uses: Wohlstand/[email protected]
- name: Check if a pull request
id: event-check
shell: bash
run: |
if [[ "${BRANCH_NAME}" == *"merge"* ]]; then
echo "--- This build is a pull-request ---"
echo "is_pull_request=true" >> $GITHUB_OUTPUT;
else
echo "--- This build is a normal branch build ---"
echo "is_pull_request=false" >> $GITHUB_OUTPUT;
fi
- name: Pull submodules
shell: bash
run: |
git submodule init
git submodule update
- name: Check for the upload support
id: upload-check
shell: bash
run: |
if [[ "${{ secrets.builds_login }}" != '' && \
"${{ secrets.builds_password }}" != '' && \
"${{ secrets.builds_host }}" != '' ]]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
- name: Check for the upload support
id: signing-check
shell: bash
run: |
if [[ "${{ secrets.ANDROID_KEYSTORE }}" != '' && \
"${{ secrets.RELEASE_STORE_PASSWORD }}" != '' && \
"${{ secrets.RELEASE_KEY_PASSWORD }}" != '' && \
"${{ secrets.RELEASE_KEY_ALIAS }}" != '' ]];
then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
- name: Install Dependencies
shell: bash
run: |
sudo apt-get update -qq && sudo apt-get install -qq cmake lftp build-essential gcc g++ libc6 libstdc++6 libc6-dev libc6-dev-i386 qttools5-dev-tools
# Pull submodules
git submodule init
git submodule update
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- uses: nttld/setup-ndk@v1
with:
ndk-version: r23c
# IMPORTANT NOTE: The SDK r23b is REQUIRED to support Android 4.1, 4.2, and 4.3, and to support non-Neon hardware
- name: Setup Android SDK
uses: android-actions/setup-android@v3
# Without NDK not compile and not normal error message. NDK is required
#- name: Install NDK
# run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;22.1.7171670" --sdk_root=${ANDROID_SDK_ROOT}
# Some times is have problems with permissions for ./gradle file. Then uncommit it code
# - name: Make gradlew executable
# run: chmod +x ./gradlew
- name: Output version code
run: echo VERSION_CODE=${{ github.run_number }} > ./version.properties
- name: Import the signing
run: echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 -d > release-key.jks
- name: Build with Gradle
if: ${{ steps.signing-check.outputs.available == 'true' }}
run: ./gradlew assembleReleaseci
env:
RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
PIN_ALIAS: ${{ secrets.PIN_ALIAS }}
DB_PASS_ALIAS: ${{ secrets.DB_PASS_ALIAS }}
- name: Build with Gradle (unsigned)
if: ${{ steps.signing-check.outputs.available != 'true' }}
run: ./gradlew assembleRelease
- name: Rename APK
if: ${{ steps.signing-check.outputs.available == 'true' }}
shell: bash
run: |
if [[ "${BRANCH_NAME}" == *"merge"* ]]; then
BRANCH_NAME_RES="pull-request"
echo "-- Pull-request detected!"
else
BRANCH_NAME_RES=${BRANCH_NAME}
fi
mv moondust/build/outputs/apk/releaseci/moondust-releaseci.apk moondust-engine-android-${BRANCH_NAME_RES}.apk
- name: Rename APK (unsigned)
if: ${{ steps.signing-check.outputs.available != 'true' }}
shell: bash
run: |
if [[ "${BRANCH_NAME}" == *"merge"* ]]; then
BRANCH_NAME_RES="pull-request"
echo "-- Pull-request detected!"
else
BRANCH_NAME_RES=${BRANCH_NAME}
fi
mv moondust/build/outputs/apk/release/moondust-release-unsigned.apk moondust-engine-android-${BRANCH_NAME_RES}.apk
- name: Upload APK
if: success() && ${{ steps.signing-check.outputs.available == 'true' }}
uses: actions/upload-artifact@v4
with:
name: moondust-engine-android-${BRANCH_NAME_RES}
path: Engine/android-project/moondust-engine-android-*.apk
- name: Upload APK (unsigned)
if: success() && ${{ steps.signing-check.outputs.available != 'true' }}
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: moondust-engine-android-${BRANCH_NAME_RES}-unsigned
path: Engine/android-project/moondust-engine-android-*.apk
- name: Deploy to builds.wohlsoft.ru
if: success() && github.event_name != 'pull_request' && steps.event-check.outputs.is_pull_request == 'false' && steps.upload-check.outputs.available == 'true'
shell: bash
run: |
if [[ "${BRANCH_NAME}" == *"merge"* ]]; then
BRANCH_NAME_RES="pull-request"
echo "-- Pull-request detected!"
else
BRANCH_NAME_RES=${BRANCH_NAME}
fi
UPLOAD_LIST="set ssl:verify-certificate no;"
UPLOAD_LIST="${UPLOAD_LIST} put -O "www/android/" ./moondust-engine-android-${BRANCH_NAME_RES}.apk;"
lftp -e "${UPLOAD_LIST} exit" -u ${{ secrets.builds_login }},${{ secrets.builds_password }} ${{ secrets.builds_host }}
- name: List Build Directory
if: always()
shell: bash
run: |
git status
ls -lR .