Improve release script reliability (ENG-1733) #18
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 to NuGet | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| release: | |
| types: | |
| - published | |
| permissions: {} | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| persist-credentials: false | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| - name: Build | |
| run: dotnet build -c Release | |
| - name: Run tests | |
| run: dotnet test -c Release | |
| env: | |
| MAXMIND_TEST_BASE_DIR: ${{ github.workspace }}/MaxMind.Db.Test | |
| - name: Pack | |
| run: dotnet pack -c Release MaxMind.Db/MaxMind.Db.csproj | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: nuget-packages | |
| path: MaxMind.Db/bin/Release/*.nupkg | |
| publish: | |
| needs: build | |
| runs-on: windows-latest | |
| environment: nuget | |
| permissions: | |
| id-token: write | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: nuget-packages | |
| path: packages | |
| - name: NuGet login | |
| id: login | |
| uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1 | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push to NuGet | |
| run: | | |
| foreach ($file in Get-ChildItem packages/*.nupkg) { | |
| dotnet nuget push $file.FullName --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json | |
| } | |
| env: | |
| NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }} |