-
Notifications
You must be signed in to change notification settings - Fork 193
316 lines (261 loc) · 10.9 KB
/
buildCSharp.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: buildCSharpSDK
on:
push:
branches: [ master, CSharp ]
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: [ master ]
jobs:
build-csharp:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
# fail-fast: Default is true, switch to false to allow one platform to fail and still run others
fail-fast: false
matrix:
name: [Ubuntu, macOS, Windows64, Windows32]
include:
- name: Ubuntu
os: ubuntu-20.04
- name: macOS
os: macos-11
- name: Windows64
os: windows-latest
- name: Windows32
os: windows-latest
steps:
- uses: actions/checkout@v4
# If you need to rebuild for a specific branch **after** you fixed the workflow...
# with:
# ref: master
- uses: actions/setup-python@v4
with:
python-version: '3.8.x'
- name: Install conan
run: |
python --version
pip install conan==1.59
conan --version
echo "Enabling conan revisions and setting parallel_download"
conan config set general.revisions_enabled=True
conan config set general.parallel_download=8
- name: Compile Ubuntu
if: runner.os == 'Linux'
shell: bash
run: |
set -x
sudo apt update && sudo apt install -y ninja-build
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE:STRING=Release \
-DBUILD_CSHARP_BINDINGS:BOOL=ON -DBUILD_NUGET_PACKAGE:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF -DBUILD_RUBY_BINDINGS:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=OFF -DBUILD_CLI:BOOL=OFF \
-DBUILD_PACKAGE:BOOL=OFF \
../
ninja
- name: Compile macOS
if: runner.os == 'macOS'
shell: bash
run: |
set -x
brew install ninja
export CC=clang
export CMAKE_OSX_ARCHITECTURES=x86_64
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE:STRING=Release \
-DBUILD_CSHARP_BINDINGS:BOOL=ON -DBUILD_NUGET_PACKAGE:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF -DBUILD_RUBY_BINDINGS:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=OFF -DBUILD_CLI:BOOL=OFF \
-DBUILD_PACKAGE:BOOL=OFF \
../
ninja
- name: Compile Windows 64
if: matrix.name == 'Windows64'
shell: cmd
run: |
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 ^
-DCMAKE_BUILD_TYPE:STRING=Release ^
-DBUILD_CSHARP_BINDINGS:BOOL=ON -DBUILD_NUGET_PACKAGE:BOOL=OFF ^
-DBUILD_TESTING:BOOL=OFF -DBUILD_RUBY_BINDINGS:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=OFF -DBUILD_CLI:BOOL=OFF ^
-DBUILD_PACKAGE:BOOL=OFF ^
../
cmake --build . --verbose --config Release -j 2
- name: Install Dotnet x86
if: matrix.name == 'Windows32'
run: |
Invoke-WebRequest 'https://dotnetcli.azureedge.net/dotnet/Runtime/7.0.1/dotnet-runtime-7.0.1-win-x86.exe' -OutFile './dotnet-runtime-7.0.1-win-x86.exe'
./dotnet-runtime-7.0.1-win-x86.exe /install /quiet /norestart
dotnet --info
- name: Compile Windows 32
if: matrix.name == 'Windows32'
shell: cmd
run: |
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A Win32 ^
-DCMAKE_BUILD_TYPE:STRING=Release ^
-DBUILD_CSHARP_BINDINGS:BOOL=ON -DBUILD_NUGET_PACKAGE:BOOL=OFF ^
-DBUILD_TESTING:BOOL=OFF -DBUILD_RUBY_BINDINGS:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=OFF -DBUILD_CLI:BOOL=OFF ^
-DBUILD_PACKAGE:BOOL=OFF ^
../
cmake --build . --verbose --config Release -j 2
- name: build nuget for Windows
if: runner.os == 'Windows'
run: |
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/
- name: build nuget for Linux
if: runner.os == 'Linux'
run: |
cp ./csharp/*.targets ./build/Products
ls ./build/Products
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/
- name: Fix dylib and build nuget for Mac
if: runner.os == 'macOS'
run: |
sudo install_name_tool -add_rpath "@loader_path/." ./build/Products/libopenstudio_csharp.dylib
sudo install_name_tool -delete_rpath "/Users/runner/work/OpenStudio/OpenStudio/build/Products" ./build/Products/libopenstudio_csharp.dylib
sudo install_name_tool -add_rpath "@loader_path/." ./build/Products/libopenstudio_model_csharp.dylib
sudo install_name_tool -delete_rpath "/Users/runner/work/OpenStudio/OpenStudio/build/Products" ./build/Products/libopenstudio_model_csharp.dylib
sudo install_name_tool -add_rpath "@loader_path/." ./build/Products/libopenstudio_translators_csharp.dylib
sudo install_name_tool -delete_rpath "/Users/runner/work/OpenStudio/OpenStudio/build/Products" ./build/Products/libopenstudio_translators_csharp.dylib
cp ./csharp/*.targets ./build/Products
ls ./build/Products
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/
- name: list files
run: |
echo "Listing the top directory=========================================="
ls
echo "Listing ./build/=========================================="
ls ./build/
echo "Listing ./build/Products/=========================================="
ls -R ./build/Products
- name: Zip Build/Source Artifact
run: |
7z a CSharp_${{ matrix.name }}.zip ./build/Products/csharp/Release/*.nupkg
7z a CSharp_${{ matrix.name }}_Src.zip ./build/csharp_wrapper/generated_sources ./build/csharp_wrapper/OpenStudio.csproj
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: CSharp_${{ matrix.name }}
path: CSharp_${{ matrix.name }}.zip
- name: Upload artifact generated_sources
uses: actions/upload-artifact@v3
with:
name: CSharp_${{ matrix.name }}_Src
path: CSharp_${{ matrix.name }}_Src.zip
- name: Upload artifact (if failed)
if: failure()
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}_Failed
path: |
./build/csharp_wrapper/
./build/Products/
Test_Windows:
name: "Test x86 and x64 nuget packages for windows"
runs-on: windows-latest
timeout-minutes: 20
needs: build-csharp
steps:
- uses: actions/checkout@v4
- name: Download CSharp_Windows32
uses: actions/download-artifact@v3
with:
name: CSharp_Windows32
- name: Download CSharp_Windows64
uses: actions/download-artifact@v3
with:
name: CSharp_Windows64
- name: unzip artifacts
run: |
Expand-Archive CSharp_Windows32.zip -DestinationPath x86
Expand-Archive CSharp_Windows64.zip -DestinationPath x64
Expand-Archive x86\*.nupkg -DestinationPath x86\package
Expand-Archive x64\*.nupkg -DestinationPath x64\package
ls -R
- name: merge x86 into x64
run: |
cp x64\package x64x86 -r
mv x64x86\lib x64x86\build
mkdir x64x86\build\netstandard2.0\x64
mkdir x64x86\build\net45\x64
mkdir x64x86\build\netstandard2.0\x86
mkdir x64x86\build\net45\x86
mv x64x86\build\netstandard2.0\*.dll x64x86\build\netstandard2.0\x64
mv x64x86\build\net45\*.dll x64x86\build\net45\x64
mv x86\package\lib\netstandard2.0\* x64x86\build\netstandard2.0\x86
mv x86\package\lib\net45\* x64x86\build\net45\x86
cp csharp\OpenStudio.targets x64x86\build\netstandard2.0\
cp csharp\OpenStudio.targets x64x86\build\net45\
cd x64x86
ls -R
- name: make a new nupkg for Windows
run: |
$VERSION = (Get-Item x64x86\build\netstandard2.0\x64\OpenStudio.dll).VersionInfo.FileVersion
echo $VERSION
Compress-Archive -U -Path x64x86\* -DestinationPath OpenStudio.$VERSION.nupkg
cp *.nupkg x64x86\OpenStudio.nupkg
ls
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: CSharp_Windows_x64x86
path: x64x86\OpenStudio.nupkg
- name: Install Dotnet x86
run: |
Invoke-WebRequest 'https://dotnetcli.azureedge.net/dotnet/Runtime/7.0.1/dotnet-runtime-7.0.1-win-x86.exe' -OutFile './dotnet-runtime-7.0.1-win-x86.exe'
./dotnet-runtime-7.0.1-win-x86.exe /install /quiet /norestart
dotnet --info
- name: Tests on Windows
run: |
$VERSION = (Get-Item x64x86\build\netstandard2.0\x64\OpenStudio.dll).VersionInfo.FileVersion
echo $VERSION
cp *.nupkg csharp/examples/OpenStudio.Tests/
cd csharp/examples/OpenStudio.Tests/
ls
dotnet remove OpenStudio.Tests.csproj package OpenStudio
dotnet remove OpenStudio.Tests.x86.csproj package OpenStudio
dotnet restore OpenStudio.Tests.csproj
dotnet restore OpenStudio.Tests.x86.csproj
dotnet add OpenStudio.Tests.csproj package OpenStudio -s "." -v $VERSION
dotnet add OpenStudio.Tests.x86.csproj package OpenStudio -s "." -v $VERSION
dotnet test OpenStudio.Tests.csproj --arch x64
dotnet clean OpenStudio.Tests.csproj
dotnet test OpenStudio.Tests.x86.csproj --arch x86
Test_Mac_ubuntu:
name: "Test x64 nuget packages for macos and ubuntu"
runs-on: ${{ matrix.os }}
strategy:
# fail-fast: Default is true, switch to false to allow one platform to fail and still run others
fail-fast: false
matrix:
name: [Ubuntu, macOS]
include:
- name: Ubuntu
os: ubuntu-latest
- name: macOS
os: macos-latest
timeout-minutes: 20
needs: build-csharp
steps:
- uses: actions/checkout@v4
- name: Download nuget
uses: actions/download-artifact@v3
with:
name: CSharp_${{ matrix.name }}
- name: unzip artifacts
run: |
7z e CSharp_${{ matrix.name }}.zip -o./nuget
ls nuget csharp/*
- name: Tests
run: |
cd csharp/examples/OpenStudio.Tests/
dotnet remove OpenStudio.Tests.csproj package OpenStudio
dotnet restore OpenStudio.Tests.csproj
dotnet add OpenStudio.Tests.csproj package OpenStudio -s "./../../../nuget"
dotnet clean OpenStudio.Tests.csproj
dotnet test OpenStudio.Tests.csproj --arch x64