-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from niyajali/create-action
feat: Add GitHub Action for building KMP web app
- Loading branch information
Showing
3 changed files
with
266 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
### AndroidStudio template | ||
# Covers files to be ignored for android development using Android Studio. | ||
|
||
# Built application files | ||
*.apk | ||
*.ap_ | ||
*.aab | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
|
||
# Gradle files | ||
.gradle | ||
.gradle/ | ||
build/ | ||
|
||
# Signing files | ||
.signing/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio | ||
/*/build/ | ||
/*/local.properties | ||
/*/out | ||
/*/*/build | ||
/*/*/production | ||
captures/ | ||
.navigation/ | ||
*.ipr | ||
*~ | ||
*.swp | ||
|
||
# Keystore files | ||
*.jks | ||
*.keystore | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
# google-services.json | ||
|
||
# Android Patch | ||
gen-external-apklibs | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
|
||
# NDK | ||
obj/ | ||
|
||
# IntelliJ IDEA | ||
*.iml | ||
*.iws | ||
/out/ | ||
|
||
# User-specific configurations | ||
.idea/ | ||
|
||
# Legacy Eclipse project files | ||
.classpath | ||
.project | ||
.cproject | ||
.settings/ | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.war | ||
*.ear | ||
|
||
# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) | ||
hs_err_pid* | ||
|
||
## Plugin-specific files: | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Mongo Explorer plugin | ||
.idea/mongoSettings.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
### Kotlin template | ||
# Compiled class file | ||
|
||
# Log file | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
|
||
# Package Files # | ||
*.jar | ||
*.nar | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
replay_pid* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,90 @@ | ||
# kmp-build-web-app-action | ||
# KMP Build Web App GitHub Action | ||
|
||
## Overview | ||
|
||
This GitHub Action is designed to build a Kotlin Multiplatform (KMP) web application using Gradle. It automates the process of setting up the development environment, caching dependencies, and packaging the web application. | ||
|
||
## Inputs | ||
|
||
### `web_package_name` | ||
**Required**: Yes | ||
- Description: Name of the web project module | ||
- Used to specify the correct path for building and uploading the web app artifact | ||
|
||
## Outputs | ||
|
||
### `artifact-name` | ||
- Description: Name of the generated artifact | ||
- Value: `web-app` | ||
|
||
## Action Workflow | ||
|
||
```mermaid | ||
flowchart TD | ||
A[Start Action] --> B[Set up Java Development Environment\nJava 17 with Zulu OpenJDK] | ||
B --> C[Setup Gradle] | ||
C --> D[Cache Gradle Dependencies] | ||
D --> E[Run jsBrowserDistribution\nPackage Web Application] | ||
E --> F[Upload Web App Artifact] | ||
F --> G[End Action] | ||
``` | ||
|
||
The action performs the following steps: | ||
|
||
1. **Set up Java Development Environment** | ||
- Uses Zulu distribution of OpenJDK | ||
- Configures Java version 17 | ||
|
||
2. **Setup Gradle** | ||
- Prepares Gradle for building the project | ||
|
||
3. **Cache Management** | ||
- Caches Gradle dependencies, build outputs, and Kotlin/Native artifacts | ||
- Speeds up subsequent builds by reusing cached components | ||
- Caches include: | ||
- Gradle caches | ||
- Gradle wrapper | ||
- Kotlin/Native artifacts | ||
- Build directory | ||
|
||
4. **Package Web Application** | ||
- Runs `./gradlew jsBrowserDistribution` to create the web app distribution | ||
|
||
5. **Artifact Upload** | ||
- Uploads the web app artifact from the specified module's build directory | ||
|
||
## Usage Example | ||
|
||
```yaml | ||
name: Build Web App | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: openMF/[email protected] | ||
with: | ||
web_package_name: 'web' | ||
``` | ||
## Requirements | ||
- GitHub Actions runner with bash support | ||
- Gradle project configured for Kotlin Multiplatform | ||
- Java 17 | ||
- Zulu OpenJDK distribution | ||
## Best Practices | ||
- Ensure your Gradle build scripts are configured for JS browser distribution | ||
- Verify that the `web_package_name` matches your project's module structure | ||
- Use consistent Gradle and Java versions across local and CI environments | ||
|
||
## Troubleshooting | ||
|
||
- Check Gradle logs if the build fails | ||
- Verify that the `jsBrowserDistribution` task is correctly configured in your build script | ||
- Ensure all necessary dependencies are declared in your Gradle files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: 'KMP Build Web App' | ||
description: 'Build the Kotlin JS Web App using Gradle' | ||
author: 'Mifos Initiative' | ||
branding: | ||
icon: 'package' | ||
color: 'green' | ||
|
||
inputs: | ||
web_package_name: | ||
description: 'Name of the web project module' | ||
required: true | ||
|
||
outputs: | ||
artifact-name: | ||
description: 'Name of the artifact' | ||
value: 'web-app' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Set up Java development environment | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' # Use Zulu distribution of OpenJDK | ||
java-version: '17' # Use Java 17 version | ||
|
||
- 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 | ||
~/.konan | ||
build | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: ${{ runner.os }}-gradle- | ||
|
||
- name: Package Desktop App | ||
shell: bash | ||
run: ./gradlew jsBrowserDistribution | ||
|
||
# Save web app as artifact | ||
- name: Upload Web Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: web-app | ||
path: './${{ inputs.web_package_name }}/build/dist/js/productionExecutable' |