-
Notifications
You must be signed in to change notification settings - Fork 34
226 lines (190 loc) · 8.25 KB
/
build.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
# Copyright (c) 2021 Armel Soro
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: CI
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 15
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 15
- uses: actions/cache@v4
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: "Set environmental variables"
run: |
echo "KEYSTORE=$(pwd)/debug.keystore" >> $GITHUB_ENV
- name: Prepare scripts
run: chmod +x gradlew
- name: Prepare local.properties
env:
MAONI_GITHUB_USERNAME: ${{ secrets.MAONI_GITHUB_USERNAME }}
MAONI_GITHUB_PASSWORD_TOKEN: ${{ secrets.MAONI_GITHUB_PASSWORD_TOKEN }}
MAONI_JIRA_REST_BASEURL: ${{ secrets.MAONI_JIRA_REST_BASEURL }}
MAONI_JIRA_USERNAME: ${{ secrets.MAONI_JIRA_USERNAME }}
MAONI_JIRA_PASSWORD: ${{ secrets.MAONI_JIRA_PASSWORD }}
run: |
echo "github.username=${MAONI_GITHUB_USERNAME}" > local.properties
echo "github.passwordToken=${MAONI_GITHUB_PASSWORD_TOKEN}" >> local.properties
echo "jira.rest.baseUrl=${MAONI_JIRA_REST_BASEURL}" >> local.properties
echo "jira.username=${MAONI_JIRA_USERNAME}" >> local.properties
echo "jira.password=${MAONI_JIRA_PASSWORD}" >> local.properties
- name: Prepare maoni-keystore.properties
env:
STORE_PASSWORD: 'android'
KEY_ALIAS: 'androiddebugkey'
KEY_PASSWORD: 'android'
run: |
mkdir -p ~/.droid
echo "keystore=${KEYSTORE}" > ~/.droid/maoni-keystore.properties
echo "storePassword=${STORE_PASSWORD}" >> ~/.droid/maoni-keystore.properties
echo "keyAlias=${KEY_ALIAS}" >> ~/.droid/maoni-keystore.properties
echo "keyPassword=${KEY_PASSWORD}" >> ~/.droid/maoni-keystore.properties
- name: Prepare PlayStore.keys.json
env:
PLAYSTORE_KEYS_JSON: ${{ secrets.PLAYSTORE_KEYS_JSON }}
run: |
mkdir -p ~/.droid
echo "${PLAYSTORE_KEYS_JSON}" > ~/.droid/PlayStore.keys.json
- name: Download dependencies
run: ./gradlew androidDependencies --stacktrace
- name: Run Tests
run: ./gradlew clean lintDebug testDebug --stacktrace
- name: Build APK
run: ./gradlew build assembleDebug --stacktrace
- name: Code Coverage
run: bash <(curl -s https://codecov.io/bash)
- name: Archive sample app artifacts
uses: actions/upload-artifact@v3
with:
name: maoni-sample_outputs
path: |
maoni-sample/build/outputs
- name: Archive build reports
uses: actions/upload-artifact@v3
with:
name: reports
path: |
**/build/reports
- name: Archive test results
uses: actions/upload-artifact@v3
with:
name: reports
path: |
**/build/test-results
publishLibraries:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 15
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 15
- uses: actions/cache@v4
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Base64 decodes and pipes the GPG key content into the secret file
- name: Prepare environment
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
run: |
git fetch --unshallow
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"
- name: "Set environmental variables"
run: |
echo "KEYSTORE=$(pwd)/debug.keystore" >> $GITHUB_ENV
- name: Prepare scripts
run: chmod +x gradlew
- name: Prepare local.properties
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
MAONI_GITHUB_USERNAME: ${{ secrets.MAONI_GITHUB_USERNAME }}
MAONI_GITHUB_PASSWORD_TOKEN: ${{ secrets.MAONI_GITHUB_PASSWORD_TOKEN }}
MAONI_JIRA_REST_BASEURL: ${{ secrets.MAONI_JIRA_REST_BASEURL }}
MAONI_JIRA_USERNAME: ${{ secrets.MAONI_JIRA_USERNAME }}
MAONI_JIRA_PASSWORD: ${{ secrets.MAONI_JIRA_PASSWORD }}
run: |
echo "signing.keyId=${SIGNING_KEY_ID}" > local.properties
echo "signing.password=${SIGNING_PASSWORD}" >> local.properties
echo "signing.secretKeyRingFile=${SIGNING_SECRET_KEY_RING_FILE}" >> local.properties
echo "ossrhUsername=${OSSRH_USERNAME}" >> local.properties
echo "ossrhPassword=${OSSRH_PASSWORD}" >> local.properties
echo "sonatypeStagingProfileId=${SONATYPE_STAGING_PROFILE_ID}" >> local.properties
echo "github.username=${MAONI_GITHUB_USERNAME}" >> local.properties
echo "github.passwordToken=${MAONI_GITHUB_PASSWORD_TOKEN}" >> local.properties
echo "jira.rest.baseUrl=${MAONI_JIRA_REST_BASEURL}" >> local.properties
echo "jira.username=${MAONI_JIRA_USERNAME}" >> local.properties
echo "jira.password=${MAONI_JIRA_PASSWORD}" >> local.properties
- name: Prepare maoni-keystore.properties
env:
STORE_PASSWORD: 'android'
KEY_ALIAS: 'androiddebugkey'
KEY_PASSWORD: 'android'
run: |
mkdir -p ~/.droid
echo "keystore=${KEYSTORE}" > ~/.droid/maoni-keystore.properties
echo "storePassword=${STORE_PASSWORD}" >> ~/.droid/maoni-keystore.properties
echo "keyAlias=${KEY_ALIAS}" >> ~/.droid/maoni-keystore.properties
echo "keyPassword=${KEY_PASSWORD}" >> ~/.droid/maoni-keystore.properties
- name: Prepare PlayStore.keys.json
env:
PLAYSTORE_KEYS_JSON: ${{ secrets.PLAYSTORE_KEYS_JSON }}
run: |
mkdir -p ~/.droid
echo "${PLAYSTORE_KEYS_JSON}" > ~/.droid/PlayStore.keys.json
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Generates artifacts
- name: Build other artifacts
run: ./gradlew build javadoc
# Runs upload, and then closes & releases the repository
- name: Publish to MavenCentral
run: ./gradlew publishToSonatype --max-workers 1 closeAndReleaseStagingRepository