This repository was archived by the owner on Oct 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (156 loc) · 6.13 KB
/
androidBuild.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
name: Android APK Build
on: push
env:
YARN_MODULES_CACHE_KEY: v1
YARN_PACKAGE_CACHE_KEY: v1
YARN_CACHE_FOLDER: .cache/yarn
FORCE_COLOR: true # display terminal colors
jobs:
install:
runs-on: ubuntu-latest
timeout-minutes: 10
if: "! contains(toJSON(github.event.head_commit.message), '[skip ci]')" # skip job if git message contains [skip ci]
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Install npm dependencies
run: yarn install
lint:
needs: install
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Lint project
run: yarn lint
test:
needs: install
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Test project
run: yarn test --maxWorkers=2 --ci --coverage
- name: Archive test results
uses: actions/upload-artifact@v1
with:
name: test-results
path: test-results/test-report.html
- name: Archive code coverage
uses: actions/upload-artifact@v1
with:
name: code-coverage
path: coverage/lcov-report/
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage/lcov.info
build:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Create properties file
run: |
printf 'RELEASE_KEY_STORE=%s\n' ${{ secrets.RELEASE_KEY_STORE }} >> android/release-keystore.properties
printf 'RELEASE_KEY_ALIAS_NAME=%s\n' '${{ secrets.RELEASE_KEY_ALIAS_NAME }}' >> android/release-keystore.properties
printf 'RELEASE_KEY_ALIAS_PASSWORD=%s\n' '${{ secrets.RELEASE_KEY_ALIAS_PASSWORD }}' >> android/release-keystore.properties
printf 'RELEASE_KEY_STORE_PASSWORD=%s\n' '${{ secrets.RELEASE_KEY_STORE_PASSWORD }}' >> android/release-keystore.properties
- name: Decode Android key
run: |
echo "${{ secrets.KEYSTORE }}" > keystore-base64
base64 -d -i keystore-base64 > android/app/release.keystore
- name: Cache Android dependencies
uses: actions/cache@v2
env:
cache-name: cache-android-dependencies
with:
path: |
~/.gradle/
~/.m2/
key: jars-{{ hashFiles('android/gradle/wrapper/gradle-wrapper.properties') }}-{{ hashFiles("android/build.gradle") }}-{{ hashFiles('android/app/build.gradle') }}
restore-keys: jars-{{ hashFiles('android/gradle/wrapper/gradle-wrapper.properties') }}-{{ hashFiles("android/build.gradle") }}-
- name: Download Android dependencies
run: |
cd android
./gradlew androidDependencies
cd ..
- name: Generate .ENV file
run: |
printf 'BUILD_VERSION=%s\n' $(echo ${{ github.sha }} | cut -c -7) >> .env
printf 'API_KEY=%s\n' '${{ secrets.API_KEY }}' >> .env
printf 'DEV_API_KEY=%s\n' '${{ secrets.DEV_API_KEY }}' >> .env
- name: Update semantic-version in package.json
# NOTE: this will run successfully on master branch. on any other branch it will use the current npm version
# run semantic-version in dry-run mode
# extract string that starts with "Release note"
# extract version number
# update version using "npm version"
run: |
yarn semantic-release -d | grep 'Release note' | grep -Po "(\d+)\.(\d+)\.(\d+)" | xargs npm version --allow-same-version --no-git-tag-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Android APK
run: yarn build:android:release
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: app-release.apk
path: android/app/build/outputs/apk/release/
release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-
- uses: actions/download-artifact@v2
with:
name: app-release.apk
path: android/app/build/outputs/apk/release/
- name: semantic-release
if: github.ref == 'refs/heads/master'
run: yarn semantic-release --dry-run ${{github.ref != 'refs/heads/master'}} --ci ${{github.ref == 'refs/heads/master'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}