Publish NuGet package #7
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: Publish NuGet package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| publishPreRelease: | |
| description: 'Publish pre-release' | |
| type: boolean | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v3.1.11 | |
| with: | |
| versionSpec: '6.0.x' | |
| - name: Determine version | |
| id: version_step | |
| uses: gittools/actions/gitversion/execute@v3.1.11 | |
| - name: Set package version | |
| run: | | |
| version=${{ steps.version_step.outputs.majorMinorPatch }} | |
| preRelease=${{ steps.version_step.outputs.preReleaseTag }} | |
| if [ "${{ inputs.publishPreRelease }}" == "true" ]; then | |
| echo "PACKAGE_VERSION=$version-pre.${{ steps.version_step.outputs.preReleaseNumber }}" >> $GITHUB_ENV | |
| else | |
| echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV | |
| fi | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build -c Release /p:Version=${PACKAGE_VERSION} | |
| - name: Test | |
| run: dotnet test -c Release /p:Version=${PACKAGE_VERSION} --no-restore --verbosity normal | |
| - name: Pack | |
| run: dotnet pack -c Release /p:Version=${PACKAGE_VERSION} --no-restore --output . | |
| - name: Push | |
| run: dotnet nuget push OldBit.Beep.${PACKAGE_VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} |