-
Notifications
You must be signed in to change notification settings - Fork 5
216 lines (187 loc) · 7.05 KB
/
android-workflow.yaml
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: CI Workflow
# Run this workflow every time a new commit pushed to your repository
on: push
jobs:
unit-tests:
name: Run Unit Tests
runs-on: macos-latest
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2
# Set up Java JDK
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Get the secrets from GitHub and add them to local.properties
# https://blog.jakelee.co.uk/accessing-android-app-secret-from-github-actions-using-gradle/
- name: Access PLATFORM_CLIENT_ID
env:
PLATFORM_CLIENT_ID: ${{ secrets.PLATFORM_CLIENT_ID }}
run: echo PLATFORM_CLIENT_ID=\"$PLATFORM_CLIENT_ID\" >> ./local.properties
- name: Access PLATFORM_REDIRECT_URI
env:
PLATFORM_REDIRECT_URI: ${{ secrets.PLATFORM_REDIRECT_URI }}
run: echo PLATFORM_REDIRECT_URI=\"$PLATFORM_REDIRECT_URI\" >> ./local.properties
# Create google-services.json
- name: Create google-services.json
run: |
cat << EOF > PennMobile/google-services.json
${{ secrets.GOOGLE_SERVICES_JSON }}
EOF
# Run unit tests
- name: Run Unit Tests
run: ./gradlew testDebugUnitTest --warning-mode all --stacktrace
# If tests pass, generate and upload APK
generate-apk:
name: Generate apk
runs-on: ubuntu-latest
needs: unit-tests
# Generate APK only if we are pushing to master or pushing a new release tag
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Get the secrets from GitHub and add them to local.properties
- name: Access PLATFORM_CLIENT_ID
env:
PLATFORM_CLIENT_ID: ${{ secrets.PLATFORM_CLIENT_ID }}
run: echo PLATFORM_CLIENT_ID=\"$PLATFORM_CLIENT_ID\" >> ./local.properties
- name: Access PLATFORM_REDIRECT_URI
env:
PLATFORM_REDIRECT_URI: ${{ secrets.PLATFORM_REDIRECT_URI }}
run: echo PLATFORM_REDIRECT_URI=\"$PLATFORM_REDIRECT_URI\" >> ./local.properties
# Create google-services.json
- name: Create google-services.json
run: |
cat << EOF > PennMobile/google-services.json
${{ secrets.GOOGLE_SERVICES_JSON }}
EOF
# Generate Signed APK
- name: Generate Release APK
run: ./gradlew assembleRelease
- name: Setup build tool version variable
shell: bash
run: |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
echo Last build tool version is: $BUILD_TOOL_VERSION
- name: Sign app APK
uses: r0adkll/sign-android-release@v1
# ID used to access action output
id: sign_app
with:
releaseDirectory: PennMobile/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
# Upload signed APK
- uses: actions/upload-artifact@v4
with:
name: release.apk
path: ${{steps.sign_app.outputs.signedReleaseFile}}
code-cov:
name: JaCoCo Code Coverage
# Set the type of machine to run on, macOS is better for running Android emulators
runs-on: macos-latest
needs: unit-tests
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Get the secrets from GitHub and add them to local.properties
- name: Access PLATFORM_CLIENT_ID
env:
PLATFORM_CLIENT_ID: ${{ secrets.PLATFORM_CLIENT_ID }}
run: echo PLATFORM_CLIENT_ID=\"$PLATFORM_CLIENT_ID\" >> ./local.properties
- name: Access PLATFORM_REDIRECT_URI
env:
PLATFORM_REDIRECT_URI: ${{ secrets.PLATFORM_REDIRECT_URI }}
run: echo PLATFORM_REDIRECT_URI=\"$PLATFORM_REDIRECT_URI\" >> ./local.properties
# Create google-services.json
- name: Create google-services.json
run: |
cat << EOF > PennMobile/google-services.json
${{ secrets.GOOGLE_SERVICES_JSON }}
EOF
# Run JaCoCo, generate Test Report
- name: Check Code Coverage
run: ./gradlew jacocoTestReport --stacktrace
# Upload reports to GitHub Actions
- name: Upload Reports
uses: actions/upload-artifact@v4
with:
name: reports
path: PennMobile/build/reports
ktlint-check:
name: Check Kotlin Code Style
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Install ktlint
run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.3.1/ktlint
chmod a+x ktlint
sudo mv ktlint /usr/local/bin/
- name: Run ktlint
run: |
set -o pipefail
ktlint --reporter=plain > ktlint_errors.txt
- name: Check for ktlint errors
if: ${{ failure() || steps.run_ktlint.exitCode == 1 }}
run: cat ktlint_errors.txt
# Publish to Firebase App Distribution
# https://github.com/wzieba/Firebase-Distribution-Github-Action
deploy-firebase:
needs: generate-apk
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: release.apk
- name: Upload APK to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{secrets.FIREBASE_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: tester
file: PennMobile-release-unsigned-signed.apk
# Publish to Play Store test track
deploy-play-store:
needs: generate-apk
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: release.apk
- name: Publish to Play Store internal test track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: com.pennapps.labs.pennmobile
releaseFiles: PennMobile-release-unsigned-signed.apk
track: internal
status: completed
# userFraction: 0.50