Skip to content

Commit 67d85f2

Browse files
committed
chore: Updated Build Desktop/Android App Actions
Refactored the Desktop App build action to: - Build for all platforms (Windows, Linux, MacOS). - Output paths to the built executables and installers. - Support debug and release builds. Refactored the Android App build action to: - Support debug and release builds. - Output paths to the built APKs. - Accept keystore and google-services.json as inputs for release builds. - Generate version numbers.
1 parent 68f3af8 commit 67d85f2

File tree

4 files changed

+179
-58
lines changed

4 files changed

+179
-58
lines changed

Diff for: .github/actions/build-android-app/action.yaml

+102-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: 'Build Android App'
2-
description: 'Build the Android application in Debug mode'
1+
name: 'KMP Build Android App'
2+
description: 'Build the Android application using Gradle'
33
author: 'Mifos Initiative'
44
branding:
55
icon: 'play'
@@ -9,6 +9,37 @@ inputs:
99
android_package_name:
1010
description: 'Name of the Android project module'
1111
required: true
12+
build_type:
13+
description: 'Type of build to perform'
14+
required: true
15+
default: 'Debug'
16+
key_store:
17+
description: 'Base64 encoded keystore file'
18+
required: false
19+
google_services:
20+
description: 'Base64 encoded google-services.json file'
21+
required: false
22+
key_store_password:
23+
description: 'Password for the keystore file'
24+
required: false
25+
key_store_alias:
26+
description: 'Alias for the keystore file'
27+
required: false
28+
key_store_alias_password:
29+
description: 'Password for the keystore alias'
30+
required: false
31+
32+
33+
outputs:
34+
demo_apk:
35+
description: 'Path to Demo APK'
36+
value: ${{ steps.collect-apks.outputs.demo_apk }}
37+
prod_apk:
38+
description: 'Path to Prod APK'
39+
value: ${{ steps.collect-apks.outputs.prod_apk }}
40+
artifact-name:
41+
description: 'Name of the artifact'
42+
value: ${{ steps.collect-apks.outputs.artifact-name }}
1243

1344
runs:
1445
using: composite
@@ -33,12 +64,78 @@ runs:
3364
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
3465
restore-keys: ${{ runner.os }}-gradle-
3566

36-
- name: Build Android App
67+
# Generate version number
68+
- name: Generate Release Number
69+
id: rel_number
70+
shell: bash
71+
run: |
72+
./gradlew versionFile
73+
COMMITS=`git rev-list --count HEAD`
74+
TAGS=`git tag | grep -v beta | wc -l`
75+
VC=$(((COMMITS+TAGS) << 1))
76+
echo "version-code=$VC" >> $GITHUB_OUTPUT
77+
VERSION=`cat version.txt`
78+
echo "version=$VERSION" >> $GITHUB_OUTPUT
79+
80+
- name: Inflate Secrets
81+
if: ${{ inputs.build_type == 'Release' }}
82+
shell: bash
83+
env:
84+
KEYSTORE: ${{ inputs.key_store }}
85+
GOOGLE_SERVICES: ${{ inputs.google_services }}
86+
run: |
87+
# Mock debug google-services.json
88+
cp .github/mock-google-services.json ${{ inputs.android_package_name }}/google-services.json
89+
90+
# Inflate keystore
91+
echo $KEYSTORE | base64 --decode > ${{ inputs.android_package_name }}/release_keystore.keystore
92+
93+
# Inflate google-services.json
94+
echo $GOOGLE_SERVICES | base64 --decode > ${{ inputs.android_package_name }}/google-services.json
95+
96+
97+
- name: Build Debug Android App
98+
if: ${{ inputs.build_type == 'Debug' }}
3799
shell: bash
100+
env:
101+
VERSION_CODE: ${{ steps.rel_number.outputs.version-code }}
102+
VERSION: ${{ steps.rel_number.outputs.version }}
38103
run: ./gradlew :${{ inputs.android_package_name }}:assembleDebug
39104

