-
Notifications
You must be signed in to change notification settings - Fork 1.3k
215 lines (213 loc) · 7.71 KB
/
build-nekoray-cmake.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
name: Nekoray build matrix - cmake
on:
workflow_dispatch:
inputs:
tag:
description: 'Release Tag'
required: true
publish:
description: 'Publish: If want ignore'
required: false
artifact-pack:
description: 'artifact-pack: If want ignore'
required: false
jobs:
build-go:
strategy:
matrix:
cross_os: [ windows, linux ]
cross_arch: [ amd64 ]
include:
- cross_os: public_res
cross_arch: public_res
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checking out sources
uses: actions/checkout@v3
- name: Go Status
run: git ls-files go | xargs cat | sha1sum > go_status
- name: Cache Common Download
id: cache-common
uses: actions/cache@v3
with:
path: artifacts.tgz
key: CommonCache-${{ matrix.cross_os }}-${{ matrix.cross_arch }}-${{ hashFiles('libs/*.sh', 'go_status', '*.txt') }}
- name: Install Golang
if: steps.cache-common.outputs.cache-hit != 'true'
uses: actions/setup-go@v3
with:
go-version: ^1.21
- name: Build golang parts
if: steps.cache-common.outputs.cache-hit != 'true'
shell: bash
run: |
[ ${{ matrix.cross_os }} == public_res ] || ./libs/get_source.sh
[ ${{ matrix.cross_os }} == public_res ] || GOOS=${{ matrix.cross_os }} GOARCH=${{ matrix.cross_arch }} ./libs/build_go.sh
[ ${{ matrix.cross_os }} == public_res ] || exit 0
./libs/build_public_res.sh
- name: Tar files
if: steps.cache-common.outputs.cache-hit != 'true'
run: tar czvf artifacts.tgz ./deployment
- name: Uploading Artifact
uses: actions/upload-artifact@v3
with:
name: NekoRay-${{ github.sha }}-Common-${{ matrix.cross_os }}-${{ matrix.cross_arch }}
path: artifacts.tgz
build-cpp:
strategy:
matrix:
include:
- platform: windows-2022
arch: x64
qt_version: "6.5"
- platform: ubuntu-20.04
arch: x64
qt_version: "5.12"
fail-fast: false
runs-on: ${{ matrix.platform }}
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- name: Checking out sources
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Install MSVC compiler
if: matrix.platform == 'windows-2022'
uses: ilammy/msvc-dev-cmd@v1
with:
# 14.1 is for vs2017, 14.2 is vs2019, following the upstream vcpkg build from Qv2ray-deps repo
toolset: 14.2
arch: ${{ matrix.arch }}
# ========================================================================================================= Qt Install
- name: Windows - Download Custom Qt ${{ matrix.qt_version }} SDK
shell: bash
if: matrix.platform == 'windows-2022'
env:
DL_QT_VER: ${{ matrix.qt_version }}
run: bash ./libs/download_qtsdk_win.sh
# ========================================================================================================= 编译与 Qt 无关的依赖
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v3
- name: Cache Download
id: cache-deps
uses: actions/cache@v3
with:
path: libs/deps
key: DepsCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ hashFiles('libs/build_deps_*.sh') }}-Qt${{ matrix.qt_version }}
- name: Build Dependencies
shell: bash
if: steps.cache-deps.outputs.cache-hit != 'true' && matrix.platform != 'ubuntu-20.04'
run: ./libs/build_deps_all.sh
- name: Build Dependencies (Docker)
shell: bash
if: steps.cache-deps.outputs.cache-hit != 'true' && matrix.platform == 'ubuntu-20.04'
run: |
docker run --rm \
-v $PWD:/nekoray \
-w /nekoray \
ghcr.io/matsuridayo/debian10-qt5:20230131 \
bash -c "./libs/build_deps_all.sh"
# ========================================================================================================= Generate MakeFile and Build
- name: Windows - Generate MakeFile and Build
shell: bash
if: matrix.platform == 'windows-2022'
env:
DL_QT_VER: ${{ matrix.qt_version }}
CC: cl.exe
CXX: cl.exe
run: |
source libs/env_qtsdk.sh $PWD/qtsdk/Qt
mkdir build
cd build
cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_BUILD_TYPE=Release ..
ninja -j2
cd ..
./libs/deploy_windows64.sh
- name: Linux - Generate MakeFile and Build
shell: bash
if: matrix.platform == 'ubuntu-20.04'
run: |
docker run --rm \
-v $PWD:/nekoray \
-w /nekoray \
ghcr.io/matsuridayo/debian10-qt5:20230131 \
bash -c "mkdir build && pushd build && cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. && ninja && popd &&./libs/deploy_linux64.sh"
# ========================================================================================================= Deployments
- name: Tar files
shell: bash
run: tar czvf artifacts.tgz ./deployment
- name: Uploading Artifact
uses: actions/upload-artifact@v3
with:
name: NekoRay-${{ github.sha }}-${{ matrix.platform }}-${{ matrix.arch }}-Qt${{ matrix.qt_version }}
path: artifacts.tgz
publish:
name: Pack & Publish Release
if: github.event.inputs.artifact-pack != 'y'
runs-on: ubuntu-latest
needs:
- build-cpp
- build-go
steps:
- name: Checking out sources
uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: download-artifact
- name: Pack
run: |
curl -Lo - https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz | tar xzv
mv ghr*linux_amd64/ghr .
####
source libs/env_deploy.sh
find . -name artifacts.tgz | xargs -n1 tar xvzf
cd deployment
cp -r public_res/* linux64
cp -r public_res/* windows64
rm -rf public_res *.pdb
####
mv linux64 nekoray
zip -r $version_standalone-linux64.zip nekoray
rm -rf nekoray
####
mv windows64 nekoray
zip -r $version_standalone-windows64.zip nekoray
rm -rf nekoray
- name: Pack Debian
run: |
source libs/env_deploy.sh
find . -name artifacts.tgz | xargs -n1 tar xvzf
cd deployment
cp -r public_res/* linux64
####
bash ../libs/package_debian.sh ${{ github.event.inputs.tag }}
mv nekoray.deb $version_standalone-debian-x64.deb
sudo rm -rf nekoray
- name: Pack AppImage
run: |
source libs/env_deploy.sh
find . -name artifacts.tgz | xargs -n1 tar xvzf
cd deployment
cp -r public_res/* linux64
####
bash ../libs/package_appimage.sh
mv nekoray-x86_64.AppImage $version_standalone-linux-x64.AppImage
- name: Clean Up
run: |
cd deployment
rm -rf linux64
rm -rf windows64
rm -rf public_res
rm -rf *.pdb
- name: Uploading Artifact
uses: actions/upload-artifact@v3
with:
name: Deployment-${{ github.sha }}
path: deployment
- name: Release
if: github.event.inputs.publish != 'y'
run: |
./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" deployment