Skip to content

Commit 9be7229

Browse files
Merge pull request #629 from nimblehq/chore/463-generate-and-add-release-notes-when-distributing-new-builds-on-firebase
[#463] Github Action: Generate and add "release notes" when distributing new builds on Firebase (staging and production)
2 parents 2a72ba8 + 057bd23 commit 9be7229

File tree

2 files changed

+102
-15
lines changed

2 files changed

+102
-15
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Deploy production to Firebase App Distribution
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
inputs:
9+
testerGroups:
10+
description: "Tester groups (Use \"vars.TESTER_GROUPS\" as default)"
11+
required: false
12+
type: string
13+
14+
jobs:
15+
deploy_production_to_firebase_app_distribution:
16+
name: Deploy production to Firebase App Distribution
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 30
19+
steps:
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v3
22+
with:
23+
distribution: 'temurin'
24+
java-version: '17'
25+
26+
- name: Set up timezone
27+
uses: zcong1993/setup-timezone@master
28+
with:
29+
timezone: Asia/Bangkok
30+
31+
- name: Checkout source code
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Cache Gradle
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.gradle/caches/modules-*
41+
~/.gradle/caches/jars-*
42+
~/.gradle/caches/build-cache-*
43+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
44+
restore-keys: |
45+
${{ runner.os }}-gradle-
46+
47+
- name: Run Detekt
48+
run: ./gradlew detekt
49+
50+
- name: Archive Detekt reports
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: DetektReports
54+
path: build/reports/detekt/
55+
56+
- name: Run unit tests with Kover
57+
run: ./gradlew koverHtmlReportCustom
58+
59+
- name: Archive code coverage reports
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: CodeCoverageReports
63+
path: app/build/reports/kover/
64+
65+
- name: Generate release notes
66+
id: generate-release-notes
67+
run: |
68+
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_OUTPUT
69+
echo "$(git log --merges --pretty=%B $(git describe --abbrev=0 --tags)..HEAD | grep "\[")" >> $GITHUB_OUTPUT
70+
echo 'EOF' >> $GITHUB_OUTPUT
71+
72+
- name: Build production APK
73+
run: ./gradlew assembleProductionPreRelease
74+
75+
- name: Deploy production to Firebase
76+
uses: wzieba/Firebase-Distribution-Github-Action@v1
77+
with:
78+
appId: ${{secrets.FIREBASE_APP_ID_PRODUCTION}}
79+
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIAL_FILE_CONTENT }}
80+
groups: ${{ github.event.inputs.testerGroups || vars.TESTER_GROUPS }}
81+
file: app/build/outputs/apk/production/preRelease/app-production-preRelease.apk
82+
releaseNotes: ${{ steps.generate-release-notes.outputs.RELEASE_NOTES }}

.cicdtemplate/.github/workflows/deploy_staging_and_production_to_firebase_app_distribution.yml renamed to .cicdtemplate/.github/workflows/deploy_staging_to_firebase_app_distribution.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
name: Deploy staging and production to Firebase App Distribution
1+
name: Deploy staging to Firebase App Distribution
22

33
on:
44
# Trigger the workflow on push action in develop branch.
55
# So it will trigger when the PR of the feature branch was merged.
66
push:
77
branches:
88
- develop
9+
workflow_dispatch:
10+
inputs:
11+
testerGroups:
12+
description: "Tester groups (Use \"vars.TESTER_GROUPS\" as default)"
13+
required: false
14+
type: string
915

1016
jobs:
11-
deploy_staging_and_production_to_firebase_app_distribution:
12-
name: Deploy staging and production to Firebase App Distribution
17+
deploy_staging_to_firebase_app_distribution:
18+
name: Deploy staging to Firebase App Distribution
1319
runs-on: ubuntu-latest
1420
timeout-minutes: 30
1521
steps:
@@ -26,6 +32,8 @@ jobs:
2632

2733
- name: Checkout source code
2834
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
2937

3038
- name: Cache Gradle
3139
uses: actions/cache@v4
@@ -59,21 +67,18 @@ jobs:
5967
- name: Build staging APK
6068
run: ./gradlew assembleStagingPreRelease
6169

70+
- name: Generate release notes
71+
id: generate-release-notes
72+
run: |
73+
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_OUTPUT
74+
echo "$((git log -1 --merges | grep "\[") | grep . && echo "" || echo $(git log -1 --merges --format=%B))" >> $GITHUB_OUTPUT
75+
echo 'EOF' >> $GITHUB_OUTPUT
76+
6277
- name: Deploy staging to Firebase
6378
uses: wzieba/Firebase-Distribution-Github-Action@v1
6479
with:
6580
appId: ${{secrets.FIREBASE_APP_ID_STAGING}}
6681
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIAL_FILE_CONTENT }}
67-
groups: testers
82+
groups: ${{ github.event.inputs.testerGroups || vars.TESTER_GROUPS }}
6883
file: app/build/outputs/apk/staging/preRelease/app-staging-preRelease.apk
69-
70-
- name: Build production APK
71-
run: ./gradlew assembleProductionPreRelease
72-
73-
- name: Deploy production to Firebase
74-
uses: wzieba/Firebase-Distribution-Github-Action@v1
75-
with:
76-
appId: ${{secrets.FIREBASE_APP_ID_PRODUCTION}}
77-
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIAL_FILE_CONTENT }}
78-
groups: testers
79-
file: app/build/outputs/apk/production/preRelease/app-production-preRelease.apk
84+
releaseNotes: ${{ steps.generate-release-notes.outputs.RELEASE_NOTES }}

0 commit comments

Comments
 (0)