Updatable builds (#1791)
* save and increment build number for each PR * cd into repo path * trial * try generating the release build without a keystore * cache keystore to maintain same signature for PR builds * weird fix * potential fix * fix key path * meh * Update cache_dependencies.yml
Omar Hatem committed
Nov 9, 2024 at 21:07 UTC
288164603723279711dd6a894d48d7645821fb36
2 files changed
+61
-3
.github/workflows/cache_dependencies.yml
+14
-1
@@ -67,4 +67,17 @@ jobs:
67
run: |
68
cd /opt/android/cake_wallet/scripts/android/
69
source ./app_env.sh cakewallet
70
- ./build_monero_all.sh
\ No newline at end of file
70
+ ./build_monero_all.sh
71
+
72
+ - name: Cache Keystore
73
+ id: cache-keystore
74
+ uses: actions/cache@v3
75
+ with:
76
+ path: /opt/android/cake_wallet/android/app/key.jks
77
+ key: $STORE_PASS
78
+
79
+ - if: ${{ steps.cache-keystore.outputs.cache-hit != 'true' }}
80
+ name: Generate KeyStore
81
+ run: |
82
+ cd /opt/android/cake_wallet/android/app
83
+ keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias testKey -noprompt -dname "CN=CakeWallet, OU=CakeWallet, O=CakeWallet, L=Florida, S=America, C=USA" -storepass $STORE_PASS -keypass $KEY_PASS
.github/workflows/pr_test_build_android.yml
+47
-2
@@ -116,8 +116,15 @@ jobs:
116
cd /opt/android/cake_wallet/scripts/android/
117
./build_mwebd.sh --dont-install
118
119
- - name: Generate KeyStore
120
- if: ${{ steps.cache-externals.outputs.cache-hit != 'true' }}
119
+ - name: Cache Keystore
120
+ id: cache-keystore
121
+ uses: actions/cache@v3
122
+ with:
123
+ path: /opt/android/cake_wallet/android/app/key.jks
124
+ key: $STORE_PASS
125
+
126
+ - if: ${{ steps.cache-keystore.outputs.cache-hit != 'true' }}
127
+ name: Generate KeyStore
128
run: |
129
cd /opt/android/cake_wallet/android/app
130
keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias testKey -noprompt -dname "CN=CakeWallet, OU=CakeWallet, O=CakeWallet, L=Florida, S=America, C=USA" -storepass $STORE_PASS -keypass $KEY_PASS
@@ -205,6 +212,36 @@ jobs:
212
run: |
213
echo -e "id=com.cakewallet.test_${{ env.PR_NUMBER }}\nname=${{ env.BRANCH_NAME }}" > /opt/android/cake_wallet/android/app.properties
214
215
+ # Step 3: Download previous build number
216
+ - name: Download previous build number
217
+ id: download-build-number
218
+ run: |
219
+ # Download the artifact if it exists
220
+ if [[ ! -f build_number.txt ]]; then
221
+ echo "1" > build_number.txt
222
+ fi
223
+
224
+ # Step 4: Read and Increment Build Number
225
+ - name: Increment Build Number
226
+ id: increment-build-number
227
+ run: |
228
+ # Read current build number from file
229
+ BUILD_NUMBER=$(cat build_number.txt)
230
+ BUILD_NUMBER=$((BUILD_NUMBER + 1))
231
+ echo "New build number: $BUILD_NUMBER"
232
+
233
+ # Save the incremented build number
234
+ echo "$BUILD_NUMBER" > build_number.txt
235
+
236
+ # Export the build number to use in later steps
237
+ echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
238
+
239
+ # Step 5: Update pubspec.yaml with new build number
240
+ - name: Update build number
241
+ run: |
242
+ cd /opt/android/cake_wallet
243
+ sed -i "s/^version: .*/version: 1.0.$BUILD_NUMBER/" pubspec.yaml
244
+
245
- name: Build
246
run: |
247
cd /opt/android/cake_wallet
@@ -235,6 +272,13 @@ jobs:
272
with:
273
path: /opt/android/cake_wallet/build/app/outputs/flutter-apk/test-apk/
274
275
+ # Re-upload updated build number for the next run
276
+ - name: Upload updated build number
277
+ uses: actions/upload-artifact@v3
278
+ with:
279
+ name: build_number
280
+ path: build_number.txt
281
+
282
- name: Send Test APK
283
continue-on-error: true
284
uses: adrey/slack-file-upload-action@1.0.5
@@ -245,3 +289,4 @@ jobs:
289
title: "${{ env.BRANCH_NAME }}.apk"
290
filename: ${{ env.BRANCH_NAME }}.apk
291
initial_comment: ${{ github.event.head_commit.message }}
292
+