11
11
env :
12
12
DOTNET_CLI_TELEMETRY_OPTOUT : true
13
13
DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
14
+ PUBLISH_RELEASE : ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !github.event.repository.fork }}
14
15
15
16
permissions :
16
17
contents : read
@@ -203,6 +204,8 @@ jobs:
203
204
name : Build NuGet package
204
205
runs-on : ubuntu-latest
205
206
needs : build-native
207
+ outputs :
208
+ version : ${{ steps.get-version.outputs.version }}
206
209
steps :
207
210
- name : Checkout
208
211
uses : actions/checkout@v4
@@ -218,8 +221,23 @@ jobs:
218
221
uses : actions/setup-dotnet@v4
219
222
with :
220
223
dotnet-version : 7.0.x
224
+ - name : Get version
225
+ id : get-version
226
+ shell : pwsh
227
+ run : |
228
+ $version_prefix=$((Select-Xml -Path ./csharp/ParquetSharp.csproj -XPath '/Project/PropertyGroup/VersionPrefix/text()').node.Value)
229
+ if ( "${env:PUBLISH_RELEASE}" -eq "true") {
230
+ $version_suffix=""
231
+ $version="${version_prefix}"
232
+ } else {
233
+ $version_suffix="$(git rev-parse --short HEAD)"
234
+ $version="${version_prefix}-${version_suffix}"
235
+ }
236
+ echo "version=${version}"
237
+ echo "version=${version}" >> $env:GITHUB_OUTPUT
238
+ echo "version_suffix=${version_suffix}" >> $env:GITHUB_OUTPUT
221
239
- name : Build NuGet package
222
- run : dotnet build csharp --configuration=Release
240
+ run : dotnet build csharp --configuration=Release --version-suffix="${{ steps.get-version.outputs.version_suffix }}"
223
241
- name : Upload NuGet artifact
224
242
uses : actions/upload-artifact@v4
225
243
with :
@@ -245,10 +263,6 @@ jobs:
245
263
steps :
246
264
- name : Checkout
247
265
uses : actions/checkout@v4
248
- - name : Get version
249
- id : get-version
250
- run : echo "version=$((Select-Xml -Path ./csharp/ParquetSharp.csproj -XPath '/Project/PropertyGroup/Version/text()').node.Value)" >> $env:GITHUB_OUTPUT
251
- shell : pwsh
252
266
- name : Download NuGet artifact
253
267
uses : actions/download-artifact@v4
254
268
with :
@@ -275,9 +289,9 @@ jobs:
275
289
- name : Change test project references to use local NuGet package
276
290
run : |
277
291
dotnet remove csharp.test reference csharp/ParquetSharp.csproj
278
- dotnet add csharp.test package ParquetSharp -v ${{ steps.get-version .outputs.version }}
292
+ dotnet add csharp.test package ParquetSharp -v ${{ needs.build-nuget .outputs.version }}
279
293
dotnet remove fsharp.test reference csharp/ParquetSharp.csproj
280
- dotnet add fsharp.test package ParquetSharp -v ${{ steps.get-version .outputs.version }}
294
+ dotnet add fsharp.test package ParquetSharp -v ${{ needs.build-nuget .outputs.version }}
281
295
- name : Build & Run C# unit tests
282
296
run : dotnet test csharp.test --configuration=Release --framework ${{ matrix.dotnet }}
283
297
- name : Build & Run F# unit tests
@@ -297,26 +311,26 @@ jobs:
297
311
298
312
# Create a GitHub release and publish the NuGet packages to nuget.org when a tag is pushed.
299
313
publish-release :
314
+ # This should match env.PUBLISH_RELEASE (which we can't access in an if condition)
300
315
if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !github.event.repository.fork
301
316
name : Publish release
302
317
runs-on : ubuntu-latest
303
318
permissions :
304
319
contents : write
305
- needs : all-required-checks-done
320
+ needs : [build-nuget, all-required-checks-done]
306
321
steps :
307
322
- name : Checkout
308
323
uses : actions/checkout@v4
309
324
- name : Check version
310
325
id : check-version
311
326
shell : pwsh
312
327
run : |
313
- $version = (Select-Xml -Path ./csharp/ParquetSharp.csproj -XPath '/Project/PropertyGroup/Version/text()').node.Value
328
+ $version = "${{ needs.build-nuget.outputs.version }}"
314
329
$tag = "${{ github.ref }}".SubString(10)
315
330
if (-not ($tag -eq $version)) {
316
331
echo "::error ::There is a mismatch between the project version ($version) and the tag ($tag)"
317
332
exit 1
318
333
}
319
- echo "version=$version" >> $env:GITHUB_OUTPUT
320
334
- name : Download NuGet artifact
321
335
uses : actions/download-artifact@v4
322
336
with :
@@ -331,12 +345,12 @@ jobs:
331
345
- name : Create release
332
346
uses : softprops/action-gh-release@v2
333
347
with :
334
- name : ParquetSharp ${{ steps.check-version .outputs.version }}
348
+ name : ParquetSharp ${{ needs.build-nuget .outputs.version }}
335
349
draft : true
336
- prerelease : ${{ contains(steps.check-version .outputs.version, '-') }}
350
+ prerelease : ${{ contains(needs.build-nuget .outputs.version, '-') }}
337
351
files : |
338
- nuget/ParquetSharp.${{ steps.check-version .outputs.version }}.nupkg
352
+ nuget/ParquetSharp.${{ needs.build-nuget .outputs.version }}.nupkg
339
353
env :
340
354
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
341
355
- name : Publish to NuGet
342
- run : dotnet nuget push nuget/ParquetSharp.${{ steps.check-version .outputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
356
+ run : dotnet nuget push nuget/ParquetSharp.${{ needs.build-nuget .outputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
0 commit comments