|
| 1 | +--- |
| 2 | +slug: 2025/fastlane-automatic-changelog-with-firebase |
| 3 | +title: Automatic Firebase Changelogs with fastlane |
| 4 | +authors: [connort] |
| 5 | +tags: [fastlane, firebase, changelog] |
| 6 | +--- |
| 7 | + |
| 8 | +As our pipelines evolved to support many different environments we felt we needed a bit more automation around our alpha builds. Builds past alpha were generally tagged releases with human written changelogs, but alpha builds were bleeding edge right from our main branch for internal use. We wanted to provide testers with a bit more context on what changed in each build without them needing to go hunt for information. |
| 9 | + |
| 10 | +This is our journey of a bit of automation to plug into Firebase App Distribution to provide automatic changelogs for our builds. |
| 11 | + |
| 12 | +{/* truncate */} |
| 13 | + |
| 14 | +Emails used to come in as new alpha builds were automatically uploaded looking a bit like this: |
| 15 | + |
| 16 | +<div class="text--center"> |
| 17 | +  |
| 18 | +</div> |
| 19 | + |
| 20 | +They were bland and needed some automation. So we got to work looking at our fastlane upload with Firebase. |
| 21 | + |
| 22 | +```ruby |
| 23 | +firebase_app_distribution( |
| 24 | + app: ENV["FASTLANE_APP_ID"], |
| 25 | + android_artifact_type: "APK", |
| 26 | + groups: "sourcetoad" |
| 27 | +) |
| 28 | +``` |
| 29 | + |
| 30 | +A quick peek of their [docs](https://firebase.google.com/docs/app-distribution/ios/distribute-fastlane#distribute) we noticed 2 parameters that caught our eye: |
| 31 | +- `release_notes`: A string to be used as the changelog for the release. |
| 32 | +- `release_notes_file`: A file path to a text file containing the changelog for the release. |
| 33 | + |
| 34 | +Knowing we could easily obtain commits in our GitHub Actions pipeline we theorized we could generate a file based on the commits and pass that to Firebase. |
| 35 | + |
| 36 | +```yaml |
| 37 | +- name: Release Notes |
| 38 | + shell: bash |
| 39 | + run: echo $JSON | jq '.event.commits[]' | jq '.message' | jq tostring | jq '.[0:100]' > release_notes.txt |
| 40 | + env: |
| 41 | + JSON: ${{ toJSON(github) }} |
| 42 | +``` |
| 43 | +
|
| 44 | +With the power of [jq](https://jqlang.org) - we did this relatively quickly. We grabbed the commit messages from the [GitHub event payload](https://docs.github.com/en/enterprise-cloud@latest/webhooks/webhook-events-and-payloads#push), converted them to strings and truncated them to 100 characters to shorten those massive Dependabot commits. We then wrote that to a file called `release_notes.txt`. |
| 45 | + |
| 46 | +We then dug into the source code of the [firebase_app_distribution action](https://github.com/firebase/fastlane-plugin-firebase_app_distribution/blob/master/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb#L537) so we could find out the environment variable name that corresponded to the `release_notes_file` parameter. |
| 47 | + |
| 48 | +Once discovered (`FIREBASEAPPDISTRO_RELEASE_NOTES_FILE`) we updated our fastlane step to include that environment variable and waited for the next merge. |
| 49 | + |
| 50 | +```yaml |
| 51 | +FIREBASEAPPDISTRO_RELEASE_NOTES_FILE: ${{ github.workspace }}/release_notes.txt |
| 52 | +``` |
| 53 | + |
| 54 | +Sure enough as the email arrived we had a beautiful internal changelog included in the email. |
| 55 | + |
| 56 | +<div class="text--center"> |
| 57 | +  |
| 58 | +</div> |
| 59 | + |
| 60 | +It was a small change that made a large difference in terms of supporting our internal testers. They had a much easier time understanding the intent of each build. |
| 61 | + |
| 62 | + * [fastlane.tools](https://fastlane.tools) |
| 63 | + * [Firebase - Android](https://firebase.google.com/docs/app-distribution/android/distribute-fastlane?apptype=apk) |
| 64 | + * [Firebase - iOS](https://firebase.google.com/docs/app-distribution/ios/distribute-fastlane) |
| 65 | + * [GitHub - fastlane-plugin-firebase_app_distribution](https://github.com/firebase/fastlane-plugin-firebase_app_distribution) |
0 commit comments