|
| 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 | + |
| 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