105+
- name: Build Release Android App
106+
if: ${{ inputs.build_type == 'Release' }}
107+
shell: bash
108+
env:
109+
KEYSTORE_PASSWORD: ${{ inputs.key_store_password }}
110+
KEYSTORE_ALIAS: ${{ inputs.key_store_alias }}
111+
KEYSTORE_ALIAS_PASSWORD: ${{ inputs.key_store_alias_password }}
112+
VERSION_CODE: ${{ steps.rel_number.outputs.version-code }}
113+
VERSION: ${{ steps.rel_number.outputs.version }}
114+
run: ./gradlew :${{ inputs.android_package_name }}:assembleRelease
115+
116+
- name: Collect APK Paths
117+
id: collect-apks
118+
shell: bash
119+
run: |
120+
# Find Demo APK
121+
demo_apk=$(find . -path "**/build/outputs/apk/**/demo/**/*.apk" -print -quit)
122+
123+
# Find Prod APK
124+
prod_apk=$(find . -path "**/build/outputs/apk/**/prod/**/*.apk" -print -quit)
125+
126+
# Output APK paths
127+
echo "demo_apk=${demo_apk}" >> $GITHUB_OUTPUT
128+
echo "prod_apk=${prod_apk}" >> $GITHUB_OUTPUT
129+
echo "artifact-name=android-app" >> $GITHUB_OUTPUT
130+
131+
# Print for logging
132+
echo "Demo APK: ${demo_apk}"
133+
echo "Prod APK: ${prod_apk}"
134+
40135
- name: Upload APK as artifact
41136
uses: actions/upload-artifact@v4
42137
with:
43-
name: APK
44-
path: '**/build/outputs/apk/**/*.apk'
138+
name: ${{ steps.collect-apks.outputs.artifact-name }}
139+
path: |
140+
${{ steps.collect-apks.outputs.demo_apk }}
141+
${{ steps.collect-apks.outputs.prod_apk }}

Diff for: .github/actions/publish-desktop-app/action.yaml

+73-50
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
1-
name: KMP Publish Desktop App
2-
description: 'Publish the desktop app to the respective app stores'
1+
name: KMP Build Desktop App
2+
description: 'Build the desktop application for all platforms'
3+
author: 'Mifos Initiative'
34
branding:
45
icon: 'play'
56
color: 'orange'
67

78
inputs:
89
desktop_package_name:
9-
description: 'Name of the Android project module'
10+
description: 'Name of the desktop project module'
1011
required: true
11-
windows_signing_key:
12-
description: 'Windows signing key'
13-
required: false
14-
windows_signing_password:
15-
description: 'Windows signing password'
16-
required: false
17-
windows_signing_certificate:
18-
description: 'Windows signing certificate'
19-
required: false
20-
macos_signing_key:
21-
description: 'MacOS signing key'
22-
required: false
23-
macos_signing_password:
24-
description: 'MacOS signing password'
25-
required: false
26-
macos_signing_certificate:
27-
description: 'MacOS signing certificate'
28-
required: false
29-
linux_signing_key:
30-
description: 'Linux signing key'
31-
required: false
32-
linux_signing_password:
33-
description: 'Linux signing password'
34-
required: false
35-
linux_signing_certificate:
36-
description: 'Linux signing certificate'
12+
13+
build_type:
14+
description: 'Type of build to perform (Debug or Release)'
3715
required: false
16+
default: 'Debug'
17+
18+
outputs:
19+
windows_exec:
20+
description: 'Path to Windows executable'
21+
value: ${{ steps.collect-windows.outputs.windows_exec }}
22+
23+
windows_inst:
24+
description: 'Path to Windows installer'
25+
value: ${{ steps.collect-windows.outputs.windows_inst }}
26+
27+
linux_app:
28+
description: 'Path to Linux package'
29+
value: ${{ steps.collect-linux.outputs.linux_app }}
30+
31+
macos_app:
32+
description: 'Path to MacOS package'
33+
value: ${{ steps.collect-macos.outputs.macos_app }}
34+
3835
runs:
3936
using: 'composite'
4037
steps:
4138
- name: Set up Java development environment
4239
uses: actions/setup-java@v4
4340
with:
44-
distribution: 'zulu' # Use Zulu distribution of OpenJDK
45-
java-version: '17' # Use Java 17 version
41+
distribution: 'zulu'
42+
java-version: '17'
4643

