1
+ name : ' confluent-kafka-dotnet build pipeline'
2
+
3
+ env :
4
+ DOTNET_CLI_TELEMETRY_OPTOUT : ' true'
5
+
6
+ on :
7
+ push :
8
+ pull_request :
9
+
10
+ jobs :
11
+
12
+ build-test :
13
+ strategy :
14
+ matrix :
15
+ os : [ubuntu-latest, windows-latest, macos-13] # macos-13 for x86_x64 arch
16
+ runs-on : ${{ matrix.os }}
17
+ steps :
18
+ - uses : actions/checkout@v4
19
+ - name : Setup .NET
20
+ uses : actions/setup-dotnet@v4
21
+ with :
22
+ dotnet-version : |
23
+ 6.0.x
24
+ 8.0.x
25
+ - name : Build and test
26
+ run : |
27
+ dotnet nuget add source --username user --password ${{ github.token }} --store-password-in-clear-text --name github https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
28
+ dotnet restore
29
+ dotnet test -c Release test/Confluent.Kafka.UnitTests/Confluent.Kafka.UnitTests.csproj
30
+ env :
31
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32
+
33
+ package :
34
+ needs : [build-test]
35
+ runs-on : windows-latest
36
+ steps :
37
+
38
+ - name : Show default environment variables
39
+ run : |
40
+ echo "The job_id is: $GITHUB_JOB" # reference the default environment variables
41
+ echo "The id of this action is: $GITHUB_ACTION" # reference the default environment variables
42
+ echo "The run id is: $GITHUB_RUN_ID"
43
+ echo "The GitHub Actor's username is: $GITHUB_ACTOR"
44
+ echo "GitHub SHA: $GITHUB_SHA"
45
+ - uses : actions/checkout@v4
46
+ - name : Setup .NET
47
+ uses : actions/setup-dotnet@v4
48
+ with :
49
+ dotnet-version : |
50
+ 6.0.x
51
+ 8.0.x
52
+ - name : Build and create packages
53
+ run : |
54
+ dotnet restore
55
+ dotnet build Confluent.Kafka.sln -c Release
56
+
57
+ # Different packaging for tagged vs untagged builds
58
+ if ($env:GITHUB_REF -match '^refs/tags/') {
59
+ $suffix = "gr"
60
+ } else {
61
+ $suffix = "ci-$env:GITHUB_RUN_ID"
62
+ }
63
+
64
+ dotnet pack src/Confluent.Kafka/Confluent.Kafka.csproj --output dist -c Release --version-suffix $suffix
65
+
66
+ - name : Upload artifacts
67
+ uses : actions/upload-artifact@v4
68
+ with :
69
+ name : build-artifacts
70
+ path : dist/
71
+
72
+ # Publish NuGet packages when a tag is pushed.
73
+ # Tests need to succeed for all components and on all platforms first,
74
+ # including having a tag name that matches the version number.
75
+ publish-release :
76
+ if : ${{ startsWith(github.ref, 'refs/tags/v') }}
77
+ needs : package
78
+ runs-on : ubuntu-latest
79
+ steps :
80
+ - name : Download NuGet package artifacts
81
+ uses : actions/download-artifact@v4
82
+ with :
83
+ name : build-artifacts
84
+ path : dist
85
+ - name : Publish to NuGet
86
+ run : |
87
+ dotnet nuget push "dist/Confluent.Kafka*.nupkg" --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --api-key ${GITHUB_TOKEN}
88
+ env :
89
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments