Skip to content

Commit 7203072

Browse files
committed
Add GitHub Actions workflow for NuGet publishing and GitVersion config
1 parent 8451dbd commit 7203072

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed

.github/workflows/publish-nuget.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Publish NuGet Package
33
on:
44
push:
55
branches:
6-
- main
6+
- main # وقتی روی برنچ main پوش میشه
77
tags:
8-
- 'v*.*.*'
8+
- 'v*.*.*' # یا وقتی تگ با الگوی vX.Y.Z ساخته میشه
99

1010
jobs:
1111
publish:
@@ -15,19 +15,21 @@ jobs:
1515
- name: Checkout code
1616
uses: actions/checkout@v3
1717

18-
- name: Setup .NET SDK
18+
- name: Setup .NET
1919
uses: actions/setup-dotnet@v4
2020
with:
2121
dotnet-version: |
2222
6.0.x
2323
8.0.x
2424
25-
- name: Install GitVersion
25+
- name: Setup GitVersion
2626
uses: gittools/actions/gitversion/[email protected]
27+
with:
28+
versionSpec: '5.x'
2729

28-
- name: Use GitVersion to get version info
30+
- name: Get version info
2931
id: gitversion
30-
run: gitversion /output json /showvariable SemVer
32+
run: gitversion /output json /showvariable NuGetVersionV2
3133

3234
- name: Restore dependencies
3335
run: dotnet restore
@@ -36,8 +38,14 @@ jobs:
3638
run: dotnet build --configuration Release --no-restore
3739

3840
- 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
4045
4146
- 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

GitVersion.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
1-
mode: ContinuousDelivery
2-
1+
mode: ContinuousDeployment
32
branches:
43
main:
54
regex: ^main$
65
increment: Minor
7-
prevent-increment-of-merged-branch-version: true
86
track-merge-target: false
9-
tag: ''
10-
7+
prevent-increment-of-merged-branch-version: true
8+
is-mainline: true
9+
pre-release-weight: 0
1110
develop:
1211
regex: ^develop$
1312
increment: Patch
14-
tag: 'beta'
15-
13+
track-merge-target: false
14+
pre-release-weight: 3000
15+
source-branches:
16+
- main
17+
- release
1618
feature:
17-
regex: ^feature[/-]
19+
regex: ^features?[/-]
1820
increment: Patch
19-
tag: 'alpha'
20-
21+
source-branches:
22+
- develop
2123
bugfix:
22-
regex: ^bugfix[/-]
24+
regex: ^bugfix(es)?[/-]
2325
increment: Patch
24-
tag: 'alpha'
25-
26+
source-branches:
27+
- develop
2628
release:
27-
regex: ^release[/-]
29+
regex: ^release(s)?[/-]
30+
increment: Minor
31+
source-branches:
32+
- develop
33+
hotfix:
34+
regex: ^hotfix(es)?[/-]
2835
increment: Patch
29-
tag: 'rc'
30-
36+
source-branches:
37+
- main
3138
ignore:
3239
sha: []
33-
40+
merge-message-strategy: MergeMessage
3441
commit-message-incrementing: Enabled
35-

0 commit comments

Comments
 (0)