-
Notifications
You must be signed in to change notification settings - Fork 166
200 lines (179 loc) · 6.86 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
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)"
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 }}
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:
labels: ["linux", "8cores"]
defaults:
run:
shell: bash
strategy:
matrix:
projectPath:
- nekoyume
targetPlatform:
- Android
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
- uses: game-ci/unity-builder@v2
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 }}
androidAppBundle: true
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 }}
- 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: 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/Nine Chronicles M.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/') || github.event.inputs.manual_build_option
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/')|| github.event.inputs.manual_build_option
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/Nine Chronicles M.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/[email protected]
with:
lane: 'android internal'