Repository navigation
320 lines (254 loc) · 9.06 KB
/
Copy pathandroid.yml
File metadata and controls
320 lines (254 loc) · 9.06 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
name: Build TaskPro APK
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
name: Build TaskPro Release APK
runs-on: ubuntu-latest
steps:
# ==========================================
# 1. Checkout
# ==========================================
- name: Checkout repository
uses: actions/checkout@v4
# ==========================================
# 2. Java 21
# ==========================================
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
# ==========================================
# 3. Node.js
# ==========================================
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
# ==========================================
# 4. Install dependencies
# ==========================================
- name: Install dependencies
run: |
npm install \
--no-audit \
--no-fund \
--prefer-offline \
--fetch-retries=5 \
--fetch-retry-factor=2 \
--fetch-retry-mintimeout=10000 \
--fetch-retry-maxtimeout=120000
# ==========================================
# 5. Prepare WWW
# ==========================================
- name: Prepare web files
run: |
rm -rf www
mkdir -p www
cp index.html www/
cp app.js www/
cp style.css www/
cp manifest.json www/
cp sw.js www/
echo "WWW files:"
ls -lah www
# ==========================================
# 6. Check icon
# ==========================================
- name: Check icon
run: |
if [ ! -f "icon.png" ]; then
echo "ERROR: icon.png not found!"
exit 1
fi
file icon.png
ls -lh icon.png
# ==========================================
# 7. Capacitor config
# ==========================================
- name: Create Capacitor config
run: |
cat > capacitor.config.json <<'EOF'
{
"appId": "com.parsa.taskpro",
"appName": "TaskPro",
"webDir": "www"
}
EOF
cat capacitor.config.json
# ==========================================
# 8. Create Android
# ==========================================
- name: Prepare Android
run: |
rm -rf android
npx cap add android
# ==========================================
# 9. Install ImageMagick
# ==========================================
- name: Install ImageMagick
run: |
sudo apt-get update
sudo apt-get install -y imagemagick
# ==========================================
# 10. Generate Android icons
# ==========================================
- name: Generate Android icons
run: |
set -e
ICON="icon.png"
rm -rf android/app/src/main/res/mipmap-ldpi
rm -rf android/app/src/main/res/mipmap-mdpi
rm -rf android/app/src/main/res/mipmap-hdpi
rm -rf android/app/src/main/res/mipmap-xhdpi
rm -rf android/app/src/main/res/mipmap-xxhdpi
rm -rf android/app/src/main/res/mipmap-xxxhdpi
rm -rf android/app/src/main/res/mipmap-anydpi-v26
mkdir -p android/app/src/main/res/mipmap-ldpi
mkdir -p android/app/src/main/res/mipmap-mdpi
mkdir -p android/app/src/main/res/mipmap-hdpi
mkdir -p android/app/src/main/res/mipmap-xhdpi
mkdir -p android/app/src/main/res/mipmap-xxhdpi
mkdir -p android/app/src/main/res/mipmap-xxxhdpi
convert "$ICON" -resize 36x36 \
android/app/src/main/res/mipmap-ldpi/ic_launcher.png
convert "$ICON" -resize 48x48 \
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
convert "$ICON" -resize 72x72 \
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
convert "$ICON" -resize 96x96 \
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
convert "$ICON" -resize 144x144 \
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
convert "$ICON" -resize 192x192 \
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
for density in ldpi mdpi hdpi xhdpi xxhdpi xxxhdpi
do
cp \
android/app/src/main/res/mipmap-$density/ic_launcher.png \
android/app/src/main/res/mipmap-$density/ic_launcher_round.png
done
echo "Icons generated successfully."
# ==========================================
# 11. Configure Gradle
# ==========================================
- name: Configure Gradle
run: |
cat >> android/gradle.properties <<'EOF'
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.daemon=false
org.gradle.parallel=false
org.gradle.caching=true
EOF
# ==========================================
# 12. Fix Kotlin duplicate classes
# ==========================================
- name: Fix Kotlin dependencies
run: |
cat >> android/build.gradle <<'EOF'
allprojects {
configurations.all {
resolutionStrategy {
force "org.jetbrains.kotlin:kotlin-stdlib:1.8.22"
force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22"
force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22"
}
}
}
EOF
# ==========================================
# 13. Sync Capacitor
# ==========================================
- name: Sync Capacitor
run: |
npx cap sync android
# ==========================================
# 14. Create Release Keystore
# ==========================================
- name: Create release keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: |
echo "$KEYSTORE_BASE64" | base64 --decode > android/taskpro-release.jks
echo "Keystore created:"
ls -lh android/taskpro-release.jks
# ==========================================
# 15. Configure Release Signing
# ==========================================
- name: Configure release signing
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
cat >> android/app/build.gradle <<EOF
android {
signingConfigs {
release {
storeFile file("../taskpro-release.jks")
storePassword "${KEYSTORE_PASSWORD}"
keyAlias "${KEY_ALIAS}"
keyPassword "${KEY_PASSWORD}"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
}
}
}
EOF
# ==========================================
# 16. Verify Gradle project
# ==========================================
- name: Verify Android project
run: |
echo "========== ANDROID =========="
ls -lah android
echo ""
echo "========== APP =========="
ls -lah android/app
echo ""
echo "========== KEYSTORE =========="
ls -lh android/taskpro-release.jks
# ==========================================
# 17. Make Gradle executable
# ==========================================
- name: Make Gradle executable
working-directory: android
run: |
chmod +x gradlew
# ==========================================
# 18. Build RELEASE APK
# ==========================================
- name: Build Release APK
working-directory: android
run: |
./gradlew assembleRelease \
--no-daemon \
--stacktrace \
--no-parallel
# ==========================================
# 19. Find APK
# ==========================================
- name: Find APK
run: |
echo "========== RELEASE APK =========="
find android/app/build/outputs/apk/release \
-type f \
-name "*.apk" \
-print
# ==========================================
# 20. Upload Release APK
# ==========================================
- name: Upload Release APK
uses: actions/upload-artifact@v4
with:
name: TaskPro-release-apk
path: android/app/build/outputs/apk/release/*.apk
if-no-files-found: error