Deploying package to nuget #2
Workflow file for this run
This file contains 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
name: CleanArchitecture.Blazored.Deploy | |
run-name: Deploying package to nuget | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main", "ProjectStart" ] | |
workflow_run: | |
workflows: ["CleanArchitecture.Blazored.Dev", "CleanArchitecture.Blazored"] | |
types: | |
- completed | |
env: | |
NuGetDirectory: ${{github.workspace }}/nuget | |
jobs: | |
create_nuget: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .Net | |
uses: actions/[email protected] | |
with: | |
dotnet-version: 8.x | |
- name: Restore dependencies | |
run: dotnet restore CleanArchitecture.Blazored.Dev.sln | |
- name: Build solution | |
run: dotnet build --no-restore CleanArchitecture.Blazored.Dev.sln -c Release | |
- name: Pack Nuget package | |
run: dotnet pack CleanArchitecture.Blazored.csproj --configuration Release --output ${{ env.NuGetDirectory }} | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: nuget | |
if-no-files-found: error | |
retention-days: 7 | |
path: ${{ env.NuGetDirectory }}/*.nupkg | |
validate_nuget: | |
runs-on: ubuntu-latest | |
needs: | |
- create_nuget | |
steps: | |
- name: Setup .NET | |
uses: actions/[email protected] | |
with: | |
dotnet-version: 8.x | |
- uses: actions/download-artifact@v3 | |
with: | |
name: nuget | |
path: ${{ env.NuGetDirectory }} | |
- name: Install nuget validator | |
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global | |
- name: Validate package | |
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg | |
deploy: | |
if: github.event_name =='release' | |
runs-on: ubuntu-latest | |
needs: | |
- validate_nuget | |
steps: | |
- uses: actions/download-artifcat@v3 | |
with: | |
name: nuget | |
path: ${{ env.NuGetDirectory }} | |
- name: Setup .NET | |
uses: actions/[email protected] | |
with: | |
dotnet-version: 8.x | |
- name: Publish Nuget package | |
run: | | |
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" - Recurse -Include *.nupkg)){ | |
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }} --source https://api/nuget.org/v3/index.json --skip-duplicate | |
} |