4744
- name: Setup Gradle
4845
uses: gradle/actions/setup-gradle@v4
@@ -55,12 +52,53 @@ runs:
5552
~/.gradle/caches
5653
~/.gradle/wrapper
5754
build
58-
key: ${{ matrix.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
59-
restore-keys: ${{ matrix.os }}-gradle-
55+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
56+
restore-keys: ${{ runner.os }}-gradle-
6057

6158
- name: Package Desktop App
6259
shell: bash
63-
run: ./gradlew packageReleaseDistributionForCurrentOS
60+
run: |
61+
# Determine the package command based on build type
62+
if [[ "${{ inputs.build_type }}" == "Release" ]]; then
63+
./gradlew packageReleaseDistributionForCurrentOS
64+
else
65+
./gradlew packageDistributionForCurrentOS
66+
fi
67+
68+
- name: Collect Windows Paths
69+
if: matrix.os == 'windows-latest'
70+
id: collect-windows
71+
shell: bash
72+
run: |
73+
# Find Windows executables and installers
74+
windows_exec=$(find . -path "**/*.exe" | grep -E "windows|win" | head -n 1)
75+
windows_inst=$(find . -path "**/*.msi" | grep -E "windows|win" | head -n 1)
76+
77+
# Output Windows paths
78+
echo "windows_exec=${windows_exec}" >> $GITHUB_ENV
79+
echo "windows_inst=${windows_inst}" >> $GITHUB_ENV
80+
81+
- name: Collect Linux Paths
82+
if: matrix.os == 'ubuntu-latest'
83+
id: collect-linux
84+
shell: bash
85+
run: |
86+
# Find Linux package
87+
linux_app=$(find . -path "**/*.deb" | head -n 1)
88+
89+
# Output Linux paths
90+
echo "linux_app=${linux_app}" >> $GITHUB_ENV
91+
92+
- name: Collect MacOS Paths
93+
if: matrix.os == 'macos-latest'
94+
id: collect-macos
95+
shell: bash
96+
run: |
97+
# Find MacOS package
98+
macos_app=$(find . -path "**/*.dmg" | head -n 1)
99+
100+
# Output MacOS paths
101+
echo "macos_app=${macos_app}" >> $GITHUB_ENV
64102
65103
# Upload Windows executables and installers
66104
- name: Upload Windows Apps
@@ -86,19 +124,4 @@ runs:
86124
uses: actions/upload-artifact@v4
87125
with:
88126
name: MacOS-App
89-
path: '**/*.dmg'
90-
91-
- name: Publish Windows App
92-
if: matrix.os == 'windows-latest'
93-
shell: bash
94-
run: echo "Publishing Windows Desktop App"
95-
96-
- name: Publish Linux App
97-
if: matrix.os == 'ubuntu-latest'
98-
shell: bash
99-
run: echo "Publishing Linux Desktop App"
100-
101-
- name: Publish MacOS App
102-
if: matrix.os == 'macos-latest'
103-
shell: bash
104-
run: echo "Publishing MacOS Desktop App"
127+
path: '**/*.dmg'

Diff for: .github/workflows/build-android-app.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
fetch-depth: 0
2525

2626
- name: Build Android App
27-
uses: openMF/kmp-build-android-app[email protected]
27+
uses: ./.github/actions/build-android-app
2828
id: build-android
2929
with:
3030
android_package_name: ${{ inputs.android_package_name }}

Diff for: .github/workflows/build-desktop-app.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ jobs:
1616
fetch-depth: 0
1717

1818
- name: Build Desktop App
19-
uses: openMF/kmp-build-desktop-app[email protected]
19+
uses: ./.github/actions/build-desktop-app
2020
id: build-desktop
2121
with:
2222
desktop_package_name: 'mifospay-desktop'
2323

2424
- name: Display Desktop App Paths
2525
run: |
26-
echo "Windows App: ${{ steps.build-desktop.outputs.windows_app }}"
26+
echo "Windows Exec: ${{ steps.build-desktop.outputs.windows_exec }}"
27+
echo "Windows Installer: ${{ steps.build-desktop.outputs.windows_inst }}"
2728
echo "Linux App: ${{ steps.build-desktop.outputs.linux_app }}"
2829
echo "MacOS App: ${{ steps.build-desktop.outputs.macos_app }}"

0 commit comments

Comments
 (0)