[WIP] Fix nuget push error for missing .nupkg file (#237) #13
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: NuGet | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| pack: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Restore | |
| run: dotnet restore src/NLog.MailKit.sln | |
| - name: Build | |
| run: dotnet build src/NLog.MailKit.sln --configuration Release --no-restore | |
| - name: Determine version suffix | |
| id: version | |
| shell: bash | |
| run: | | |
| if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then | |
| echo "suffix=" >> $GITHUB_OUTPUT | |
| else | |
| CLEAN=$(echo "$GITHUB_REF_NAME" | sed 's/[^a-zA-Z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//;s/-$//') | |
| echo "suffix=$CLEAN" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Pack | |
| shell: bash | |
| run: | | |
| VERSION_SUFFIX="${{ steps.version.outputs.suffix }}" | |
| if [ -n "$VERSION_SUFFIX" ]; then | |
| dotnet pack src/NLog.MailKit.sln --no-build --configuration Release --output artifacts --version-suffix "$VERSION_SUFFIX" | |
| else | |
| dotnet pack src/NLog.MailKit.sln --no-build --configuration Release --output artifacts | |
| fi | |
| - name: Upload nuget package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nupkg | |
| path: artifacts/*pkg | |
| - name: NuGet login | |
| if: github.ref == 'refs/heads/master' | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push to NuGet.org | |
| if: github.ref == 'refs/heads/master' | |
| shell: bash | |
| run: dotnet nuget push artifacts/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |