-
Notifications
You must be signed in to change notification settings - Fork 104
249 lines (231 loc) · 8.88 KB
/
android.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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Android CI
on:
push:
branches: [ main ]
paths: [ '.github/**', 'android/**' ]
pull_request:
branches: [ main ]
paths: [ '.github/**', 'android/**' ]
release:
types: [ published ]
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: android
steps:
# Setup
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
- name: Deploy APK signing keystore and related secrets (test signing)
if: ${{ github.event_name != 'pull_request' }}
env:
KEYSTORE_BASE64: ${{ secrets.APK_SIGNING_TEST_KEYSTORE }}
KEYSTORE_PATH: ${{ runner.temp }}/apk_signing_keystore.jks
run: echo $KEYSTORE_BASE64 | base64 --decode > $KEYSTORE_PATH
# Build
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle and run tests
env:
ORG_GRADLE_PROJECT_apkSigningKeystorePath: ${{ runner.temp }}/apk_signing_keystore.jks
ORG_GRADLE_PROJECT_apkSigningKeyAlias: signing
ORG_GRADLE_PROJECT_apkSigningKeystorePassword: ${{ secrets.APK_SIGNING_TEST_PASSWORD }}
ORG_GRADLE_PROJECT_apkSigningKeyPassword: ${{ secrets.APK_SIGNING_TEST_PASSWORD }}
run: ./gradlew build
# Upload binaries to workflow artifacts
- uses: actions/upload-artifact@v3
if: ${{ github.event_name != 'pull_request' }}
with:
name: binaries
path: |
android/clientlib/build/outputs/aar/*.aar
android/clientlib-ktx/build/outputs/aar/*.aar
android/common/build/outputs/aar/*.aar
android/fakedapp/build/outputs/apk/**/*.apk
android/fakewallet/build/outputs/apk/**/*.apk
android/walletlib/build/outputs/aar/*.aar
if-no-files-found: error
retention-days: 5
# Upload javadoc to workflow artifacts
- uses: actions/upload-artifact@v3
if: ${{ github.event_name != 'pull_request' }}
with:
name: clientlib-javadoc
path: |
android/clientlib/build/docs/*
!android/clientlib/build/docs/**/*.zip
if-no-files-found: error
retention-days: 1
- uses: actions/upload-artifact@v3
if: ${{ github.event_name != 'pull_request' }}
with:
name: common-javadoc
path: |
android/common/build/docs/*
!android/common/build/docs/**/*.zip
if-no-files-found: error
retention-days: 1
- uses: actions/upload-artifact@v3
if: ${{ github.event_name != 'pull_request' }}
with:
name: walletlib-javadoc
path: |
android/walletlib/build/docs/*
!android/walletlib/build/docs/**/*.zip
if-no-files-found: error
retention-days: 1
# Publish to Maven Central (only for releases that start with 'v')
- name: Publish to Maven Central (release only)
if: ${{ github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v') }}
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PASSWORD }}
TAG: ${{ github.event.release.tag_name }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -P version=${TAG:1}
test:
runs-on: macos-latest
needs: build
strategy:
matrix:
api-level: [28]
steps:
# Setup
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
# Caching
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
target: google_apis
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
# Test
# Note: the fakedapp tests rely on fakewallet, so we always run the fakewallet
# tests first to ensure fakewallet is installed before the fakedapp tests
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
target: google_apis
force-avd-creation: false
emulator-options: -no-snapshot-save -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS
./gradlew :fakewallet:connectedDebugAndroidTest
./gradlew :fakedapp:connectedDebugAndroidTest
- name: Archive fakewallet test results
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: fakewallet-connected-test-results-${{ matrix.api-level }}
path: android/fakewallet/build/reports/androidTests/connected/
retention-days: 7
- name: Archive fakedapp test results
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: fakedapp-connected-test-results-${{ matrix.api-level }}
path: android/fakedapp/build/reports/androidTests/connected/
retention-days: 7
# Note: only runs on 'push' events
publish-to-gh-pages:
runs-on: ubuntu-latest
needs: build
concurrency: publish-to-gh-pages
if: ${{ github.event_name == 'push' }}
steps:
- name: Update clientlib javadoc
uses: solana-mobile/gha-commit-artifact-to-branch@v1
with:
token: ${{ secrets.UPDATE_GITHUB_PAGES_TOKEN }}
branch: gh-pages
artifact-name: clientlib-javadoc
dest: clientlib
commit-message: 'Update clientlib javadoc'
- name: Update common javadoc
uses: solana-mobile/gha-commit-artifact-to-branch@v1
with:
token: ${{ secrets.UPDATE_GITHUB_PAGES_TOKEN }}
branch: gh-pages
artifact-name: common-javadoc
dest: common
commit-message: 'Update common javadoc'
- name: Update walletlib javadoc
uses: solana-mobile/gha-commit-artifact-to-branch@v1
with:
token: ${{ secrets.UPDATE_GITHUB_PAGES_TOKEN }}
branch: gh-pages
artifact-name: walletlib-javadoc
dest: walletlib
commit-message: 'Update walletlib javadoc'
# Note: only runs on 'release' events
upload-to-release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write # needed for uploading files to releases
if: ${{ github.event_name == 'release' }}
steps:
- uses: actions/download-artifact@v3
with:
name: binaries
path: binaries
- uses: actions/download-artifact@v3
with:
name: clientlib-javadoc
path: clientlib-javadoc
- uses: actions/download-artifact@v3
with:
name: common-javadoc
path: common-javadoc
- uses: actions/download-artifact@v3
with:
name: walletlib-javadoc
path: walletlib-javadoc
- name: Compress clientlib javadoc
run: tar -cvzf clientlib-javadoc/clientlib-javadoc.tgz -C clientlib-javadoc javadoc
- name: Compress common javadoc
run: tar -cvzf common-javadoc/common-javadoc.tgz -C common-javadoc javadoc
- name: Compress walletlib javadoc
run: tar -cvzf walletlib-javadoc/walletlib-javadoc.tgz -C walletlib-javadoc javadoc
- name: Upload files to release
run: find ${FILES} -type f -exec gh release -R ${GITHUB_REPOSITORY} upload ${TAG} {} +
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.release.tag_name }}
FILES: |
binaries/
clientlib-javadoc/clientlib-javadoc.tgz
common-javadoc/common-javadoc.tgz
walletlib-javadoc/walletlib-javadoc.tgz