@@ -3,9 +3,9 @@ name: Publish NuGet Package
3
3
on :
4
4
push :
5
5
branches :
6
- - main
6
+ - main # وقتی روی برنچ main پوش میشه
7
7
tags :
8
- - ' v*.*.*'
8
+ - ' v*.*.*' # یا وقتی تگ با الگوی vX.Y.Z ساخته میشه
9
9
10
10
jobs :
11
11
publish :
@@ -15,19 +15,21 @@ jobs:
15
15
- name : Checkout code
16
16
uses : actions/checkout@v3
17
17
18
- - name : Setup .NET SDK
18
+ - name : Setup .NET
19
19
uses : actions/setup-dotnet@v4
20
20
with :
21
21
dotnet-version : |
22
22
6.0.x
23
23
8.0.x
24
24
25
- - name : Install GitVersion
25
+ - name : Setup GitVersion
26
26
uses :
gittools/actions/gitversion/[email protected]
27
+ with :
28
+ versionSpec : ' 5.x'
27
29
28
- - name : Use GitVersion to get version info
30
+ - name : Get version info
29
31
id : gitversion
30
- run : gitversion /output json /showvariable SemVer
32
+ run : gitversion /output json /showvariable NuGetVersionV2
31
33
32
34
- name : Restore dependencies
33
35
run : dotnet restore
36
38
run : dotnet build --configuration Release --no-restore
37
39
38
40
- name : Pack NuGet
39
- run : dotnet pack --configuration Release -p:PackageVersion=${{ steps.gitversion.outputs.SemVer }} --no-build -o out
41
+ run : |
42
+ dotnet pack --configuration Release \
43
+ -p:PackageVersion=${{ steps.gitversion.outputs.NuGetVersionV2 }} \
44
+ --no-build -o out
40
45
41
46
- name : Push to NuGet
42
- if : success() && github.event_name == 'push'
43
- run : dotnet nuget push out/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
47
+ if : success() && steps.gitversion.outputs.NuGetVersionV2 != ''
48
+ run : |
49
+ dotnet nuget push out/*.nupkg \
50
+ --api-key ${{ secrets.NUGET_API_KEY }} \
51
+ --source https://api.nuget.org/v3/index.json
0 commit comments