-
Notifications
You must be signed in to change notification settings - Fork 453
278 lines (249 loc) · 9.98 KB
/
build-windows.yaml
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
275
276
277
278
name: Build Windows
on:
workflow_dispatch:
release:
pull_request:
branches:
- master
paths-ignore:
- 'docs/**'
- '**.md'
push:
branches:
- master
- release-*
paths-ignore:
- 'docs/**'
- '**.md'
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
GO_VERSION: ''
GOSEC_VERSION: '2.20.0'
jobs:
filter:
name: Path Filter
runs-on: ubuntu-24.04
outputs:
build-ovs-ovn: ${{ steps.filter.outputs.windows-ovs-ovn }}
build-kube-ovn: ${{ steps.filter.outputs.windows-kube-ovn }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION || '' }}
go-version-file: go.mod
check-latest: true
cache: false
- name: Generate path filter
env:
GOOS: windows
run: |
filter=".github/path-filters.yaml"
workflow=$(echo ${{ github.workflow_ref }} | awk -F@ '{print $1}' | sed 's@^${{ github.repository }}/@@')
cat > $filter <<EOF
windows-ovs-ovn:
- $workflow
windows-kube-ovn:
- $workflow
- go.mod
- go.sum
EOF
sh hack/go-list.sh cmd/cni | while read f; do
echo "- $f" | tee -a $filter
done
sh hack/go-list.sh cmd/windows | while read f; do
echo "- $f" | tee -a $filter
done
- uses: dorny/paths-filter@v3
id: filter
with:
base: ${{ github.base_ref || github.ref_name }}
filters: .github/path-filters.yaml
list-files: csv
build-ovs-and-ovn:
name: Build OVS and OVN
needs: filter
runs-on: windows-2019
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || needs.filter.outputs.build-ovs-ovn == 'true'
steps:
- name: Check out PTHREADS4W
run: |
New-Item -ItemType directory -Path pthreads4w
git clone https://git.code.sf.net/p/pthreads4w/code pthreads4w\code
- name: Check out OVS
uses: actions/checkout@v4
with:
repository: openvswitch/ovs
ref: branch-3.3
path: ovs
- name: Check out OVN
uses: actions/checkout@v4
with:
repository: ovn-org/ovn
ref: branch-24.03
path: ovn
- name: Apply OVS patches
working-directory: ovs
run: |
# fix kernel crash
Invoke-WebRequest -Uri "https://github.com/kubeovn/ovs/commit/2e4109b122f09342479b7b00aafbabcb2c829169.patch" -OutFile ..\ovs-01.patch
# support for building in github actions
Invoke-WebRequest -Uri "https://github.com/kubeovn/ovs/commit/eb2e7251e515c50b1c8137b93a81cc74a1eca60c.patch" -OutFile ..\ovs-02.patch
# listen on tcp 127.0.0.1:6643 by default
Invoke-WebRequest -Uri "https://github.com/kubeovn/ovs/commit/527f4338f42e774807b8461f11978b11b3fe8de3.patch" -OutFile ..\ovs-03.patch
git apply ..\ovs-01.patch
git apply ..\ovs-02.patch
git apply ..\ovs-03.patch
- name: Apply OVN patches
working-directory: ovn
run: |
# change hash type from dp_hash to hash with field src_ip
Invoke-WebRequest -Uri "https://github.com/kubeovn/ovn/commit/fc7edfcfe070e0a4f824fa7ce21843102003d344.patch" -OutFile ..\ovn-01.patch
# add support for windows
Invoke-WebRequest -Uri "https://github.com/kubeovn/ovn/commit/d497719c50c52ea8542afd31fe7c827854df6857.patch" -OutFile ..\ovn-02.patch
# set br-int controller to TCP 127.0.0.1:6653
Invoke-WebRequest -Uri "https://github.com/kubeovn/ovn/commit/fd94df637cf32ffe21122a895463185857551a4f.patch" -OutFile ..\ovn-03.patch
# ovn-controller: do not send GARP on localnet for Kube-OVN ports
Invoke-WebRequest -Uri "https://github.com/kubeovn/ovn/commit/97723a87ded4c35ea4f2465b34ef501e837b365b.patch" -OutFile ..\ovn-04.patch
git apply ..\ovn-01.patch
git apply ..\ovn-02.patch
git apply ..\ovn-03.patch
git apply ..\ovn-04.patch
- name: Build PTHREADS4W
working-directory: pthreads4w\code
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
nmake all install
- name: Build OVS and OVN
shell: cmd
env:
MSYS2_PATH_TYPE: inherit
run: |
SETLOCAL ENABLEDELAYEDEXPANSION
SET _p4w_dir=%CD:\=/%/pthreads4w/PTHREADS-BUILT
FOR /F "tokens=* USEBACKQ" %%F IN (`C:\msys64\usr\bin\cygpath.exe -u "%CD%\ovs"`) DO (
SET _ovs_dir=%%F
)
FOR /F "tokens=* USEBACKQ" %%F IN (`C:\msys64\usr\bin\cygpath.exe -u "%CD%\ovn"`) DO (
SET _ovn_dir=%%F
)
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
SET _vs_path=
FOR %%d IN ("%PATH:;=";"%") DO (
echo %%~d | findstr /C:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" > nul && set _vs_path=!_vs_path!;%%~d
)
SET PATH="%_vs_path%;%PATH%"
C:\msys64\usr\bin\bash.exe -lc "pacman -S --noconfirm python-pip libtool autoconf automake-wrapper"
C:\msys64\usr\bin\bash.exe -lc "python3 -m pip install pypiwin32"
C:\msys64\usr\bin\bash.exe -lc "rm -f `which link`"
C:\msys64\usr\bin\bash.exe -lc "cd '%_ovs_dir%' && ./boot.sh"
C:\msys64\usr\bin\bash.exe -lc "cd '%_ovs_dir%' && ./configure CC=./build-aux/cccl LD='`which link`' LIBS='-lws2_32 -lShlwapi -liphlpapi -lwbemuuid -lole32 -loleaut32' --prefix='C:/openvswitch/usr' --localstatedir='C:/openvswitch/var' --sysconfdir='C:/openvswitch/etc' --with-pthread='%_p4w_dir%' --disable-ssl"
C:\msys64\usr\bin\bash.exe -lc "cd '%_ovs_dir%' && make -j"
C:\msys64\usr\bin\bash.exe -lc "cd '%_ovs_dir%' && make windows_installer"
C:\msys64\usr\bin\bash.exe -lc "cd '%_ovn_dir%' && ./boot.sh"
C:\msys64\usr\bin\bash.exe -lc "cd '%_ovn_dir%' && ./configure CC=./build-aux/cccl LD='`which link`' LIBS='-lws2_32 -lShlwapi -liphlpapi -lwbemuuid -lole32 -loleaut32' --prefix='C:/ovn/usr' --localstatedir='C:/ovn/var' --sysconfdir='C:/ovn/etc' --with-pthread='%_p4w_dir%' --disable-ssl --with-ovs-source='../ovs'"
C:\msys64\usr\bin\bash.exe -lc "cd '%_ovn_dir%' && make -j"
C:\msys64\usr\bin\bash.exe -lc "cd '%_ovn_dir%' && make install"
- name: Upload OVS
uses: actions/upload-artifact@v4
with:
name: ovs-win64
path: ovs\windows\ovs-windows-installer\bin\x64\Release\OpenvSwitch.msi
- name: Upload OVN
uses: actions/upload-artifact@v4
with:
name: ovn-win64
path: C:\ovn
build-kube-ovn:
name: Build Kube-OVN
needs: filter
runs-on: windows-2019
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || needs.filter.outputs.build-kube-ovn == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION || '' }}
go-version-file: go.mod
check-latest: true
cache: false
- name: Export Go full version
run: |
$goVersion = (go env GOVERSION)
$entry = [string]::Format("GO_FULL_VER={0}", $goVersion)
Add-Content -Path $env:GITHUB_ENV -Value $entry
- name: Go Cache
uses: actions/cache@v4
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-${{ env.GO_FULL_VER }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-
- name: Install gosec
run: |
Invoke-WebRequest https://github.com/securego/gosec/releases/download/v${{ env.GOSEC_VERSION }}/gosec_${{ env.GOSEC_VERSION }}_windows_amd64.tar.gz -OutFile gosec.tar.gz
mkdir gosec
tar -xzvf gosec.tar.gz -C gosec
Copy-Item gosec/gosec.exe -Destination C:\Windows\system32
- name: Build
run: |
go mod tidy
make lint-windows
make build-go-windows
- name: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: kube-ovn-bin
path: |
dist/windows/kube-ovn.exe
dist/windows/kube-ovn-daemon.exe
package:
name: Pack Windows Files
needs:
- build-ovs-and-ovn
- build-kube-ovn
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
- name: Download Kube-OVN binaries
uses: actions/download-artifact@v4
with:
name: kube-ovn-bin
path: dist/windows
- name: Download OVS
uses: actions/download-artifact@v4
with:
name: ovs-win64
path: dist/windows
- name: Download OVN
uses: actions/download-artifact@v4
with:
name: ovn-win64
path: dist/windows/ovn
- name: Pack files
working-directory: dist/windows
run: |
# ovn
New-Item -ItemType directory -Path ovn/etc
Copy-Item ovn-controller.conf -Destination ovn/etc
Copy-Item start-ovn-controller.ps1 -Destination ovn
# kube-ovn
New-Item -ItemType directory -Path "kube-ovn/etc", "kube-ovn/bin"
Copy-Item 01-kube-ovn.conflist -Destination kube-ovn
Copy-Item kube-ovn.conf -Destination kube-ovn/etc
Copy-Item start-kube-ovn.ps1 -Destination kube-ovn/bin
Copy-Item kube-ovn.exe -Destination kube-ovn/bin
Copy-Item kube-ovn-daemon.exe -Destination kube-ovn/bin
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: kube-ovn-win64
path: |
dist/windows/OpenvSwitch.msi
dist/windows/ovn
dist/windows/kube-ovn
dist/windows/install.ps1