-
Notifications
You must be signed in to change notification settings - Fork 2
224 lines (206 loc) · 9.21 KB
/
custom-build.yml
File metadata and controls
224 lines (206 loc) · 9.21 KB
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
name: custom-build
on:
workflow_call:
inputs:
branch:
type: string
description: 'Branch to build'
required: true
build_version:
type: string
description: 'Version to build, e.g. 1.0.0'
required: true
build_type:
type: string
description: 'Build type, e.g. Release, Debug'
required: true
upload_artifacts:
type: boolean
description: 'Upload artifacts, e.g. true, false'
required: true
workflow_dispatch:
inputs:
branch:
type: string
description: 'Branch to build'
required: true
default: 'main'
build_version:
type: string
description: 'Version to build, e.g. 1.0.0'
required: true
default: '1.0.0'
build_type:
type: choice
description: 'Build type, e.g. Release, Debug'
required: true
default: 'Release'
options:
- 'Release'
- 'Debug'
upload_artifacts:
type: boolean
description: 'Upload artifacts, e.g. true, false'
required: true
default: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
target_platform: [android, linux, windows, macos, ios, xros]
include:
- os: ubuntu-latest
target_platform: android
- os: ubuntu-latest
target_platform: linux
- os: windows-latest
target_platform: windows
- os: macos-latest
target_platform: macos
- os: macos-latest
target_platform: ios
- os: macos-latest
target_platform: xros
exclude:
- os: ubuntu-latest
target_platform: windows
- os: ubuntu-latest
target_platform: macos
- os: ubuntu-latest
target_platform: ios
- os: ubuntu-latest
target_platform: xros
- os: windows-latest
target_platform: android
- os: windows-latest
target_platform: linux
- os: windows-latest
target_platform: macos
- os: windows-latest
target_platform: ios
- os: windows-latest
target_platform: xros
- os: macos-latest
target_platform: android
- os: macos-latest
target_platform: linux
- os: macos-latest
target_platform: windows
outputs:
nightly_link_url_android: "https://nightly.link/opentraa/traa/actions/runs/${{ github.run_id }}/android-${{inputs.build_version}}-${{ github.run_id }}-${{ steps.strings.outputs.timestamp}}.zip"
nightly_link_url_linux: "https://nightly.link/opentraa/traa/actions/runs/${{ github.run_id }}/linux-${{inputs.build_version}}-${{ github.run_id }}-${{ steps.strings.outputs.timestamp}}.zip"
nightly_link_url_windows: "https://nightly.link/opentraa/traa/actions/runs/${{ github.run_id }}/windows-${{inputs.build_version}}-${{ github.run_id }}-${{ steps.strings.outputs.timestamp}}.zip"
nightly_link_url_macos: "https://nightly.link/opentraa/traa/actions/runs/${{ github.run_id }}/macos-${{inputs.build_version}}-${{ github.run_id }}-${{ steps.strings.outputs.timestamp}}.zip"
nightly_link_url_ios: "https://nightly.link/opentraa/traa/actions/runs/${{ github.run_id }}/ios-${{inputs.build_version}}-${{ github.run_id }}-${{ steps.strings.outputs.timestamp}}.zip"
nightly_link_url_xros: "https://nightly.link/opentraa/traa/actions/runs/${{ github.run_id }}/xros-${{inputs.build_version}}-${{ github.run_id }}-${{ steps.strings.outputs.timestamp}}.zip"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '1'
lfs: 'true'
submodules: 'true'
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
echo "build-output-dir=${{ github.workspace }}/bin" >> "$GITHUB_OUTPUT"
echo "timestamp=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
echo "build-id=${{ github.run_id }}" >> "$GITHUB_OUTPUT"
# The part of the most complex build script for android
# 1. Set up Java
# 2. Set up Android SDK
# 3. Build for android
- uses: actions/setup-java@v4
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target_platform == 'android' }}
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'
cache-dependency-path: |
projects/android/.gradle
- uses: android-actions/setup-android@v3
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target_platform == 'android' }}
- uses: nttld/setup-ndk@v1.5.0
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target_platform == 'android' }}
with:
ndk-version: r21e
local-cache: true
- name: Build for android
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target_platform == 'android' }}
shell: bash
run: >
bash scripts/build.sh -p ${{ matrix.target_platform }}
-v ${{ inputs.build_version }}
-t ${{ inputs.build_type }}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}
-A "arm64-v8a,x86,x86_64,armeabi-v7a"
- name: Build for linux
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target_platform == 'linux' }}
shell: bash
run: >
bash scripts/build.sh -p ${{ matrix.target_platform }}
-v ${{ inputs.build_version }}
-t ${{ inputs.build_type }}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}
- name: Build for windows x64
if: ${{ matrix.os == 'windows-latest' && matrix.target_platform == 'windows' }}
run: >
scripts/build.bat -a x64
-v ${{ inputs.build_version }}
-t ${{ inputs.build_type }}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}
- name: Build for windows Win32
if: ${{ matrix.os == 'windows-latest' && matrix.target_platform == 'windows' }}
run: >
scripts/build.bat -a Win32
-v ${{ inputs.build_version }}
-t ${{ inputs.build_type }}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}
- name: Build for macOS iOS and xrOS
if: ${{ matrix.os == 'macos-latest' && (matrix.target_platform == 'macos' || matrix.target_platform == 'ios' || matrix.target_platform == 'xros') }}
run: >
sh scripts/build.sh -p ${{ matrix.target_platform }}
-v ${{ inputs.build_version }}
-t ${{ inputs.build_type }}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs
# There is no need to sign frameworks
# - name: Sign macOS iOS and xrOS
# if: ${{ matrix.os == 'macos-latest' && (matrix.target_platform == 'macos' || matrix.target_platform == 'ios' || matrix.target_platform == 'xros') }}
# env:
# BUILD_CERTIFICATE_BASE64: ${{ secrets.DIST_BUILD_CERTIFICATE_BASE64 }}
# BUILD_CERTIFICATE_NAME: ${{ secrets.DIST_BUILD_CERTIFICATE_NAME }}
# P12_PASSWORD: ${{ secrets.DIST_P12_PASSWORD }}
# KEYCHAIN_PASSWORD: ${{ secrets.DIST_KEYCHAIN_PASSWORD }}
# run: |
# CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
# KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# # import certificate and provisioning profile from secrets
# echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# # create temporary keychain
# security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
# security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# # import certificate to keychain
# security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
# security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# security list-keychain -d user -s $KEYCHAIN_PATH
# # sign every framework in the build output directory with command:
# find ${{ steps.strings.outputs.build-output-dir }} -name "*.framework" -exec codesign --force --deep --sign "$BUILD_CERTIFICATE_NAME" --options runtime --timestamp --verbose=2 {} \;
- name: Upload artifacts
if: ${{ inputs.upload_artifacts == true }}
# https://github.com/actions/upload-artifact/issues/93 the official version do not support to keep the symbolic link for now
uses: eXhumer/upload-artifact@0b7d5f5684d3f642f978d2faad9ade64f5b4dd57
with:
name: ${{ matrix.target_platform }}-${{ inputs.build_version }}-${{ steps.strings.outputs.build-id }}-${{ steps.strings.outputs.timestamp }}
path: ${{ steps.strings.outputs.build-output-dir }}
follow-symlinks: false
if-no-files-found: error