forked from openMF/mobile-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
356 lines (310 loc) · 11.4 KB
/
kmp-platform-build-and-publish.yaml
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
name: KMP Multi-Platform App Build and Publish
on:
workflow_dispatch:
inputs:
release_type:
type: string
default: 'internal'
description: Release Type
target_branch:
type: string
default: 'dev'
description: 'Target branch for release'
publish_android:
type: boolean
default: false
description: Publish Android App On Play Store
build_ios:
type: boolean
default: false
description: Build iOS App
# Toggle for iOS App Store publishing
publish_ios:
type: boolean
default: false
description: Publish iOS App On App Store
# Toggle for Desktop app publishing (Windows/macOS/Linux)
publish_desktop:
type: boolean
default: false
description: Publish Desktop Apps On App Store
# Toggle for Web app deployment
publish_web:
type: boolean
default: true
description: Publish Web App
permissions:
contents: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
# Build and publish web app
build_android:
name: Build Android Application
runs-on: macos-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Android App
uses: ./.github/actions/build-android-app
with:
android_package_name: mifospay-android
build_type: 'Release'
google_services: ${{ secrets.GOOGLESERVICES }}
keystore_file: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
keystore_password: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
keystore_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
keystore_alias_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
# Publish Android app on Firebase App Distribution
publish_android_on_firebase:
name: Deploy Android App On Firebase
runs-on: macos-latest
steps:
# Check out caller repository
- name: Checkout Caller Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Publish Android App on Firebase
uses: ./.github/actions/android-firebase
with:
android_package_name: mifospay-android
keystore_file: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
keystore_password: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
keystore_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
keystore_alias_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
google_services: ${{ secrets.GOOGLESERVICES }}
firebase_creds: ${{ secrets.FIREBASECREDS }}
# Publish Android app on Play Store
publish_android_on_playstore:
name: Publish Android App On Play Store
if: inputs.publish_android
runs-on: macos-latest
steps:
# Check out caller repository
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Promote Android App to Beta or Internal
uses: ./.github/actions/android-beta
with:
release_type: ${{ inputs.release_type }}
android_package_name: mifospay-android
google_services: ${{ secrets.GOOGLESERVICES }}
playstore_creds: ${{ secrets.PLAYSTORECREDS }}
keystore_file: ${{ secrets.UPLOAD_KEYSTORE_FILE }}
keystore_password: ${{ secrets.UPLOAD_KEYSTORE_FILE_PASSWORD }}
keystore_alias: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }}
keystore_alias_password: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }}
# iOS Build Job
build_ios:
name: Build iOS App
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Build iOS App
if: inputs.build_ios
uses: ./.github/actions/build-ios
# Firebase Distribution Job for iOS
publish_ios_app_to_firebase:
name: Publish iOS App On Firebase
if: inputs.publish_ios
runs-on: macos-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Deploy iOS App to Firebase
uses: ./.github/actions/ios-firebase
with:
ios_package_name: ${{ inputs.ios_package_name }}
firebase_creds: ${{ secrets.FIREBASECREDS }}
tester_groups: 'mifos-wallet-testers'
# App Store Publishing Job
publish_ios_app_to_app_center:
name: Publish iOS App On App Center
if: inputs.publish_ios
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Git Status
run: git status
# TODO: Implement App Store publishing
# Desktop Build Job
build_desktop:
name: Build Desktop App
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Build Desktop App
uses: openMF/[email protected]
with:
desktop_package_name: mifospay-desktop
build_type: 'Release'
# Desktop Publishing Job
publish_desktop:
name: Publish Desktop App
if: inputs.publish_desktop
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: openMF/[email protected]
with:
desktop_package_name: mifospay-desktop
windows_signing_key: ${{ secrets.WINDOWS_SIGNING_KEY }}
windows_signing_password: ${{ secrets.WINDOWS_SIGNING_PASSWORD }}
windows_signing_certificate: ${{ secrets.WINDOWS_SIGNING_CERTIFICATE }}
macos_signing_key: ${{ secrets.MACOS_SIGNING_KEY }}
macos_signing_password: ${{ secrets.MACOS_SIGNING_PASSWORD }}
macos_signing_certificate: ${{ secrets.MACOS_SIGNING_CERTIFICATE }}
linux_signing_key: ${{ secrets.LINUX_SIGNING_KEY }}
linux_signing_password: ${{ secrets.LINUX_SIGNING_PASSWORD }}
linux_signing_certificate: ${{ secrets.LINUX_SIGNING_CERTIFICATE }}
# Web Build Job
build_web:
name: Build Web Application
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Build Web App
uses: openMF/[email protected]
with:
web_package_name: mifospay-web
# Web Publishing Job
publish_web:
name: Publish Web App
if: inputs.publish_web
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
id-token: write
pages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Publish KMP Web App To GitHub Pages
uses: openMF/[email protected]
id: deployment
with:
web_package_name: mifospay-web
# Creates GitHub release with all built artifacts
github_release:
name: Create Github Release
needs: [ build_android, build_desktop, build_web, build_ios ]
if: inputs.release_type == 'beta'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Java development environment
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Cache Gradle dependencies and build outputs to speed up future builds
- name: Cache Gradle and build outputs
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
build
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
# Generate version number
- name: Generate Release Number
id: rel_number
shell: bash
run: |
./gradlew versionFile
COMMITS=`git rev-list --count HEAD`
TAGS=`git tag | grep -v beta | wc -l`
VC=$(((COMMITS+TAGS) << 1))
echo "version-code=$VC" >> $GITHUB_OUTPUT
VERSION=`cat version.txt`
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate Release Notes
uses: actions/github-script@v7
id: release-notes
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
// Get latest release tag
const latestRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
const previousTag = latestRelease.data.tag_name;
// Generate release notes
const params = {
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '${{ steps.rel_number.outputs.version }}',
target_commitish: '${{ inputs.target_branch }}'
};
const { data } = await github.rest.repos.generateReleaseNotes(params);
const changelog = data.body.replaceAll('`', '\'').replaceAll('"', '\'');
// Write changelog files
const fs = require('fs');
fs.writeFileSync('changelogGithub', changelog);
// Generate beta changelog
const { execSync } = require('child_process');
execSync('git log --format="* %s" HEAD^..HEAD > changelogBeta');
return changelog;
} catch (error) {
console.error('Error generating release notes:', error);
return '';
}
# Get all build artifacts
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: ./all-artifacts
# Debug: Show downloaded files
- name: Display structure of downloaded files
run: ls -R ./all-artifacts
#Creates a ZIP archive of the web app build using PowerShell.
- name: Archive Web Build
shell: pwsh
# Executes the Compress-Archive command to create the ZIP archive.
run: |
Compress-Archive -Path './all-artifacts/web-app/*' -DestinationPath './all-artifacts/mifospay-web.zip'
# Create GitHub pre-release with all artifacts
- name: Create Github Pre-Release
uses: softprops/[email protected]
with:
tag_name: ${{ steps.rel_number.outputs.version }}
body_path: ./changelogGithub
draft: false
prerelease: true
files: |
./all-artifacts/android-app/mifospay-android/build/outputs/apk/demo/release/*.apk
./all-artifacts/android-app/mifospay-android/build/outputs/apk/prod/release/*.apk
./all-artifacts/desktop-app-macos-latest/mifospay-desktop/build/compose/binaries/main-release/dmg/*.dmg
./all-artifacts/desktop-app-ubuntu-latest/mifospay-desktop/build/compose/binaries/main-release/deb/*.deb
./all-artifacts/desktop-app-windows-latest/mifospay-desktop/build/compose/binaries/main-release/exe/*.exe
./all-artifacts/desktop-app-windows-latest/mifospay-desktop/build/compose/binaries/main-release/msi/*.msi
./all-artifacts/mifospay-web.zip