mobile-wallet/fastlane/FastFile
Sk Niyaj Ali f0d3d72e05
chore(actions): Migrated Android & iOS Workflows to use Fastlane (#1841)
* chore: Update web dependencies

Updated the following dependencies:
- Upgraded `enhanced-resolve` from 5.17.0 to 5.18.0
- Upgraded `karma` from 6.4.3 to 6.4.4
- Upgraded `kotlin-web-helpers` to 2.0.0
- Upgraded `mocha` from 10.7.0 to 10.7.3
- Upgraded `webpack` from 5.93.0 to 5.94.0
- Upgraded `ws` from 8.5.0 to 8.18.0

Removed the following dependencies:
- `@types/eslint`
- `@types/eslint-scope`

Also, updated the multi-platform build and publish workflow to use `niyajali/mifos-mobile-github-actions` instead of `openMF/mifos-mobile-github-actions`.

* ci: Update GitHub Actions workflow

This commit updates the GitHub Actions workflows to:

- Remove the pull request trigger from the `build-and-deploy-site` workflow. The workflow will now only be triggered manually or on a schedule.
- Add `build_ios` as an input to the `multi-platform-build-and-publish` workflow to control whether the iOS app should be built.
- Remove unused inputs from the `multi-platform-build-and-publish` workflow, including `publish_desktop` and `publish_web`.

* chore: Add Fastlane lanes and update workflows

This commit introduces new Fastlane lanes for Android and iOS:

- **Android:**
  - `assembleDebugApks`: Assembles debug APKs.
  - `assembleReleaseApks`: Assembles release APKs using a keystore.
  - `bundlePlayStoreRelease`: Bundles a Play Store release, including generating a version and release notes.
  - `deploy_on_firebase`: Deploys the release APK to Firebase App Distribution.
  - `buildAndSignApp`: A private lane to build and sign the app with provided keystore credentials.
  - `generateVersion`: Generates and sets version information.
  - `generateReleaseNotes`: Generates release notes from git commits.
- **iOS:**
  - `build_ios`: Builds the iOS app with optional configuration (defaults to Debug).
  - `increment_version`: Increments the build number using Firebase App Distribution's latest release.
  - `deploy_on_firebase`: Deploys the iOS app to Firebase App Distribution, including incrementing the build number.
  - `generateReleaseNotes`: Generates release notes from git commits.

It also updates the following workflows:

- **promote-to-production.yml**: Removes the manual trigger and workflow dispatch, making it only triggered by GitHub releases.
- **tag-weekly-release.yml**: Updates the cron schedule to run weekly.
- **multi-platform-build-and-publish.yml**: Switches back to using `openMF/mifos-mobile-github-actions` instead of `niyajali/mifos-mobile-github-actions`.

Additionally, it relocates the keystore to a `keystores` directory, updates the `build.gradle.kts` file to reflect this change, and adds necessary metadata for the Play Store. It also updates the `AppFile` to use the playStorePublishServiceCredentialsFile from the secrets directory and adds a `secrets` directory to the `.gitignore`.

* ci: Remove `publish_android` input from multi-platform workflow

This commit removes the `publish_android` input from the `multi-platform-build-and-publish` workflow.
This input was previously used to control whether the Android app should be published to the Play Store.
Since this functionality is no longer required, the input has been removed to simplify the workflow configuration.

* chore: Remove `repoName` param from `generateReleaseNotes` lane

This commit removes the `repoName` parameter from the `generateReleaseNotes` lane in the Fastfile. The `repoName` parameter is no longer needed as the lane now automatically determines the repository name.

This change simplifies the `generateReleaseNotes` lane and makes it more robust.
2024-12-30 22:24:06 -05:00

229 lines
6.9 KiB
Plaintext

default_platform(:android)
platform :android do
desc "Assemble debug APKs."
lane :assembleDebugApks do |options|
gradle(
tasks: ["assembleDebug"],
)
end
desc "Assemble Release APK"
lane :assembleReleaseApks do |options|
options[:storeFile] ||= "release_keystore.keystore"
options[:storePassword] ||= "Mifospay"
options[:keyAlias] ||= "key0"
options[:keyPassword] ||= "Mifos@123"
# Generate version
generateVersion = generateVersion()
buildAndSignApp(
taskName: "assemble",
buildType: "Release",
storeFile: options[:storeFile],
storePassword: options[:storePassword],
keyAlias: options[:keyAlias],
keyPassword: options[:keyPassword],
)
end
desc "Bundle Play Store release"
lane :bundlePlayStoreRelease do |options|
options[:storeFile] ||= "release_keystore.keystore"
options[:storePassword] ||= "Mifospay"
options[:keyAlias] ||= "key0"
options[:keyPassword] ||= "Mifos@123"
# Generate version
generateVersion = generateVersion()
# Generate Release Note
releaseNotes = generateReleaseNotes()
# Write the generated release notes to default.txt
buildConfigPath = "metadata/android/en-GB/changelogs/default.txt"
File.write(buildConfigPath, releaseNotes)
buildAndSignApp(
taskName: "bundle",
buildType: "Release",
storeFile: options[:storeFile],
storePassword: options[:storePassword],
keyAlias: options[:keyAlias],
keyPassword: options[:keyPassword],
)
end
desc "Publish Release Play Store artifacts to Firebase App Distribution"
lane :deploy_on_firebase do |options|
options[:apkFile] ||= "mifospay-android/build/outputs/apk/prod/release/mifospay-android-prod-release.apk"
options[:serviceCredsFile] ||= "secrets/firebaseAppDistributionServiceCredentialsFile.json"
options[:groups] ||= "mifos-wallet-testers"
# Generate Release Note
releaseNotes = generateReleaseNotes()
firebase_app_distribution(
app: "1:64530857057:android:f8d67b786db1b844",
android_artifact_type: "APK",
android_artifact_path: options[:apkFile],
service_credentials_file: options[:serviceCredsFile],
groups: options[:groups],
release_notes: "#{releaseNotes}",
)
end
desc "Deploy internal tracks to Google Play"
lane :deploy_internal do |options|
options[:aabFile] ||= "mifospay-android/build/outputs/bundle/prodRelease/mifospay-android-prod-release.aab"
upload_to_play_store(
track: 'internal',
aab: options[:aabFile],
skip_upload_metadata: true,
skip_upload_images: true,
skip_upload_screenshots: true,
)
end
desc "Promote internal tracks to beta on Google Play"
lane :promote_to_beta do
upload_to_play_store(
track: 'internal',
track_promote_to: 'beta',
skip_upload_changelogs: true,
skip_upload_metadata: true,
skip_upload_images: true,
skip_upload_screenshots: true,
)
end
desc "Promote beta tracks to production on Google Play"
lane :promote_to_production do
upload_to_play_store(
track: 'beta',
track_promote_to: 'production',
skip_upload_changelogs: true,
skip_upload_metadata: true,
skip_upload_images: true,
skip_upload_screenshots: true,
)
end
desc "Generate artifacts for the given [build] signed with the provided [keystore] and credentials."
private_lane :buildAndSignApp do |options|
# Get the project root directory
project_dir = File.expand_path('..', Dir.pwd)
# Construct the absolute path to the keystore
keystore_path = File.join(project_dir, 'keystores', options[:storeFile])
# Check if keystore exists
unless File.exist?(keystore_path)
UI.error "Keystore file not found at: #{keystore_path}"
UI.error "Please ensure the keystore file exists at the correct location"
exit 1 # Exit with error code 1
end
gradle(
task: options[:taskName],
build_type: options[:buildType],
properties: {
"android.injected.signing.store.file" => keystore_path,
"android.injected.signing.store.password" => options[:storePassword],
"android.injected.signing.key.alias" => options[:keyAlias],
"android.injected.signing.key.password" => options[:keyPassword],
},
print_command: false,
)
end
desc "Generate Version"
lane :generateVersion do
# Generate version file
gradle(tasks: ["versionFile"])
# Set version from file
ENV['VERSION'] = File.read("../version.txt").strip
# Calculate and set version code
commit_count = `git rev-list --count HEAD`.to_i
tag_count = `git tag | grep -v beta | wc -l`.to_i
ENV['VERSION_CODE'] = ((commit_count + tag_count) << 1).to_s
UI.success("Set VERSION=#{ENV['VERSION']} VERSION_CODE=#{ENV['VERSION_CODE']}")
end
desc "Generate release notes"
lane :generateReleaseNotes do |options|
branchName = `git rev-parse --abbrev-ref HEAD`.chomp()
releaseNotes = changelog_from_git_commits(
commits_count: 1,
)
releaseNotes
end
end
platform :ios do
desc "Build iOS application"
lane :build_ios do |options|
# Set default configuration if not provided
options[:configuration] ||= "Debug"
# automatic code signing
update_code_signing_settings(
use_automatic_signing: true,
path: "mifospay-ios/iosApp.xcodeproj"
)
build_ios_app(
project: "mifospay-ios/iosApp.xcodeproj",
scheme: "iosApp",
# Set configuration to debug for now
configuration: options[:configuration],
skip_codesigning: "true",
output_directory: "mifospay-ios/build",
skip_archive: "true"
)
end
lane :increment_version do |options|
options[:serviceCredsFile] ||= "secrets/firebaseAppDistributionServiceCredentialsFile.json"
latest_release = firebase_app_distribution_get_latest_release(
app: "1:728434912738:ios:86a7badfaed88b841a1dbb",
service_credentials_file: options[:serviceCredsFile]
)
increment_build_number(
xcodeproj: "mifospay-ios/iosApp.xcodeproj",
build_number: latest_release[:buildVersion].to_i + 1
)
end
desc "Upload iOS application to Firebase App Distribution"
lane :deploy_on_firebase do |options|
options[:serviceCredsFile] ||= "secrets/firebaseAppDistributionServiceCredentialsFile.json"
options[:groups] ||= "mifos-wallet-testers"
increment_version()
build_ios()
releaseNotes = generateReleaseNotes()
release = firebase_app_distribution(
app: "1:728434912738:ios:86a7badfaed88b841a1dbb",
service_credentials_file: options[:serviceCredsFile],
release_notes_file: "#{releaseNotes}",
groups: options[:groups]
)
end
desc "Generate release notes"
lane :generateReleaseNotes do
branchName = `git rev-parse --abbrev-ref HEAD`.chomp()
releaseNotes = changelog_from_git_commits(
commits_count: 1,
)
releaseNotes
end
end