Build and Publish NuGet Package #11
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
| name: Build and Publish NuGet Package | |
| on: | |
| push: | |
| branches: | |
| - test | |
| tags: | |
| - 'v*' | |
| env: | |
| DOTNET_VERSION: '8.0.x' | |
| PROJECT_PATH: 'src/Invoicetronic.Sdk/Invoicetronic.Sdk.csproj' | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore dependencies | |
| run: dotnet restore ${{ env.PROJECT_PATH }} | |
| - name: Build | |
| run: dotnet build ${{ env.PROJECT_PATH }} --configuration Release --no-restore | |
| - name: Run tests | |
| run: dotnet test --no-restore --verbosity normal | |
| - name: Pack | |
| run: dotnet pack ${{ env.PROJECT_PATH }} --configuration Release --no-build --output nupkgs | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ./nupkgs/*.nupkg | |
| generate_release_notes: true | |
| make_latest: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push to NuGet | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: dotnet nuget push ./nupkgs/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate |