Skip to content

Commit bd16190

Browse files
authored
Merge pull request #1 from niyajali/create-action
feat: Added iOS app build and publish to Firebase Action
2 parents fef41ce + aafac8d commit bd16190

File tree

3 files changed

+363
-1
lines changed

3 files changed

+363
-1
lines changed

.gitignore

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
### AndroidStudio template
2+
# Covers files to be ignored for android development using Android Studio.
3+
4+
# Built application files
5+
*.apk
6+
*.ap_
7+
*.aab
8+
9+
# Files for the ART/Dalvik VM
10+
*.dex
11+
12+
# Java class files
13+
*.class
14+
15+
# Generated files
16+
bin/
17+
gen/
18+
out/
19+
20+
# Gradle files
21+
.gradle
22+
.gradle/
23+
build/
24+
25+
# Signing files
26+
.signing/
27+
28+
# Local configuration file (sdk path, etc)
29+
local.properties
30+
31+
# Proguard folder generated by Eclipse
32+
proguard/
33+
34+
# Log Files
35+
*.log
36+
37+
# Android Studio
38+
/*/build/
39+
/*/local.properties
40+
/*/out
41+
/*/*/build
42+
/*/*/production
43+
captures/
44+
.navigation/
45+
*.ipr
46+
*~
47+
*.swp
48+
49+
# Keystore files
50+
*.jks
51+
*.keystore
52+
53+
# Google Services (e.g. APIs or Firebase)
54+
# google-services.json
55+
56+
# Android Patch
57+
gen-external-apklibs
58+
59+
# External native build folder generated in Android Studio 2.2 and later
60+
.externalNativeBuild
61+
62+
# NDK
63+
obj/
64+
65+
# IntelliJ IDEA
66+
*.iml
67+
*.iws
68+
/out/
69+
70+
# User-specific configurations
71+
.idea/
72+
73+
# Legacy Eclipse project files
74+
.classpath
75+
.project
76+
.cproject
77+
.settings/
78+
79+
# Mobile Tools for Java (J2ME)
80+
.mtj.tmp/
81+
82+
# Package Files #
83+
*.war
84+
*.ear
85+
86+
# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
87+
hs_err_pid*
88+
89+
## Plugin-specific files:
90+
91+
# mpeltonen/sbt-idea plugin
92+
.idea_modules/
93+
94+
# JIRA plugin
95+
atlassian-ide-plugin.xml
96+
97+
# Mongo Explorer plugin
98+
.idea/mongoSettings.xml
99+
100+
# Crashlytics plugin (for Android Studio and IntelliJ)
101+
com_crashlytics_export_strings.xml
102+
crashlytics.properties
103+
crashlytics-build.properties
104+
fabric.properties
105+
106+
### Kotlin template
107+
# Compiled class file
108+
109+
# Log file
110+
111+
# BlueJ files
112+
*.ctxt
113+
114+
# Mobile Tools for Java (J2ME)
115+
116+
# Package Files #
117+
*.jar
118+
*.nar
119+
*.zip
120+
*.tar.gz
121+
*.rar
122+
123+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
124+
replay_pid*
125+

README.md

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,106 @@
1-
# KMP-Publish-Ios-on-Firebase
1+
# KMP Build & Publish iOS App on Firebase
2+
3+
This GitHub Action automates the process of building an iOS application, generating release notes, and distributing the build to Firebase App Distribution. It includes version management and comprehensive caching for optimized build times.
4+
5+
## Features
6+
7+
- Automated iOS app building
8+
- Version number generation
9+
- Automated release notes generation
10+
- Firebase App Distribution integration
11+
- Gradle and Konan caching
12+
- Java development environment setup
13+
- Fastlane integration
14+
15+
## Prerequisites
16+
17+
- iOS project with Xcode configuration
18+
- Firebase project setup
19+
- GitHub repository with release history
20+
- Fastlane setup in the repository
21+
- Valid iOS certificates and provisioning profiles
22+
23+
## Inputs
24+
25+
| Input | Description | Required |
26+
|--------------------|-------------------------------------------|----------|
27+
| `ios_package_name` | Name of the iOS project module | Yes |
28+
| `firebase_creds` | Firebase service account credentials JSON | Yes |
29+
| `github_token` | GitHub token for API access | Yes |
30+
| `target_branch` | Target branch for deployment | Yes |
31+
32+
## Usage
33+
34+
```yaml
35+
name: KMP iOS deploy to Firebase
36+
37+
on:
38+
workflow_dispatch:
39+
inputs:
40+
ios_package_name:
41+
description: 'Name of the iOS project module'
42+
required: true
43+
default: 'mifospay-ios'
44+
45+
46+
permissions:
47+
contents: write
48+
49+
jobs:
50+
deploy_ios_app:
51+
name: Deploy iOS App
52+
runs-on: macos-latest
53+
steps:
54+
- name: Checkout Repository
55+
uses: actions/checkout@v4
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Deploy iOS App to Firebase
60+
uses: openMF/[email protected]
61+
with:
62+
ios_package_name: ${{ inputs.ios_package_name }}
63+
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
firebase_creds: ${{ secrets.FIREBASECREDS }}
65+
target_branch: 'dev'
66+
67+
```
68+
69+
## Workflow Details
70+
71+
1. **Environment Setup**
72+
- Configures Java 17 (Zulu distribution)
73+
- Sets up Gradle with caching
74+
- Configures Ruby and Fastlane
75+
- Sets up dependency caching for Gradle, Konan, and build outputs
76+
77+
2. **Version Management**
78+
- Generates version codes based on commits and tags
79+
- Reads version name from version.txt
80+
- Formula: `version-code = (commits + tags) << 1`
81+
82+
3. **Release Notes Generation**
83+
- Fetches latest release tag
84+
- Generates release notes using GitHub API
85+
- Creates two changelog files:
86+
- `changelogGithub`: Comprehensive release notes
87+
- `changelogBeta`: Changes since last commit
88+
89+
4. **Build Process**
90+
- Configures Firebase credentials
91+
- Builds iOS application using Fastlane
92+
- Generates IPA file
93+
94+
5. **Distribution**
95+
- Uploads build artifacts with high compression
96+
- Distributes to Firebase App Distribution
97+
98+
## Dependencies
99+
100+
- Java 17 (Zulu distribution)
101+
- Gradle
102+
- Ruby
103+
- Bundler 2.2.27
104+
- Fastlane plugins:
105+
- firebase_app_distribution
106+
- increment_build_number

