fix: Use dotnet workload restore for all required workloads #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Nome del workflow visualizzato su GitHub | |
| name: Build and Publish Libraries | |
| # --- Trigger --- | |
| # Elenco degli eventi che attivano questo workflow | |
| on: | |
| push: | |
| branches: | |
| - main # Si attiva a ogni push sul branch 'main' | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+' # Si attiva quando viene pushato un tag come 'v1.0.0' | |
| pull_request: | |
| branches: | |
| - main # Si attiva quando viene aperta/aggiornata una PR verso 'main' | |
| workflow_dispatch: # Permette di avviare il workflow manualmente dalla UI di GitHub | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Richiesto per creare una GitHub Release | |
| steps: | |
| # 1. Scarica il codice del repository | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2. Installa la versione specificata di .NET | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' # Assicurati che corrisponda alla versione del tuo progetto | |
| # --- Esegui i comandi sulla soluzione dedicata alle librerie --- | |
| # 3. Ripristina le dipendenze NuGet dei progetti nella soluzione delle librerie | |
| - name: Restore dependencies | |
| run: dotnet restore Lifter.Libraries.sln | |
| # 4. Compila la soluzione delle librerie in configurazione Release | |
| - name: Build | |
| run: dotnet build Lifter.Libraries.sln --no-restore --configuration Release | |
| # 5. Esegue i test dei progetti nella soluzione delle librerie | |
| - name: Run tests | |
| run: dotnet test Lifter.Libraries.sln --no-build --configuration Release --verbosity normal | |
| # --- Pubblicazione --- | |
| # I seguenti passaggi vengono eseguiti SOLO se il workflow | |
| # è stato attivato dal push di un tag (es. v1.2.3) | |
| # 6. Crea i pacchetti NuGet per i progetti nella soluzione delle librerie | |
| - name: Pack projects | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: dotnet pack Lifter.Libraries.sln --no-build --configuration Release --output ./packages | |
| # 7. Pubblica tutti i pacchetti .nupkg creati | |
| - name: Publish to NuGet | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: dotnet nuget push "./packages/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json | |
| # 8. Crea una Release su GitHub e carica i pacchetti come artefatti | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ./packages/*.nupkg |