-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (147 loc) · 6.53 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
name: Build Android
on:
workflow_dispatch:
inputs:
checkoutRef:
description: "Tag or SHA ref to checkout"
required: false
default: ""
release:
types:
- published
env:
node-version: "12"
java-version: "1.8"
UPLOAD_TO_RELEASE: ${{ secrets.UPLOAD_TO_RELEASE }}
UPLOAD_TO_GOOGLE: ${{ secrets.UPLOAD_TO_GOOGLE }}
jobs:
release:
name: Build
runs-on: ubuntu-20.04
steps:
- name: Checkout the repo
uses: actions/checkout@v2
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
with:
persist-credentials: false
ref: ${{ github.event.inputs.checkoutRef }}
- name: Increase watchers to fix Docker
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Set up JDK
uses: actions/setup-java@v1
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
with:
java-version: ${{ env.java-version }}
- name: Make Gradle executable
run: chmod +x ./gradlew
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
working-directory: ./android
- name: Cache Gradle
uses: actions/cache@v2
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Set up Node
uses: actions/setup-node@v2
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
with:
node-version: ${{ env.node-version }}
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
- name: Cache Yarn dependencies
uses: actions/cache@v2
id: yarn-cache
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
uses: nick-invision/retry@v2
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
with:
timeout_minutes: 10
max_attempts: 5
retry_on: error
command: yarn install --prefer-offline --frozen-lockfile --silent
- name: Get version
id: get-version
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
run: echo ::set-output name=version::$(node -p "'v'+require('./package.json').version")
- name: Display version
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
run: echo ${{ steps.get-version.outputs.version }}
- name: Get prerelease
id: get-prerelease
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
run: echo ::set-output name=is-prerelease::$(node -p "!!require('semver/functions/prerelease')('${{ steps.get-version.outputs.version }}')")
- name: Display prerelease
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
run: echo ${{ steps.get-prerelease.outputs.is-prerelease }}
- name: Decrypt dotenv for staging or production
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
run: |
[[ -z "$DOTENV" ]] && exit 0
echo "$DOTENV" | base64 --decode > ./.env
chmod 600 ./.env
env:
DOTENV: ${{ (steps.get-prerelease.outputs.is-prerelease == 'true' && secrets.DOTENV_STAGING) || secrets.DOTENV_PROD }}
- name: Decrypt release keystore
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
run: |
echo "$RELEASE_JKS" | base64 --decode > ./android/app/release.jks
chmod 600 ./android/app/release.jks
env:
RELEASE_JKS: ${{ secrets.RELEASE_JKS }}
- name: Decrypt google services
if: env.UPLOAD_TO_RELEASE == 'true' || env.UPLOAD_TO_GOOGLE == 'true'
run: |
[[ -z "$GOOGLE_SERVICES" ]] && exit 0
echo "$GOOGLE_SERVICES" | base64 --decode > ./android/app/google-services.json
chmod 600 ./android/app/google-services.json
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
- name: Decrypt google play service account
if: env.UPLOAD_TO_GOOGLE == 'true'
run: |
[[ -z "$GOOGLE_PLAY_SERVICE_ACCOUNT" ]] && exit 0
echo "$GOOGLE_PLAY_SERVICE_ACCOUNT" | base64 --decode > ./google-play-service-account.json
chmod 600 ./google-play-service-account.json
env:
GOOGLE_PLAY_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT }}
- name: Generate APK
if: env.UPLOAD_TO_RELEASE == 'true'
run: ./gradlew assembleRelease --no-daemon
working-directory: ./android
env:
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
- name: Upload APK to Release tagged with current version
uses: AButler/[email protected]
if: env.UPLOAD_TO_RELEASE == 'true'
with:
files: "./android/app/build/outputs/apk/release/*.apk"
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ steps.get-version.outputs.VERSION }}
- name: Generate AAB
if: env.UPLOAD_TO_GOOGLE == 'true'
run: ./gradlew bundleRelease --no-daemon
working-directory: ./android
env:
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
- name: Upload AAB to Google Play
uses: DiogoAbu/upload-google-play@053164334a899567ff29ea0e7201f215017e91b4
if: env.UPLOAD_TO_GOOGLE == 'true'
with:
packageName: com.diogoabu.pokedex
releaseFiles: ./android/app/build/outputs/bundle/release/*.aab
mappingFile: ./android/app/build/outputs/mapping/release/mapping.txt
serviceAccountJson: ./google-play-service-account.json
track: ${{ (steps.get-prerelease.outputs.is-prerelease == 'true' && 'alpha') || 'production' }}