Skip to content

Commit 1834a30

Browse files
committed
Fix CI-CD
1 parent 2213971 commit 1834a30

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

.github/workflows/publish-nuget.yml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,58 @@ name: Publish NuGet Package
22

33
on:
44
push:
5-
branches:
6-
- main
75
tags:
8-
- 'v*.*.*'
6+
- 'v*.*.*' # فقط زمانی اجرا شود که یک تگ با فرمت vX.Y.Z پوش شود
97

108
jobs:
119
publish:
1210
runs-on: ubuntu-latest
11+
# یک شرط اضافه برای اطمینان از اینکه فقط برای تگ‌ها اجرا می‌شود (اختیاری چون trigger اصلی همین کار را می‌کند)
12+
# if: startsWith(github.ref, 'refs/tags/')
1313

1414
steps:
1515
- name: Checkout code
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4 # استفاده از نسخه جدیدتر
17+
with:
18+
fetch-depth: 0 # بسیار مهم برای GitVersion
1719

18-
- name: Setup .NET SDKs
19-
uses: actions/setup-dotnet@v4
20+
- name: Setup .NET SDK
21+
uses: actions/setup-dotnet@v4 # استفاده از نسخه جدیدتر
2022
with:
21-
dotnet-version: |
22-
8.0.x
23-
10.0.x
23+
dotnet-version: 8.0.x # یا هر نسخه‌ای که پروژه شما نیاز دارد. اگر فقط یکی لازم است، دومی را حذف کنید.
24+
# اگر پروژه شما به 10.0.x هم نیاز دارد، آن را نگه دارید:
25+
# dotnet-version: |
26+
# 8.0.x
27+
# 10.0.x # توجه: .NET 10 هنوز منتشر نشده، احتمالا منظورتان .NET Core 3.1 یا .NET 6/7 بوده؟ یا شاید یک نسخه preview؟
2428

2529
- name: Install GitVersion
26-
uses: gittools/actions/gitversion/[email protected]
30+
uses: gittools/actions/gitversion/[email protected] # نسخه جدیدتر اکشن
31+
with:
32+
versionSpec: '5.x' # مشخص کردن نسخه GitVersion CLI
2733

28-
- name: Use GitVersion
29-
uses: gittools/actions/gitversion/[email protected]
34+
- name: Determine Version using GitVersion
35+
id: gitversion # <<<<< اضافه کردن ID برای ارجاع به خروجی
36+
uses: gittools/actions/gitversion/[email protected] # نسخه جدیدتر اکشن
3037

3138
- name: Restore dependencies
32-
run: dotnet restore
39+
# اگر فایل csproj در روت نیست، مسیر را مشخص کنید: e.g., src/MyPackage/MyPackage.csproj
40+
run: dotnet restore YourProject.csproj # <--- مسیر فایل csproj خود را جایگزین کنید
3341

3442
- name: Build
35-
run: dotnet build --configuration Release --no-restore
43+
# اگر فایل csproj در روت نیست، مسیر را مشخص کنید
44+
run: dotnet build YourProject.csproj --configuration Release --no-restore -p:Version=${{ steps.gitversion.outputs.NuGetVersionV2 }} # <--- مسیر فایل csproj و استفاده از نسخه
3645

3746
- name: Pack NuGet
47+
# اگر فایل csproj در روت نیست، مسیر را مشخص کنید
3848
run: |
39-
dotnet pack --configuration Release \
49+
dotnet pack YourProject.csproj --configuration Release \
4050
-p:PackageVersion=${{ steps.gitversion.outputs.NuGetVersionV2 }} \
41-
--no-build -o out
51+
--no-build -o ./out # <--- مسیر فایل csproj خود را جایگزین کنید
4252
4353
- name: Push to NuGet
44-
if: success()
54+
# if: success() # این شرط به طور پیش‌فرض وجود دارد، اگر مراحل قبلی موفق باشند این مرحله اجرا می‌شود
4555
run: |
46-
dotnet nuget push out/*.nupkg \
56+
dotnet nuget push ./out/*.nupkg \
4757
--api-key ${{ secrets.NUGET_API_KEY }} \
48-
--source https://api.nuget.org/v3/index.json
58+
--source https://api.nuget.org/v3/index.json \
59+
--skip-duplicate # جلوگیری از خطا در صورت وجود نسخه تکراری

0 commit comments

Comments
 (0)