Moved publish.yml to workflows directory #1
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
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: Publish Packages | |
| on: | |
| workflow_dispatch: # Allow running the workflow manually from the GitHub UI | |
| push: | |
| branches: | |
| - 'main' # Run the workflow when pushing to the main branch | |
| pull_request: | |
| branches: | |
| - '*' # Run the workflow for all pull requests | |
| release: | |
| types: | |
| - published # Run the workflow when a new GitHub release is published | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
| DOTNET_NOLOGO: true | |
| defaults: | |
| run: | |
| shell: pwsh | |
| jobs: | |
| Build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Install the .NET SDK indicated in the global.json file | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # Restore packages dependencies | |
| - name: Install dependencies | |
| run: dotnet restore | |
| # Build packages | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| Deploy: | |
| # Publish only when creating a GitHub Release | |
| # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository | |
| # You can update this logic if you want to manage releases differently | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| needs: [ Build ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| # Restore packages dependencies | |
| - name: Install dependencies | |
| run: dotnet restore | |
| # Build packages | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| # Publish packages | |
| - name: Publish package | |
| run: dotnet pack --configuration Release --no-build --no-restore | |
| - name: Push to NuGet | |
| run: dotnet nuget push *.nupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate |