Skip to content

Commit

Permalink
chore: Refactor GitHub Actions workflows
Browse files Browse the repository at this point in the history
- Updated workflows to use local actions instead of remote actions.
- Added a new input variable `build_ios` to control iOS build.
- Updated iOS Firebase deployment workflow to use `tester_groups` input.
- Refactored input variable names for keystore and alias passwords for consistency.
- Removed unused input variables and dependencies.
- Simplified iOS Firebase deployment by removing release notes generation and versioning steps.
  • Loading branch information
niyajali committed Dec 27, 2024
1 parent c1dc2ca commit 6fb743a
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 124 deletions.
10 changes: 5 additions & 5 deletions .github/actions/android-beta/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ inputs:
keystore_password:
description: 'Password for the keystore file'
required: true
key_alias:
keystore_alias:
description: 'Key alias for the keystore file'
required: true
key_password:
keystore_alias_password:
description: 'Password for the key alias'
required: true

Expand Down Expand Up @@ -74,9 +74,9 @@ runs:
- name: Bundle Android App
shell: bash
env:
KEYSTORE_PASSWORD: ${{ inputs.key_store_password }}
KEYSTORE_ALIAS: ${{ inputs.key_store_alias }}
KEYSTORE_ALIAS_PASSWORD: ${{ inputs.key_store_alias_password }}
KEYSTORE_PASSWORD: ${{ inputs.keystore_password }}
KEYSTORE_ALIAS: ${{ inputs.keystore_alias }}
KEYSTORE_ALIAS_PASSWORD: ${{ inputs.keystore_alias_password }}
run: |
bundle exec fastlane android bundlePlayStoreRelease \
storeFile:release_keystore.keystore \
Expand Down
22 changes: 11 additions & 11 deletions .github/actions/android-firebase/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ inputs:

keystore_file:
description: 'Base64 encoded keystore file'
required: true
required: false
keystore_password:
description: 'Password for the keystore file'
required: true
key_alias:
description: 'Key alias for the keystore file'
required: true
key_password:
description: 'Password for the key alias'
required: true
required: false
keystore_alias:
description: 'Alias for the keystore file'
required: false
keystore_alias_password:
description: 'Password for the keystore alias'
required: false

google_services:
description: 'Google services JSON file'
Expand Down Expand Up @@ -74,9 +74,9 @@ runs:
- name: Build Release Android App
shell: bash
env:
KEYSTORE_PASSWORD: ${{ inputs.key_store_password }}
KEYSTORE_ALIAS: ${{ inputs.key_store_alias }}
KEYSTORE_ALIAS_PASSWORD: ${{ inputs.key_store_alias_password }}
KEYSTORE_PASSWORD: ${{ inputs.keystore_password }}
KEYSTORE_ALIAS: ${{ inputs.keystore_alias }}
KEYSTORE_ALIAS_PASSWORD: ${{ inputs.keystore_alias_password }}
run: |
bundle exec fastlane android assembleReleaseApks \
storeFile:release_keystore.keystore \
Expand Down
20 changes: 10 additions & 10 deletions .github/actions/build-android-app/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ inputs:
description: 'Type of build to perform'
required: true
default: 'Debug'
key_store:
description: 'Base64 encoded keystore file'
required: false
google_services:
description: 'Base64 encoded google-services.json file'
required: false
key_store_password:
keystore_file:
description: 'Base64 encoded keystore file'
required: false
keystore_password:
description: 'Password for the keystore file'
required: false
key_store_alias:
keystore_alias:
description: 'Alias for the keystore file'
required: false
key_store_alias_password:
keystore_alias_password:
description: 'Password for the keystore alias'
required: false

Expand Down Expand Up @@ -67,7 +67,7 @@ runs:
if: ${{ inputs.build_type == 'Release' }}
shell: bash
env:
KEYSTORE: ${{ inputs.key_store }}
KEYSTORE: ${{ inputs.keystore_file }}
GOOGLE_SERVICES: ${{ inputs.google_services }}
run: |
# Inflate keystore
Expand All @@ -86,9 +86,9 @@ runs:
if: ${{ inputs.build_type == 'Release' }}
shell: bash
env:
KEYSTORE_PASSWORD: ${{ inputs.key_store_password }}
KEYSTORE_ALIAS: ${{ inputs.key_store_alias }}
KEYSTORE_ALIAS_PASSWORD: ${{ inputs.key_store_alias_password }}
KEYSTORE_PASSWORD: ${{ inputs.keystore_password }}
KEYSTORE_ALIAS: ${{ inputs.keystore_alias }}
KEYSTORE_ALIAS_PASSWORD: ${{ inputs.keystore_alias_password }}
run: |
bundle exec fastlane android assembleReleaseApks \
storeFile:release_keystore.keystore \
Expand Down
79 changes: 9 additions & 70 deletions .github/actions/ios-firebase/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,13 @@ inputs:
firebase_creds:
description: 'Firebase credentials'
required: true
github_token:
description: 'GitHub token'
required: true
target_branch:
description: 'Target branch for deployment'
tester_groups:
description: 'Firebase Tester Group'
required: true

