# مدیریت Package های Proto در FourSat با GitLab Registry > **تاریخ**: December 6, 2025 > **NuGet Server**: GitLab Package Registry (Afrino) > **URL**: `https://git.afrino.co/api/packages/FourSat/nuget/index.json` --- ## 📊 معماری فعلی ``` ┌────────────────────────────────────────────────────┐ │ LAYER 1: CMS Proto (Base) │ │ CMSMicroservice.Protobuf │ │ Version: 0.0.142 → Auto-push به GitLab │ └─────────────────┬──────────────────────────────────┘ │ PackageReference ▼ ┌────────────────────────────────────────────────────┐ │ LAYER 2: BFF Protos │ │ BackOffice.BFF.*.Protobuf (14 packages) │ │ FrontOffice.BFF.*.Protobuf (8 packages) │ │ → Depend on: CMS Proto v0.0.x │ └─────────────────┬──────────────────────────────────┘ │ PackageReference ▼ ┌────────────────────────────────────────────────────┐ │ LAYER 3: UI Applications │ │ BackOffice UI → BackOffice.BFF Protos │ │ FrontOffice UI → FrontOffice.BFF Protos │ └────────────────────────────────────────────────────┘ ``` --- ## 🔧 تنظیمات فعلی در csproj شما از قبل این Target را دارید: ```xml $(PackageOutputPath)$(PackageId).$(Version).nupkg dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate && del "$(NugetPackagePath)" ``` ✅ **مزیت**: خودکار push می‌شه ⚠️ **نیاز**: فقط Version افزایش پیدا کنه --- ## 🚀 Workflow پیشنهادی ### حالت 1️⃣: Development (Local) ```xml ``` **مزایا**: - تغییرات بلافاصله اعمال می‌شود - نیازی به build/pack/push نیست - سرعت توسعه بالا ### حالت 2️⃣: Production (Release) ```xml ``` **مزایا**: - استقلال پروژه‌ها - Version control دقیق - امکان Rollback --- ## 📝 مثال کامل csproj ### CMSMicroservice.Protobuf.csproj ```xml net9.0 enable enable Foursat.CMSMicroservice.Protobuf 0.0.142 FourSat Team Afrino gRPC Protobuf contracts for CMS Microservice https://git.afrino.co/FourSat/cms all runtime; build; native; contentfiles; analyzers; buildtransitive $(PackageOutputPath)$(PackageId).$(Version).nupkg dotnet nuget push "$(NugetPackagePath)" --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate ``` ### BackOffice.BFF.Products.Protobuf.csproj ```xml net9.0 Foursat.BackOffice.BFF.Products.Protobuf 1.0.0 all $(PackageOutputPath)$(PackageId).$(Version).nupkg dotnet nuget push "$(NugetPackagePath)" --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate ``` --- ## 🔄 فرآیند Release جدید ### مرحله 1: افزایش Version ```bash # افزایش Patch version (0.0.142 → 0.0.143) ./bump-version.sh patch # افزایش Minor version (0.0.142 → 0.1.0) ./bump-version.sh minor # افزایش Major version (0.0.142 → 1.0.0) ./bump-version.sh major # افزایش version یک پروژه خاص ./bump-version.sh patch /path/to/Project.csproj ``` ### مرحله 2: Build & Pack (Auto-Push) ```bash # Build & Pack CMS Proto (Layer 1) cd /home/masoud/Apps/project/FourSat/CMS/src/CMSMicroservice.Protobuf dotnet pack -c Release # ✅ بعد از Pack، خودکار push می‌شه به GitLab! ``` ### مرحله 3: Update BFF Dependencies ```bash # بعد از push CMS Proto، version جدید را در BFF ها update کنید: # BackOffice.BFF.Products.Protobuf.csproj: ``` ### مرحله 4: Build & Pack BFF Protos (Layer 2) ```bash # Build & Pack همه BackOffice.BFF Protos cd /home/masoud/Apps/project/FourSat/BackOffice.BFF/src/Protobufs for dir in BackOffice.BFF.*.Protobuf; do cd "$dir" dotnet pack -c Release # ✅ Auto-push می‌شه cd .. done ``` ### مرحله 5: Update UI Dependencies ```bash # BackOffice.csproj: ``` --- ## 🛠️ Scripts خودکار ### 1. `bump-version.sh` - افزایش Version ```bash # همه Proto projects ./bump-version.sh patch # یک پروژه خاص ./bump-version.sh minor CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj ``` ### 2. `release-proto.sh` - Release کامل ```bash #!/bin/bash # 1. Bump version ./bump-version.sh patch # 2. Build & Pack (Auto-push) cd CMS/src/CMSMicroservice.Protobuf dotnet pack -c Release # 3. Commit changes git add . git commit -m "chore: bump proto version" git push ``` --- ## 📊 Version Strategy ``` 0.0.142 → Current CMS Proto version │ │ │ │ │ └── PATCH: Bug fixes, compatible changes │ └───── MINOR: New features, compatible └────── MAJOR: Breaking changes ``` **مثال**: - اضافه کردن فیلد جدید → **PATCH** (0.0.143) - اضافه کردن RPC جدید → **MINOR** (0.1.0) - تغییر signature RPC → **MAJOR** (1.0.0) --- ## 🔍 بررسی Packages روی GitLab ```bash # اضافه کردن GitLab source dotnet nuget add source https://git.afrino.co/api/packages/FourSat/nuget/index.json \ --name foursat-gitlab \ --username YOUR_USERNAME \ --password 061a5cb15517c6da39c16cfce8556c55ae104d0d \ --store-password-in-clear-text # جستجو dotnet nuget search Foursat --source foursat-gitlab # نصب dotnet add package Foursat.CMSMicroservice.Protobuf --version 0.0.142 --source foursat-gitlab ``` --- ## ⚙️ nuget.config (Optional) ```xml ``` --- ## 🎯 خلاصه ✅ **Development** → Debug build → `ProjectReference` → سرعت بالا ✅ **Production** → Release build → `PackageReference` → استقلال ✅ **Auto-Push** → بعد از Pack خودکار به GitLab می‌ره ✅ **Version Bump** → با `bump-version.sh` خودکار ✅ **Rollback** → برگشت به version قبلی ساده --- **تاریخ**: December 6, 2025 **NuGet Registry**: GitLab (Afrino) **Current CMS Version**: 0.0.142