Update README with NuGet badge, more examples, and options table #3
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 | |
| on: | |
| pull_request: | |
| branches: | |
| - '*' | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build: | |
| name: Build & Pack | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Extract version from tag | |
| id: version | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
| VERSION="${{ github.ref_name }}" | |
| VERSION="${VERSION#v}" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "IS_RELEASE=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "VERSION=1.0.0" >> $GITHUB_OUTPUT | |
| echo "IS_RELEASE=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build | |
| run: dotnet build -c Release -p:Version=${{ steps.version.outputs.VERSION }} | |
| - name: Pack | |
| run: dotnet pack -c Release -p:Version=${{ steps.version.outputs.VERSION }} --output ./nupkgs | |
| - name: Upload NuGet package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget | |
| path: ./nupkgs/*.nupkg | |
| - name: Publish to NuGet | |
| if: github.repository_owner == 'Hymma' && startsWith(github.ref, 'refs/tags/v') | |
| run: dotnet nuget push ./nupkgs/*.nupkg --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| generate_release_notes: true | |
| files: ./nupkgs/*.nupkg | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |