-
Notifications
You must be signed in to change notification settings - Fork 157
249 lines (225 loc) · 8.92 KB
/
android-build-and-release.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 Build and Release
on:
push:
branches:
- main
- development
- release/*
- fast-track/*
tags: ["*"]
pull_request:
types: [ready_for_review, opened, reopened, auto_merge_enabled]
workflow_dispatch:
inputs:
clo:
description: "Assets/StreamingAssets/clo.json"
required: false
type: string
default: ""
version-code:
description: "Google Play Console VersionCode"
app-version:
description: "Google Play Console VersionName ex(40.0.0)"
package-name:
description: "package name ex(com.planetariumlabs.ninechroniclesmobile)"
required: false
type: string
default: "com.planetariumlabs.ninechroniclesmobile"
cloud-project-id:
description: "cloud project id ex(abcd-1234-xyz0)"
required: false
type: string
default: ""
player-name:
description: "player name ex(Nine-Chronicles-M -> Nine Chronicles M)"
required: false
type: string
default: "Nine-Chronicles-M"
other-google-services:
description: "Please turn on the option when build other package"
required: false
type: boolean
default: false
manual_build_option:
description: "Please turn on the option when manually executing the action"
type: boolean
required: false
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.inputs.player-name }}
cancel-in-progress: true
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
jobs:
build:
name: Build for ${{ matrix.targetPlatform }}
runs-on:
group: linux-8cores
defaults:
run:
shell: bash
strategy:
matrix:
projectPath:
- nekoyume
targetPlatform:
- Android
environment: |-
${{ github.event.inputs.other-google-services == 'true' && 'k'
|| github.ref_name == 'main' && 'main'
|| startsWith(github.ref_name, 'release/') == 'true' && 'internal'
|| '' }}
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
steps:
- name: Set CRLF
run: |
git config --global core.autocrlf true
- uses: actions/checkout@v3
with:
lfs: true
submodules: true
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-ubuntu-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.projectPath }}-ubuntu-
Library-
- name: Copy clo.json
run: |
if [ -n "${{ github.event.inputs.clo }}" ]; then
echo ${{ github.event.inputs.clo }} > ${{ matrix.projectPath }}/Assets/StreamingAssets/clo.json
fi
- name: Decode google-services.json File
run: |
echo "$GOOGLE_SERVICES_JSON" | base64 -d > ${{ matrix.projectPath }}/Assets/NineChronicles/GoogleServices/google-services.json
- name: Resolve AAR files
run: |
if [ '${{ github.event.inputs.other-google-services }}' == 'true' ]; then
sudo \cp -R ${{ matrix.projectPath }}/ResolvedAAR/. ${{ matrix.projectPath }}/Assets/Plugins/Android/
fi
- name: Change cloudProjectId in ProjectSettings.asset
run: |
if [ -n "${{ github.event.inputs.cloud-project-id }}" ]; then
sed -i '/cloudProjectId/c\ cloudProjectId: ${{ github.event.inputs.cloud-project-id }}' ${{ matrix.projectPath }}/ProjectSettings/ProjectSettings.asset
cat ${{ matrix.projectPath }}/ProjectSettings/ProjectSettings.asset
fi
- uses: game-ci/unity-builder@v4
with:
androidKeystoreName: 9c-aos-signing-keystore.keystore # This file won't exist, but this property needs to exist.
androidKeystoreBase64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
androidKeyaliasName: ${{ secrets.ANDROID_KEY_ALIAS_NAME }}
androidKeyaliasPass: ${{ secrets.ANDROID_KEY_ALIAS_PASS }}
androidExportType: 'androidAppBundle'
projectPath: ${{ matrix.projectPath }}
targetPlatform: ${{ matrix.targetPlatform }}
buildMethod: 'Editor.Builder.Build${{ matrix.targetPlatform }}'
buildName: ${{ matrix.targetPlatform }}
androidVersionCode: ${{ github.event.inputs.version-code }}
version: ${{ github.event.inputs.app-version }}
androidTargetSdkVersion: AndroidApiLevel34
customParameters: -identifier ${{ github.event.inputs.package-name }} -playerName ${{ github.event.inputs.player-name }}
allowDirtyBuild: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11.0
- name: Install bundletool
run: |
tr -d "\r" < .github/bin/install-bundletool.sh > .github/bin/install-bundletool-trimed.sh
bash .github/bin/install-bundletool-trimed.sh /tmp
- name: Setup Keystore and Passwords
run: |
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > /tmp/9c-signing-keystore.keystore
echo "${{ secrets.ANDROID_KEYSTORE_PASS }}" > /tmp/keystore.pwd
echo "${{ secrets.ANDROID_KEY_ALIAS_NAME }}" > /tmp/keyalias.name
echo "${{ secrets.ANDROID_KEY_ALIAS_PASS }}" > /tmp/keyalias.pwd
- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
- name: Print file content
run: ls -R $GITHUB_WORKSPACE/build
- name: Move Folder
run: |
sudo mv $GITHUB_WORKSPACE/build /tmp/player
- name: Convert AAB to APKS
run: |
sudo java -jar /tmp/bundletool-all-*.jar build-apks --bundle="/tmp/player/Android/android-build.aab" --output="/tmp/player/Android/result.apks" --ks="/tmp/9c-signing-keystore.keystore" --ks-pass=file:/tmp/keystore.pwd --ks-key-alias=$(cat /tmp/keyalias.name) --key-pass=file:/tmp/keyalias.pwd --mode=universal --local-testing
- name: Pack
run: |
targetPlatform=${{ matrix.targetPlatform }}
tr -d "\r" < .github/bin/pack.sh > .github/bin/pack_trimed.sh
rm .github/bin/pack.sh
mv .github/bin/pack_trimed.sh .github/bin/pack.sh
pip3 install wheel
sudo bash .github/bin/pack.sh \
/tmp/packages \
"${{ matrix.targetPlatform }}" \
"/tmp/player"
- uses: actions/upload-artifact@v3
with:
name: Build-${{ matrix.targetPlatform }}
path: /tmp/packages
retention-days: 7
if-no-files-found: error
extract:
if: startsWith(github.ref, 'refs/heads/release/') || startsWith(github.event.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
outputs:
network: ${{ steps.extract.outputs.network }}
steps:
- uses: actions/checkout@v3
- name: extract
id: extract
run: |
if [[ "${{ startsWith(github.ref, 'refs/heads/release/') }}" == "true" || "${{ github.event.inputs.manual_build_option }}" == "true" ]]; then
echo "::set-output name=network::internal"
elif [[ "${{ startsWith(github.event.ref, 'refs/tags/') }}" == "true" ]]; then
echo "::set-output name=network::main"
else
echo "::set-output name=network::null"
fi
release-to-google-play:
if: startsWith(github.ref, 'refs/heads/release/') || startsWith(github.event.ref, 'refs/tags/')
name: Release to the Google Play Store
runs-on: ubuntu-latest
needs: ["extract"]
environment:
name: ${{ needs.extract.outputs.network }}
env:
GOOGLE_PLAY_KEY_FILE: ${{ secrets.GOOGLE_PLAY_KEY_FILE }}
GOOGLE_PLAY_KEY_FILE_PATH:
${{ format('{0}/fastlane/google-fastlane.json', github.workspace) }}
ANDROID_BUILD_FILE_PATH: ${{ format('{0}/build/Android/android-build.aab', github.workspace) }}
ANDROID_PACKAGE_NAME: ${{ secrets.ANDROID_PACKAGE_NAME }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download Android Artifact
uses: actions/download-artifact@v3
with:
name: Build-Android
path: build
- name: unzip artifact for deployment
run: |
mkdir -p build/Android
unzip build/Android.zip -d build/Android
- name: Add Authentication
run: |
echo ${{secrets.GOOGLE_PLAY_KEY_FILE}} | base64 -d > ${{ env.GOOGLE_PLAY_KEY_FILE_PATH }}
- name: Set up Fastlane
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Upload to Google Play Internal
uses: maierj/fastlane-action@v3.0.0
with:
lane: 'android internal'