Skip to content

Merge pull request #392 from maxmind/dependabot/github_actions/NuGet/… #142

Merge pull request #392 from maxmind/dependabot/github_actions/NuGet/…

Merge pull request #392 from maxmind/dependabot/github_actions/NuGet/… #142

Workflow file for this run

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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
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
- name: Pack
run: dotnet pack -c Release MaxMind.MinFraud/MaxMind.MinFraud.csproj
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: nuget-packages
path: MaxMind.MinFraud/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@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: nuget-packages
path: packages
- name: NuGet login
id: login
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # 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 }}