Skip to content

Commit 9be40c3

Browse files
committed
chore: refactor GitHub Actions workflow for Android builds
This commit refactors the GitHub Actions workflow for Android builds. Key changes: - Introduced a `setup` job to handle environment setup, including Ruby, Bundler, Fastlane, keystore, and Google Play JSON. - The `setup` job now outputs the `bundle-path` for use in subsequent jobs. - The `build-bundle` job is renamed to `build` and now focuses solely on building the AAB. - Subsequent jobs (`unit-test`, `code-analysis`, `deploy-release`, `deploy-beta`, `deploy-firebase-internal`) now depend on the `build` job and utilize the `bundle-path` output from the `setup` job. - Removed redundant setup steps from deployment and testing jobs. - Standardized Google Play JSON file path using an environment variable. - Updated job dependencies to reflect the new workflow structure. - Removed the `deploy-firebase-beta` job as it was redundant with `deploy-beta`.
1 parent 9c709fe commit 9be40c3

File tree

1 file changed

+48
-81
lines changed

1 file changed

+48
-81
lines changed

.github/workflows/android.yml

Lines changed: 48 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ env:
1313
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
1414
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
1515
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
16+
GOOGLE_PLAY_JSON_PATH: app/qrbarcode-8b0b8-aaefa03b2374.json
1617

1718
jobs:
18-
build-bundle:
19-
name: Build AAB
19+
setup:
20+
name: Setup Environment
2021
runs-on: ubuntu-latest
22+
container:
23+
image: softartdev/android-fastlane:33
24+
outputs:
25+
bundle-path: ${{ steps.set-bundle-path.outputs.bundle-path }}
2126

2227
steps:
2328
- name: Checkout Repository
@@ -32,34 +37,57 @@ jobs:
3237
- name: Setup Android SDK
3338
uses: android-actions/setup-android@v3
3439

40+
- name: Setup Ruby
41+
uses: ruby/setup-ruby@v1
42+
with:
43+
ruby-version: '3.2'
44+
45+
- name: Set Bundle Path Output
46+
id: set-bundle-path
47+
run: echo "bundle-path=${HOME}/.gem/ruby/3.2.0/bin" >> $GITHUB_OUTPUT
48+
49+
- name: Cache Ruby Gems
50+
uses: actions/cache@v4
51+
with:
52+
path: vendor/bundle
53+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
54+
3555
- name: Install Bundler & Fastlane
3656
run: |
3757
gem install bundler:2.5.11 --user-install
3858
bundle _2.5.11_ config set path vendor/bundle
3959
bundle _2.5.11_ install
4060
env:
41-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
61+
PATH: "${{ steps.set-bundle-path.outputs.bundle-path }}:${PATH}"
62+
63+
- name: Decode Keystore File
64+
run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > $KEYSTORE_FILE
4265

43-
- name: Setup local.properties
66+
- name: Write local.properties
4467
run: |
4568
echo "sdk.dir=$ANDROID_HOME" > local.properties
4669
echo "KEYSTORE_FILE=$KEYSTORE_FILE" >> local.properties
4770
echo "KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD" >> local.properties
4871
echo "KEY_ALIAS=$KEY_ALIAS" >> local.properties
4972
echo "KEY_PASSWORD=$KEY_PASSWORD" >> local.properties
5073
51-
- name: Decode keystore file
52-
run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > $KEYSTORE_FILE
53-
54-
- name: Create Service Account JSON (base64)
74+
- name: Create Google Service Account JSON
5575
run: |
5676
mkdir -p app
57-
echo "${{ secrets.GOOGLE_PLAY_JSON }}" | base64 --decode > app/qrbarcode-8b0b8-aaefa03b2374.json
77+
echo "${{ secrets.GOOGLE_PLAY_JSON }}" | base64 --decode > ${{ env.GOOGLE_PLAY_JSON_PATH }}
78+
79+
build:
80+
name: Build AAB
81+
runs-on: ubuntu-latest
82+
needs: setup
83+
84+
steps:
85+
- uses: actions/checkout@v3
5886

5987
- name: Run buildBundle lane
6088
run: bundle exec fastlane buildBundle
6189
env:
62-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
90+
PATH: "${{ needs.setup.outputs.bundle-path }}:${PATH}"
6391

6492
- name: Upload Bundle Artifact
6593
uses: actions/upload-artifact@v4
@@ -70,33 +98,19 @@ jobs:
7098
unit-test:
7199
name: Unit Tests
72100
runs-on: ubuntu-latest
73-
needs: build-bundle
101+
needs: build
74102

75103
steps:
76104
- uses: actions/checkout@v3
77-
- name: Setup Java
78-
uses: actions/setup-java@v3
79-
with:
80-
java-version: '17'
81-
distribution: 'temurin'
82-
83-
- name: Install Bundler & Dependencies
84-
run: |
85-
gem install bundler:2.5.11 --user-install
86-
bundle _2.5.11_ config set path vendor/bundle
87-
bundle _2.5.11_ install
88-
env:
89-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
90-
91-
- name: Run Fastlane Test
105+
- name: Run Tests
92106
run: bundle exec fastlane test
93107
env:
94-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
108+
PATH: "${{ needs.setup.outputs.bundle-path }}:${PATH}"
95109

96110
code-analysis:
97111
name: Lint & Check
98112
runs-on: ubuntu-latest
99-
needs: build-bundle
113+
needs: build
100114

101115
steps:
102116
- uses: actions/checkout@v3
@@ -114,84 +128,37 @@ jobs:
114128
name: Deploy to Play Store (Production)
115129
runs-on: ubuntu-latest
116130
if: github.ref == 'refs/heads/master'
117-
needs: build-bundle
131+
needs: build
118132

119133
steps:
120134
- uses: actions/checkout@v3
121-
- name: Setup
122-
run: |
123-
gem install bundler:2.5.11 --user-install
124-
bundle _2.5.11_ config set path vendor/bundle
125-
bundle _2.5.11_ install
126-
echo "${{ secrets.GOOGLE_PLAY_JSON }}" | base64 --decode > app/qrbarcode-8b0b8-aaefa03b2374.json
127-
env:
128-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
129-
130135
- name: Deploy
131136
run: bundle exec fastlane deployRelease
132137
env:
133-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
138+
PATH: "${{ needs.setup.outputs.bundle-path }}:${PATH}"
134139

135140
deploy-beta:
136141
name: Deploy to Play Store (Beta)
137142
runs-on: ubuntu-latest
138143
if: github.ref == 'refs/heads/development'
139-
needs: build-bundle
144+
needs: build
140145

141146
steps:
142147
- uses: actions/checkout@v3
143-
- name: Setup
144-
run: |
145-
gem install bundler:2.5.11 --user-install
146-
bundle _2.5.11_ config set path vendor/bundle
147-
bundle _2.5.11_ install
148-
echo "${{ secrets.GOOGLE_PLAY_JSON }}" | base64 --decode > app/qrbarcode-8b0b8-aaefa03b2374.json
149-
env:
150-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
151-
152148
- name: Deploy
153149
run: bundle exec fastlane deployBeta
154150
env:
155-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
156-
157-
deploy-firebase-beta:
158-
name: Distribute via Firebase (Beta)
159-
runs-on: ubuntu-latest
160-
if: github.ref == 'refs/heads/development'
161-
needs: build-bundle
162-
163-
steps:
164-
- uses: actions/checkout@v3
165-
- name: Setup
166-
run: |
167-
gem install bundler:2.5.11 --user-install
168-
bundle _2.5.11_ config set path vendor/bundle
169-
bundle _2.5.11_ install
170-
env:
171-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
172-
173-
- name: Deploy
174-
run: bundle exec fastlane deployFirebase --verbose
175-
env:
176-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
151+
PATH: "${{ needs.setup.outputs.bundle-path }}:${PATH}"
177152

178153
deploy-firebase-internal:
179154
name: Distribute via Firebase (Internal)
180155
runs-on: ubuntu-latest
181156
if: startsWith(github.ref, 'refs/heads/internal-testing/')
182-
needs: build-bundle
157+
needs: build
183158

184159
steps:
185160
- uses: actions/checkout@v3
186-
- name: Setup
187-
run: |
188-
gem install bundler:2.5.11 --user-install
189-
bundle _2.5.11_ config set path vendor/bundle
190-
bundle _2.5.11_ install
191-
env:
192-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
193-
194161
- name: Deploy
195162
run: bundle exec fastlane deployFirebase --verbose
196163
env:
197-
PATH: "${HOME}/.gem/ruby/3.2.0/bin:${PATH}"
164+
PATH: "${{ needs.setup.outputs.bundle-path }}:${PATH}"

0 commit comments

Comments
 (0)