4343 - name : Set up Android SDK
4444 if : steps.cache-jniLibs.outputs.cache-hit != 'true'
4545 uses : android-actions/setup-android@v2
46- - name : Install NDK
46+ - name : Set up Android NDK
4747 if : steps.cache-jniLibs.outputs.cache-hit != 'true'
4848 run : |
4949 sdkmanager "ndk;${{ env.NDK_VERSION }}"
@@ -82,13 +82,53 @@ jobs:
8282 run : |
8383 test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
8484
85+ # This needs to be a seperate job since fastlane update_version,
86+ # fails if run concurrently (such as in build apk/aab matrix),
87+ # thus we need to run it once and and reuse the results.
88+ # https://github.com/fastlane/fastlane/issues/13689#issuecomment-439217502
89+ get-versionCode :
90+ name : Get latest versionCode
91+ runs-on : ubuntu-latest
92+ outputs :
93+ versionCode : ${{ steps.versionCode.outputs.versionCode }}
94+
95+ steps :
96+ - uses : actions/checkout@v2
97+ with :
98+ submodules : ' recursive'
99+
100+
101+ # Ruby & Fastlane
102+ # version set by .ruby-version
103+ - name : Set up Ruby and install fastlane
104+ uses : ruby/setup-ruby@v1
105+ with :
106+ bundler-cache : true
107+
108+ # Needed for `fastlane update_version`
109+ - uses : adnsio/setup-age-action@v1.2.0
110+ - name : Load Fastlane secrets
111+ env :
112+ KEY_FASTLANE_API : ${{ secrets.KEY_FASTLANE_API }}
113+ run : |
114+ printf "$KEY_FASTLANE_API" > fastlane/api-8546008605074111507-287154-450dc77b365f.json.key
115+ cat fastlane/api-8546008605074111507-287154-450dc77b365f.json.age \
116+ | age -d -i fastlane/api-8546008605074111507-287154-450dc77b365f.json.key \
117+ -o fastlane/api-8546008605074111507-287154-450dc77b365f.json
118+ rm fastlane/api-8546008605074111507-287154-450dc77b365f.json.key
119+
120+ - name : Update versionCode
121+ run : bundle exec fastlane update_version
122+
123+ - name : Output versionCode
124+ id : versionCode
125+ run : |
126+ cat mobile/build.gradle | grep versionCode | sed 's/.*\s\([0-9]*\)$/versionCode=\1/' >> "$GITHUB_OUTPUT"
85127
86128 build-apk :
87129 name : Build ${{ matrix.type }}
88130 runs-on : ubuntu-20.04
89- needs : [build-rust]
90- env :
91- SUPPLY_TRACK : production # used by fastlane to determine track to publish to
131+ needs : [build-rust, get-versionCode]
92132 strategy :
93133 fail-fast : true
94134 matrix :
@@ -108,19 +148,11 @@ jobs:
108148 run : |
109149 echo "${{ steps.version.outputs.full }} (stable: ${{ steps.version.outputs.is_stable }})"
110150
111- - name : Set RELEASE and SUPPLY_TRACK
151+ - name : Set RELEASE
112152 run : |
113153 # Build in release mode if on a tag/release (longer build times)
114154 echo "RELEASE=${{ startsWith(github.ref_name, 'v') }}" >> $GITHUB_ENV
115155
116- # Set SUPPLY_TRACK (used by fastlane) depending on is_stable
117- if [[ "${{ steps.version.outputs.is_stable }}" == "true" ]]; then
118- SUPPLY_TRACK="production"
119- else
120- SUPPLY_TRACK="internal"
121- fi
122- echo "SUPPLY_TRACK=${SUPPLY_TRACK}" >> $GITHUB_ENV
123-
124156 - name : Set up JDK
125157 uses : actions/setup-java@v1
126158 with :
@@ -129,23 +161,13 @@ jobs:
129161 # Android SDK & NDK
130162 - name : Set up Android SDK
131163 uses : android-actions/setup-android@v2
132- - name : Install NDK
164+ - name : Set up Android NDK
133165 run : |
134166 sdkmanager "ndk;${{ env.NDK_VERSION }}"
135167 ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
136168 ls $ANDROID_NDK_HOME
137169 echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
138170
139- # Ruby & Fastlane
140- # version set by .ruby-version
141- - name : Set up Ruby and install fastlane
142- uses : ruby/setup-ruby@v1
143- with :
144- bundler-cache : true
145-
146- - name : Install age
147- uses : adnsio/setup-age-action@v1.2.0
148-
149171 # Restores jniLibs from cache
150172 # `actions/cache/restore` only restores, without saving back in a post-hook
151173 - uses : actions/cache/restore@v3
@@ -161,28 +183,21 @@ jobs:
161183 run : |
162184 test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
163185
164- # Needed for `fastlane update_version`
165- - name : Load Fastlane secrets
166- env :
167- KEY_FASTLANE_API : ${{ secrets.KEY_FASTLANE_API }}
168- run : |
169- printf "$KEY_FASTLANE_API" > fastlane/api-8546008605074111507-287154-450dc77b365f.json.key
170- cat fastlane/api-8546008605074111507-287154-450dc77b365f.json.age \
171- | age -d -i fastlane/api-8546008605074111507-287154-450dc77b365f.json.key \
172- -o fastlane/api-8546008605074111507-287154-450dc77b365f.json
173- rm fastlane/api-8546008605074111507-287154-450dc77b365f.json.key
174-
175- - name : Set version
186+ - name : Set versionName
176187 if : startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag
177188 run : |
178189 # Sets versionName, tail used to skip "v" at start of tag name
179190 SHORT_VERSION=$(echo "${{ github.ref_name }}" | tail -c +2 -)
180191 sed -i "s/versionName \".*\"/versionName \"$SHORT_VERSION\"/g" \
181192 mobile/build.gradle
182193
183- - name : Update versionCode
184- run : bundle exec fastlane update_version
194+ - name : Set versionCode
195+ run : |
196+ # Sets versionCode
197+ sed -i "s/versionCode .*/versionCode ${{needs.get-versionCode.outputs.versionCode}}/" \
198+ mobile/build.gradle
185199
200+ - uses : adnsio/setup-age-action@v1.2.0
186201 - name : Load Android secrets
187202 if : env.KEY_ANDROID_JKS != null
188203 env :
@@ -229,7 +244,7 @@ jobs:
229244 # Android SDK & NDK
230245 - name : Set up Android SDK
231246 uses : android-actions/setup-android@v2
232- - name : Install NDK
247+ - name : Set up Android NDK
233248 run : |
234249 sdkmanager "ndk;${{ env.NDK_VERSION }}"
235250 ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
@@ -387,7 +402,7 @@ jobs:
387402 # Android SDK & NDK
388403 - name : Set up Android SDK
389404 uses : android-actions/setup-android@v2
390- - name : Install NDK
405+ - name : Set up Android NDK
391406 run : |
392407 sdkmanager "ndk;${{ env.NDK_VERSION }}"
393408 ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
@@ -496,7 +511,7 @@ jobs:
496511 echo "SUPPLY_TRACK=${SUPPLY_TRACK}" >> $GITHUB_ENV
497512
498513 - uses : adnsio/setup-age-action@v1.2.0
499- - name : Load secrets
514+ - name : Load Android secrets
500515 env :
501516 KEY_FASTLANE_API : ${{ secrets.KEY_FASTLANE_API }}
502517 run : |
0 commit comments