action.yaml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: 'KMP Publish iOS App on Firebase'
2+
description: 'Build and publish iOS application on Firebase'
3+
author: 'Mifos Initiative'
4+
branding:
5+
icon: 'package'
6+
color: 'blue'
7+
8+
inputs:
9+
ios_package_name:
10+
description: 'Name of the Android project module'
11+
required: true
12+
firebase_creds:
13+
description: 'Firebase credentials'
14+
required: true
15+
github_token:
16+
description: 'GitHub token'
17+
required: true
18+
target_branch:
19+
description: 'Target branch for deployment'
20+
required: true
21+
22+
runs:
23+
using: composite
24+
steps:
25+
- name: Set up Java development environment
26+
uses: actions/[email protected]
27+
with:
28+
distribution: 'zulu' # Use Zulu distribution of OpenJDK
29+
java-version: '17' # Use Java 17 version
30+
31+
- name: Setup Gradle
32+
uses: gradle/actions/setup-gradle@v4
33+
34+
# Cache Gradle dependencies to speed up builds
35+
- uses: actions/cache@v3
36+
with:
37+
path: |
38+
~/.gradle/caches
39+
~/.gradle/wrapper
40+
~/.konan
41+
build
42+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
43+
44+
- name: Configure Ruby
45+
uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
46+
with:
47+
bundler-cache: true
48+
49+
- name: Install Fastlane
50+
shell: bash
51+
run: |
52+
gem install bundler:2.2.27
53+
bundle install --jobs 4 --retry 3
54+
bundle exec fastlane add_plugin firebase_app_distribution
55+
bundle exec fastlane add_plugin increment_build_number
56+
57+
# Generate version number
58+
- name: Generate Release Number
59+
id: rel_number
60+
shell: bash
61+
run: |
62+
./gradlew versionFile
63+
COMMITS=`git rev-list --count HEAD`
64+
TAGS=`git tag | grep -v beta | wc -l`
65+
VC=$(((COMMITS+TAGS) << 1))
66+
echo "version-code=$VC" >> $GITHUB_OUTPUT
67+
VERSION=`cat version.txt`
68+
echo "version=$VERSION" >> $GITHUB_OUTPUT
69+
70+
- name: Generate Release Notes
71+
uses: actions/github-script@v7
72+
id: release-notes
73+
with:
74+
github-token: ${{ inputs.github_token }}
75+
script: |
76+
try {
77+
// Get latest release tag
78+
const latestRelease = await github.rest.repos.getLatestRelease({
79+
owner: context.repo.owner,
80+
repo: context.repo.repo,
81+
});
82+
const previousTag = latestRelease.data.tag_name;
83+
84+
// Generate release notes
85+
const params = {
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
tag_name: '${{ steps.rel_number.outputs.version }}',
89+
target_commitish: '${{ inputs.target_branch }}'
90+
};
91+
92+
const { data } = await github.rest.repos.generateReleaseNotes(params);
93+
const changelog = data.body.replaceAll('`', '\'').replaceAll('"', '\'');
94+
95+
// Write changelog files
96+
const fs = require('fs');
97+
fs.writeFileSync('${{ inputs.ios_package_name }}/changelogGithub', changelog);
98+
99+
// Generate beta changelog
100+
const { execSync } = require('child_process');
101+
execSync('git log --format="* %s" HEAD^..HEAD > ${{ inputs.ios_package_name }}/changelogBeta');
102+
103+
return changelog;
104+
} catch (error) {
105+
console.error('Error generating release notes:', error);
106+
return '';
107+
}
108+
109+
- name: Inflate Secrets
110+
shell: bash
111+
env:
112+
FIREBASE_CREDS: ${{ inputs.firebase_creds }}
113+
run: |
114+
# Inflate Firebase credentials
115+
touch ${{ inputs.ios_package_name }}/firebaseAppDistributionServiceCredentialsFile.json
116+
echo $FIREBASE_CREDS > ${{ inputs.ios_package_name }}/firebaseAppDistributionServiceCredentialsFile.json
117+
118+
- name: Build iOS App
119+
shell: bash
120+
run: bundle exec fastlane ios build_ios
121+
122+
- name: Upload iOS Artifact
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: ios-app
126+
retention-days: 1
127+
compression-level: 9
128+
path: '**/*.ipa'
129+
130+
- name: Upload iOS App to Firebase Distribution
131+
shell: bash
132+
run: bundle exec fastlane ios deploy_on_firebase

0 commit comments

Comments
 (0)