@@ -14,54 +14,66 @@ jobs:
14
14
CommitsSinceVersionSource : ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
15
15
16
16
steps :
17
- - uses : actions/checkout@v2
17
+ - uses : actions/checkout@v4
18
18
with :
19
19
fetch-depth : 0 # fetch-depth is needed for GitVersion
20
20
21
21
# Install and calculate the new version with GitVersion
22
22
- name : Install GitVersion
23
- uses : gittools/actions/gitversion/setup@v0.9.7
23
+ uses : gittools/actions/gitversion/setup@v0.10.2
24
24
with :
25
25
versionSpec : 5.x
26
26
- name : Determine Version
27
- uses : gittools/actions/gitversion/execute@v0.9.7
27
+ uses : gittools/actions/gitversion/execute@v0.10.2
28
28
id : gitversion # step id used as reference for output values
29
29
- name : Display GitVersion outputs
30
30
run : |
31
31
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
32
32
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
33
33
34
- # Build/pack the project
34
+ # Build/pack the project
35
35
- name : Setup .NET
36
- uses : actions/setup-dotnet@v1
36
+ uses : actions/setup-dotnet@v3.2.0
37
37
with :
38
- dotnet-version : 6.0.x
39
- - name : Build and Pack NuGet package
40
- run : dotnet pack MqttNet.DependencyInjection/MqttNet.DependencyInjection.csproj -p:Version='${{ steps.gitversion.outputs.SemVer }}' -c Release
38
+ dotnet-version : 7.0.x
39
+
40
+ - name : Build and Pack NuGet package with versioning
41
+ run : dotnet pack ${{ vars.CS_PROJ_PATH }} -p:Version='${{ steps.gitversion.outputs.SemVer }}' -c Release
42
+
41
43
- name : Upload NuGet package to GitHub
42
- uses : actions/upload-artifact@v2
44
+ uses : actions/upload-artifact@v3.1.3
43
45
with :
44
46
name : nugetPackage
45
- path : bin/Release/
46
-
47
+ path : bin/Release/*.nupkg
48
+
47
49
release :
48
50
runs-on : ubuntu-latest
49
51
needs : build
50
-
51
- steps :
52
+ if : github.ref == 'refs/heads/master' # only run job if on the master branch
53
+
54
+ steps :
52
55
# Push NuGet package to GitHub packages
53
56
- name : Download nuget package artifact
54
- uses : actions/download-artifact@v1 .0.0
57
+ uses : actions/download-artifact@v3 .0.2
55
58
with :
56
59
name : nugetPackage
57
- - name : Push package to GitHub packages
58
- run : dotnet nuget push nugetPackage/*.nupkg --api-key ${{ secrets.NUGET_PACKAGE_TOKEN }} --source "https://api.nuget.org/v3/index.json"
60
+ path : nugetPackage
61
+ - name : Prep packages
62
+ run : dotnet nuget add source --username ${{ vars.USERNAME }} --password ${{ secrets.NUGET_PACKAGE_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ vars.USERNAME }}/index.json"
63
+ - name : Push package to GitHub packages
64
+ if : needs.build.outputs.CommitsSinceVersionSource > 0 # Only release if there has been a commit/version change
65
+ run : dotnet nuget push nugetPackage/*.nupkg --api-key ${{ secrets.NUGET_PACKAGE_TOKEN }} --source "github"
66
+
67
+ # Publish to NuGet.org
68
+ - name : Publish to NuGet.org
69
+ run : dotnet nuget push nugetPackage/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
59
70
60
71
# Create release
61
72
- name : Create Release
62
- uses : actions/create-release@v1
63
- env :
64
- GITHUB_TOKEN : ${{ secrets.NUGET_PACKAGE_TOKEN }}
73
+ if : needs.build.outputs.CommitsSinceVersionSource > 0 # Only release if there has been a commit/version change
74
+ uses : ncipollo/release-action@v1.13.0
65
75
with :
66
- tag_name : ${{ needs.build.outputs.Version }}
67
- release_name : Release ${{ needs.build.outputs.Version }}
76
+ tag : ${{ needs.build.outputs.Version }}
77
+ name : Release ${{ needs.build.outputs.Version }}
78
+ artifacts : " nugetPackage/*"
79
+ token : ${{ secrets.NUGET_PACKAGE_TOKEN }}
0 commit comments