Skip to content

Commit e516b2e

Browse files
committed
🎈 main.yml
1 parent 231dbe6 commit e516b2e

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

.github/workflows/main.yml

+33-21
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,66 @@ jobs:
1414
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
1515

1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0 #fetch-depth is needed for GitVersion
2020

2121
#Install and calculate the new version with GitVersion
2222
- name: Install GitVersion
23-
uses: gittools/actions/gitversion/setup@v0.9.7
23+
uses: gittools/actions/gitversion/setup@v0.10.2
2424
with:
2525
versionSpec: 5.x
2626
- name: Determine Version
27-
uses: gittools/actions/gitversion/execute@v0.9.7
27+
uses: gittools/actions/gitversion/execute@v0.10.2
2828
id: gitversion # step id used as reference for output values
2929
- name: Display GitVersion outputs
3030
run: |
3131
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
3232
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
3333
34-
#Build/pack the project
34+
# Build/pack the project
3535
- name: Setup .NET
36-
uses: actions/setup-dotnet@v1
36+
uses: actions/setup-dotnet@v3.2.0
3737
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+
4143
- name: Upload NuGet package to GitHub
42-
uses: actions/upload-artifact@v2
44+
uses: actions/upload-artifact@v3.1.3
4345
with:
4446
name: nugetPackage
45-
path: bin/Release/
46-
47+
path: bin/Release/*.nupkg
48+
4749
release:
4850
runs-on: ubuntu-latest
4951
needs: build
50-
51-
steps:
52+
if: github.ref == 'refs/heads/master' # only run job if on the master branch
53+
54+
steps:
5255
#Push NuGet package to GitHub packages
5356
- name: Download nuget package artifact
54-
uses: actions/download-artifact@v1.0.0
57+
uses: actions/download-artifact@v3.0.2
5558
with:
5659
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
5970

6071
#Create release
6172
- 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
6575
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 }}

MqttNet.DependencyInjection/MqttNet.DependencyInjection.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
55
<PackageReadmeFile>README.md</PackageReadmeFile>
6-
<RepositoryUrl>https://github.com/jinzaz/MqttNet.DependencyInjection</RepositoryUrl>
6+
<RepositoryUrl>https://github.com/jinzaz/MqttNet.DependencyInjection.</RepositoryUrl>
7+
<PackageProjectUrl>https://github.com/jinzaz/MqttNet.DependencyInjection</PackageProjectUrl>
78
<PackageLicenseExpression>MIT</PackageLicenseExpression>
8-
<Title>MqttNet DependencyInjection in AspNetCore</Title>
9+
<Title>MqttNet Client DependencyInjection in AspNetCore</Title>
910
<Authors>john.jiang</Authors>
1011
<Version>1.0.1</Version>
1112
</PropertyGroup>

0 commit comments

Comments
 (0)