-
Notifications
You must be signed in to change notification settings - Fork 102
274 lines (245 loc) · 10 KB
/
auto-publish.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: 01 Auto publish packages (Release)
on:
push:
branches:
- 'release/release-v*'
jobs:
create_release:
needs: extract_version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Extract version number
id: extract_version
shell: bash
run: |
VERSION="${GITHUB_REF#refs/heads/release/release-}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Check if release tag exists
id: tag_exists
shell: bash
run: |
if git rev-parse "refs/tags/release-${{ env.VERSION }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_ENV
else
echo "exists=false" >> $GITHUB_ENV
fi
echo "env.exists=$(cat $GITHUB_ENV | grep exists | cut -d '=' -f2)"
- name: Read CHANGELOG.md
id: read_changelog
if: env.exists == 'false'
shell: bash
run: |
CHANGELOG=$(cat CHANGELOG.md | base64)
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV
- name: Create GitHub Release
id: create_release
if: env.exists == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: release-${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
body: $(echo ${{ env.CHANGELOG }} | base64 --decode)
- name: Save assets upload URL
if: env.exists == 'false'
shell: bash
run: echo "UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_ENV
upload_assets:
needs: create_release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
platform: [ windows, linux, macos, android ]
build_type: [ minsizerel ]
arch: [ x86_64, aarch64, arm64, x86, arm64-v8a, armeabi-v7a ]
include:
- os: windows-latest
platform: windows # Platform: Windows (keep: x86_64, x86, arm64)
c_compiler: cl
cpp_compiler: cl
- os: macos-latest
platform: macos # Platform: MacOS (keep: x86_64, arm64)
c_compiler: clang
cpp_compiler: clang++
- os: ubuntu-latest
platform: linux # Platform: Linux (keep: x86_64, aarch64)
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
platform: android # Platform: Android (keep: x86_64, x86, arm64-v8a, armeabi-v7a)
c_compiler: clang
cpp_compiler: clang++
exclude:
# Linux (keep: x86_64, aarch64)
- platform: linux
arch: arm64-v8a
- platform: linux
arch: armeabi-v7a
- platform: linux
arch: x86
- platform: linux
arch: arm64
# macOS (keep: x86_64, arm64)
- platform: macos
arch: arm64-v8a
- platform: macos
arch: armeabi-v7a
- platform: macos
arch: x86
- platform: macos
arch: aarch64
# Windows (keep: x86_64, x86, arm64)
- platform: windows
arch: arm64-v8a
- platform: windows
arch: armeabi-v7a
- platform: windows
arch: aarch64
# Android (keep: x86_64, x86, arm64-v8a, armeabi-v7a)
- platform: android
arch: aarch64
- platform: android
arch: arm64
# Exclude unsupported compiler combinations
- os: windows-latest
platform: linux
- os: windows-latest
platform: macos
- os: windows-latest
platform: android
- os: ubuntu-latest
platform: windows
- os: ubuntu-latest
platform: macos
- os: macos-latest
platform: windows
- os: macos-latest
platform: linux
- os: macos-latest
platform: android
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Extract version from branch name
id: extract_version
shell: bash
run: |
VERSION="${GITHUB_REF#refs/heads/release/release-}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build zip tar
sudo apt-get install -y gcc g++ gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install cmake ninja zip
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install cmake ninja zip
- name: Set up Android SDK and NDK
if: matrix.platform == 'android'
uses: android-actions/setup-android@v2
with:
api-level: 27
ndk-version: 26.1.10909125
cmake-version: 3.29.5
- name: Build project (Linux, macOS, Windows)
if: matrix.platform != 'android'
run: |
bash ./auto_build.sh --platform ${{ matrix.platform }} \
--build-type ${{ matrix.build_type }} \
--arch-abi ${{ matrix.arch }} \
-c
- name: Build project (Android)
if: matrix.platform == 'android'
run: |
bash ./auto_build.sh --platform android \
--cmake "cmake" \
--ninja "ninja" \
--build-type ${{ matrix.build_type }} \
--arch-abi ${{ matrix.arch }} \
--jobs 4 \
--android-ndk "$ANDROID_NDK_HOME" \
--android-ver 27 \
-c
- name: Create release directory
run: |
mkdir -p release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}
- name: Copy files to release directory
run: |
cp -r include release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
cp -r cmake-build-${{ matrix.build_type }}-${{ matrix.platform }}-${{ matrix.arch }}/bin release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
cp -r cmake-build-${{ matrix.build_type }}-${{ matrix.platform }}-${{ matrix.arch }}/lib release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
cp CHANGELOG.md release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
cp README.md release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
cp LICENSE release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
- name: Create zip archive (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
tar -czvf release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}
- name: Create zip archive (macOS)
if: matrix.os == 'macos-latest'
run: |
tar -czvf release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}
- name: Create zip archive (Windows)
if: matrix.os == 'windows-latest'
run: |
zip -r release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.zip release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}
- name: Create zip archive (Android)
if: matrix.platform == 'android'
run: |
zip -r release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.zip release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}
- name: Upload release asset (Linux)
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz
asset_name: release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz
asset_content_type: application/gzip
- name: Upload release asset (macOS)
if: matrix.os == 'macos-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz
asset_name: release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz
asset_content_type: application/gzip
- name: Upload release asset (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.zip
asset_name: release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.zip
asset_content_type: application/zip
- name: Upload release asset (Android)
if: matrix.platform == 'android'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.zip
asset_name: release-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.zip
asset_content_type: application/zip