runs:
using: composite
steps:
- name: Set up Java development environment
uses: actions/[email protected]
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 to speed up builds
- uses: actions/cache@v3
with:
Expand All @@ -54,72 +42,23 @@ runs:
bundle exec fastlane add_plugin firebase_app_distribution
bundle exec fastlane add_plugin increment_build_number
# 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: ${{ inputs.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('${{ inputs.ios_package_name }}/changelogGithub', changelog);
// Generate beta changelog
const { execSync } = require('child_process');
execSync('git log --format="* %s" HEAD^..HEAD > ${{ inputs.ios_package_name }}/changelogBeta');
return changelog;
} catch (error) {
console.error('Error generating release notes:', error);
return '';
}
- name: Inflate Secrets
shell: bash
env:
GOOGLE_SERVICES: ${{ inputs.google_services }}
FIREBASE_CREDS: ${{ inputs.firebase_creds }}
run: |
mkdir -p ${{ github.workspace }}/secrets
mkdir -p secrets
# Inflate Firebase credentials
touch ${{ github.workspace }}/secrets/firebaseAppDistributionServiceCredentialsFile.json
echo $FIREBASE_CREDS > ${{ github.workspace }}/secrets/firebaseAppDistributionServiceCredentialsFile.json
touch secrets/firebaseAppDistributionServiceCredentialsFile.json
echo $FIREBASE_CREDS | base64 --decode > secrets/firebaseAppDistributionServiceCredentialsFile.json
- name: Upload iOS App to Firebase Distribution
shell: bash
run: bundle exec fastlane ios deploy_on_firebase
run: bundle exec fastlane ios deploy_on_firebase \
serviceCredsFile:secrets/firebaseAppDistributionServiceCredentialsFile.json \
groups:${{ inputs.tester_groups }}

- name: Upload iOS Artifact
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/android-promote-beta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:

keystore_file: ${{ secrets.UPLOAD_KEYSTORE_FILE }}
keystore_password: ${{ secrets.UPLOAD_KEYSTORE_FILE_PASSWORD }}
key_alias: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }}
key_password: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }}
keystore_alias: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }}
keystore_alias_password: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }}

google_services: ${{ secrets.GOOGLESERVICES }}
playstore_creds: ${{ secrets.PLAYSTORECREDS }}
8 changes: 4 additions & 4 deletions .github/workflows/build-android-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
android_package_name: ${{ inputs.android_package_name }}
build_type: ${{ inputs.build_type }}
google_services: ${{ secrets.GOOGLESERVICES }}
key_store: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
key_store_password: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
key_store_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
key_store_alias_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
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 }}
4 changes: 2 additions & 2 deletions .github/workflows/deploy-android-app-to-firebase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:

keystore_file: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
keystore_password: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
key_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
key_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
keystore_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
keystore_alias_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}

google_services: ${{ secrets.GOOGLESERVICES }}
firebase_creds: ${{ secrets.FIREBASECREDS }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ios-firebase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
uses: ./.github/actions/ios-firebase
with:
ios_package_name: ${{ inputs.ios_package_name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
firebase_creds: ${{ secrets.FIREBASECREDS }}
target_branch: 'dev'
tester_groups: 'mifos-wallet-testers'

41 changes: 23 additions & 18 deletions .github/workflows/kmp-platform-build-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ on:
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
Expand Down Expand Up @@ -57,15 +62,15 @@ jobs:
fetch-depth: 0

- name: Build Android App
uses: openMF/kmp-build-android-app[email protected]
uses: ./.github/actions/build-android-app
with:
android_package_name: mifospay-android
build_type: 'Release'
google_services: ${{ secrets.GOOGLESERVICES }}
key_store: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
key_store_password: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
key_store_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
key_store_alias_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
keystore: ${{ 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:
Expand All @@ -79,17 +84,17 @@ jobs:
fetch-depth: 0

- name: Publish Android App on Firebase
uses: openMF/kmp-android-firebase[email protected]
uses: ./.github/actions/android-firebase
with:
android_package_name: mifospay-android

keystore_file: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
keystore_password: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
key_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
key_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
keystore_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
keystore_alias_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}

google_services: ${{ secrets.GOOGLESERVICES }}
firebase_creds: ${{ secrets.FIREBASECREDS }}
github_token: ${{ secrets.GITHUB_TOKEN }}
target_branch: ${{ inputs.target_branch }}

# Publish Android app on Play Store
publish_android_on_playstore:
Expand All @@ -104,16 +109,16 @@ jobs:
fetch-depth: 0

- name: Promote Android App to Beta or Internal
uses: openMF/kmp-publish-android-on-playstore-beta[email protected]
uses: ./.github/actions/android-promote-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 }}
key_alias: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }}
key_password: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }}
keystore_alias: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }}
keystore_alias_password: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }}

# iOS Build Job
build_ios:
Expand All @@ -124,7 +129,8 @@ jobs:
uses: actions/checkout@v4

- name: Build iOS App
uses: openMF/[email protected]
if: inputs.build_ios
uses: ./.github/actions/build-ios

# Firebase Distribution Job for iOS
publish_ios_app_to_firebase:
Expand All @@ -138,12 +144,11 @@ jobs:
uses: actions/checkout@v4

- name: Deploy iOS App to Firebase
uses: openMF/kmp-publish-ios-on-firebase[email protected]
uses: ./.github/actions/ios-firebase
with:
ios_package_name: mifospay-ios
github_token: ${{ secrets.GITHUB_TOKEN }}
ios_package_name: ${{ inputs.ios_package_name }}
firebase_creds: ${{ secrets.FIREBASECREDS }}
target_branch: ${{ inputs.target_branch }}
tester_groups: 'mifos-wallet-testers'

# App Store Publishing Job
publish_ios_app_to_app_center:
Expand Down

0 comments on commit 6fb743a

Please sign in to comment.