-
Notifications
You must be signed in to change notification settings - Fork 1
160 lines (134 loc) · 5.61 KB
/
build-android-prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Android Deploy
run-name: Android Deploy for ${{ inputs.brand }} on ${{github.ref_name}}
on:
workflow_dispatch:
inputs:
brand:
description: 'Brand to publish'
required: true
default: 'cozy'
type: choice
options:
- cozy
- mabulle
jobs:
android-build:
name: Android Deploy
runs-on: ubuntu-latest
steps:
- name: Set NodeJS version
uses: actions/setup-node@v3
with:
node-version: 16
- name: Check out Git repository
uses: actions/checkout@v3
- name: Set up our JDK environment
uses: actions/setup-java@v3
with:
distribution: 'adopt-hotspot'
java-version: '11'
- name: Fixing Android Build Tool Issue
run: |
cd $ANDROID_HOME/build-tools/33.0.0
mv d8 dx
cd lib
mv d8.jar dx.jar
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Restore node_modules from cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Cache Gradle Wrapper
uses: actions/cache@v3
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Cache Gradle Dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-caches-
- name: 'Create env file'
run: |
touch .env
- name: Set white label brand
run: yarn brand:configure:${{ inputs.brand }} --force
- name: Make Gradlew Executable
run: cd android && chmod +x ./gradlew
- name: Build Android App Bundle
run: |
cd android && ./gradlew bundleRelease --no-daemon
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Sign App Bundle
id: sign_app
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: android/app/build/outputs/bundle/prodRelease
signingKeyBase64: ${{ secrets[format('{0}_ANDROID_SIGNING_KEY', inputs.brand)] }}
alias: ${{ secrets[format('{0}_ANDROID_ALIAS', inputs.brand)] }}
keyStorePassword: ${{ secrets[format('{0}_ANDROID_KEY_STORE_PASSWORD', inputs.brand)] }}
keyPassword: ${{ secrets[format('{0}_ANDROID_KEY_PASSWORD', inputs.brand)] }}
env:
BUILD_TOOLS_VERSION: "33.0.0"
- name: Upload AAB artifact to GitHub
uses: actions/upload-artifact@v3
with:
name: AAB
path: android/app/build/outputs/bundle/prodRelease/*.aab
- name: Upload App to Google Play
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.ANDROID_SERVICE_ACCOUNT_JSON_TEXT }}
packageName: ${{ inputs.brand != 'cozy' && format('io.cozy.flagship.mobile.{0}', inputs.brand) || 'io.cozy.flagship.mobile' }}
releaseFiles: android/app/build/outputs/bundle/prodRelease/*.aab
track: internal
- name: Download BundleTool
run: |
curl -L https://github.com/google/bundletool/releases/download/1.8.0/bundletool-all-1.8.0.jar -o bundletool.jar
- name: Decode signing key
run: echo "${{ secrets[format('{0}_ANDROID_SIGNING_KEY', inputs.brand)] }}" | base64 --decode > signingKey.jks
env:
BUILD_TOOLS_VERSION: "33.0.0"
- name: Generate APK Set from AAB
run: |
java -jar bundletool.jar build-apks \
--bundle=android/app/build/outputs/bundle/prodRelease/app-prod-release.aab \
--output=app-prod-release.apks \
--mode=universal \
--ks=signingKey.jks \
--ks-pass=pass:${{ secrets[format('{0}_ANDROID_KEY_STORE_PASSWORD', inputs.brand)] }} \
--ks-key-alias=${{ secrets[format('{0}_ANDROID_ALIAS', inputs.brand)] }} \
--key-pass=pass:${{ secrets[format('{0}_ANDROID_KEY_PASSWORD', inputs.brand)] }}
- name: Rename .apks file to .zip
run: mv app-prod-release.apks app-prod-release.zip
- name: Unzip the universal APK from the .zip file
run: unzip app-prod-release.zip -d ./extracted-apks
- name: Rename and move Universal APK
run: |
APK_PATH=$(find ./extracted-apks -name '*.apk')
mv "$APK_PATH" "./extracted-apks/cozy_flagship_universal.apk"
- name: Extract Version Info and Define Artifact Name
run: |
GRADLE_PATH="./android/app/build.gradle"
VERSION_CODE=$(awk '/versionCode/ {print}' $GRADLE_PATH | sed 's/[^0-9*]//g' | bc)
VERSION_NAME=$(grep versionName $GRADLE_PATH | awk -F '"' '{print $2}')
ARTIFACT_NAME="App-$VERSION_NAME-$VERSION_CODE-${{ github.event.inputs.brand }}"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
echo "::set-output name=artifact_name::$ARTIFACT_NAME"
id: artifact_info
- name: Upload APK artifact to GitHub
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact_info.outputs.artifact_name }}
path: ./extracted-apks/cozy_flagship_universal.apk