forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 4
295 lines (252 loc) · 9.9 KB
/
generate-and-build-sdks.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
name: Generate and Build SDKs
on:
workflow_call:
inputs:
xapi_version:
required: true
type: string
jobs:
generate-sdk-sources:
name: Generate SDK sources
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup XenAPI environment
uses: ./.github/workflows/setup-xapi-environment
with:
xapi_version: ${{ inputs.xapi_version }}
- name: Generate SDKs
shell: bash
run: opam exec -- make sdk
- name: Run CI for SDKs
uses: ./.github/workflows/sdk-ci
- name: Store C SDK source
uses: actions/upload-artifact@v4
with:
name: SDK_Source_C
path: |
_build/install/default/share/c/*
!_build/install/default/share/c/dune
- name: Store C# SDK source
uses: actions/upload-artifact@v4
with:
name: SDK_Source_CSharp
path: _build/install/default/share/csharp/*
- name: Store PowerShell SDK source
uses: actions/upload-artifact@v4
with:
name: SDK_Source_PowerShell
path: _build/install/default/share/powershell/*
- name: Store Go SDK Artifacts
uses: actions/upload-artifact@v4
with:
name: SDK_Artifacts_Go
path: |
_build/install/default/share/go/*
!_build/install/default/share/go/dune
- name: Store Java SDK source
uses: actions/upload-artifact@v4
with:
name: SDK_Source_Java
path: _build/install/default/share/java/*
- name: Trim dune cache
run: opam exec -- dune cache trim --size=2GiB
build-c-sdk:
name: Build C SDK
runs-on: ubuntu-latest
needs: generate-sdk-sources
steps:
- name: Install dependencies
run: sudo apt-get install libxml2-dev
- name: Retrieve C SDK source
uses: actions/download-artifact@v4
with:
name: SDK_Source_C
path: source/
- name: Build C SDK
shell: bash
run: make -C source
- name: Store C SDK
uses: actions/upload-artifact@v4
with:
name: SDK_Artifacts_C
path: |
source/*
!source/src/*.o
build-java-sdk:
name: Build Java SDK
runs-on: ubuntu-latest
needs: generate-sdk-sources
steps:
- name: Install dependencies
run: sudo apt-get install maven
- name: Retrieve Java SDK source
uses: actions/download-artifact@v4
with:
name: SDK_Source_Java
path: source/
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Build Java SDK
shell: bash
run: |
xapi_version="${{ inputs.xapi_version }}"
xapi_version="${xapi_version//v/}"
mkdir -p target && mvn -f source/xen-api/pom.xml -B -Drevision=$xapi_version-prerelease clean package && mv source/xen-api/target/*.jar target/
- name: Store Java SDK
uses: actions/upload-artifact@v4
with:
name: SDK_Artifacts_Java
path: target/*
build-csharp-sdk:
name: Build C# SDK
runs-on: windows-2022
needs: generate-sdk-sources
steps:
- name: Strip 'v' prefix from xapi version
shell: pwsh
run: echo "XAPI_VERSION_NUMBER=$("${{ inputs.xapi_version }}".TrimStart('v'))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Retrieve C# SDK source
uses: actions/download-artifact@v4
with:
name: SDK_Source_CSharp
path: source/
- name: Build C# SDK
shell: pwsh
run: |
dotnet build source/src `
--disable-build-servers `
--configuration Release `
-p:Version=${{ env.XAPI_VERSION_NUMBER }}-prerelease-unsigned `
--verbosity=normal
- name: Store C# SDK
uses: actions/upload-artifact@v4
with:
name: SDK_Binaries_CSharp
path: source/src/bin/Release/XenServer.NET.${{ env.XAPI_VERSION_NUMBER }}-prerelease-unsigned.nupkg
build-powershell-5x-sdk:
name: Build PowerShell 5.x SDK (.NET Framework 4.5)
needs: build-csharp-sdk
# PowerShell SDK for PowerShell 5.x needs to run on windows-2019 because
# windows-2022 doesn't contain .NET Framework 4.x dev tools
runs-on: windows-2019
steps:
- name: Strip 'v' prefix from xapi version
shell: pwsh
run: echo "XAPI_VERSION_NUMBER=$("${{ inputs.xapi_version }}".TrimStart('v'))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Retrieve PowerShell SDK source
uses: actions/download-artifact@v4
with:
name: SDK_Source_PowerShell
path: source/
- name: Retrieve C# SDK binaries
uses: actions/download-artifact@v4
with:
name: SDK_Binaries_CSharp
path: csharp/
# Following needed for restoring packages
# when calling dotnet add package
- name: Set up dotnet CLI (.NET 6.0 and 8.0)
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6
8
- name: Setup project and dotnet CLI
shell: pwsh
run: |
dotnet nuget add source --name local ${{ github.workspace }}\csharp
dotnet add source/src package XenServer.NET --version ${{ env.XAPI_VERSION_NUMBER }}-prerelease-unsigned
- name: Build PowerShell SDK (.NET Framework 4.5)
shell: pwsh
run: |
dotnet build source/src/XenServerPowerShell.csproj `
--disable-build-servers `
--configuration Release `
-p:Version=${{ env.XAPI_VERSION_NUMBER }}-prerelease-unsigned `
-p:TargetFramework=net45 `
--verbosity=normal`
- name: Update SDK and PS versions in "XenServerPSModule.psd1"
shell: pwsh
run: |
(Get-Content "source\XenServerPSModule.psd1") -replace "@SDK_VERSION@","${{ env.XAPI_VERSION_NUMBER }}" | Set-Content -Path "source\XenServerPSModule.psd1"
(Get-Content "source\XenServerPSModule.psd1") -replace "@PS_VERSION@","5.0" | Set-Content -Path "source\XenServerPSModule.psd1"
- name: Move binaries to destination folder
shell: pwsh
run: |
New-Item -Path "." -Name "output" -ItemType "directory"
Copy-Item -Verbose "source\README_51.md" -Destination "output" -Force
Copy-Item -Verbose "source\LICENSE" -Destination "output" -Force
Copy-Item -Path "source\src\bin\Release\net45\*" -Include "*.dll" "output\"
Get-ChildItem -Path "source" |`
Where-Object { $_.Extension -eq ".ps1" -or $_.Extension -eq ".ps1xml" -or $_.Extension -eq ".psd1" -or $_.Extension -eq ".txt" } |`
ForEach-Object -Process { Copy-Item -Verbose $_.FullName -Destination "output" }
- name: Store PowerShell SDK (.NET Framework 4.5)
uses: actions/upload-artifact@v4
with:
name: SDK_Binaries_XenServerPowerShell_NET45
path: output/**/*
build-powershell-7x-sdk:
name: Build PowerShell 7.x SDK
strategy:
fail-fast: false
matrix:
dotnet: ["6", "8"]
needs: build-csharp-sdk
runs-on: windows-2022
steps:
- name: Strip 'v' prefix from xapi version
shell: pwsh
run: echo "XAPI_VERSION_NUMBER=$("${{ inputs.xapi_version }}".TrimStart('v'))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Retrieve PowerShell SDK source
uses: actions/download-artifact@v4
with:
name: SDK_Source_PowerShell
path: source/
- name: Retrieve C# SDK binaries
uses: actions/download-artifact@v4
with:
name: SDK_Binaries_CSharp
path: csharp/
- name: Set up dotnet CLI (.NET ${{ matrix.dotnet }})
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Setup project and NuGet source
shell: pwsh
run: |
dotnet nuget add source --name local ${{ github.workspace }}\csharp
dotnet add source/src package XenServer.NET --version ${{ env.XAPI_VERSION_NUMBER }}-prerelease-unsigned
- name: Build PowerShell SDK (.NET ${{ matrix.dotnet }})
shell: pwsh
run: |
dotnet build source/src/XenServerPowerShell.csproj `
--disable-build-servers `
--configuration Release `
-p:Version=${{ env.XAPI_VERSION_NUMBER }}-prerelease-unsigned `
-p:TargetFramework=net${{ matrix.dotnet }}.0 `
--verbosity=normal`
- name: Update SDK and PS versions in "XenServerPSModule.psd1"
shell: pwsh
run: |
(Get-Content "source\XenServerPSModule.psd1") -replace "@SDK_VERSION@","${{ env.XAPI_VERSION_NUMBER }}" | Set-Content -Path "source\XenServerPSModule.psd1"
(Get-Content "source\XenServerPSModule.psd1") -replace "@PS_VERSION@","7.0" | Set-Content -Path "source\XenServerPSModule.psd1"
- name: Move binaries to destination folder
shell: pwsh
run: |
New-Item -Path "." -Name "output" -ItemType "directory"
Copy-Item -Verbose "source\README.md" -Destination "output" -Force
Copy-Item -Verbose "source\LICENSE" -Destination "output" -Force
Copy-Item -Path "source\src\bin\Release\net${{ matrix.dotnet }}.0\*" -Include "*.dll" "output\"
Get-ChildItem -Path "source" |`
Where-Object { $_.Extension -eq ".ps1" -or $_.Extension -eq ".ps1xml" -or $_.Extension -eq ".psd1" -or $_.Extension -eq ".txt" } |`
ForEach-Object -Process { Copy-Item -Verbose $_.FullName -Destination "output" }
- name: Store PowerShell SDK (.NET ${{ matrix.dotnet }})
uses: actions/upload-artifact@v4
with:
name: SDK_Binaries_XenServerPowerShell_NET${{ matrix.dotnet }}
path: output/**/*