Skip to content

Merge pull request #411 from maxmind/dependabot/github_actions/zizmor… #69

Merge pull request #411 from maxmind/dependabot/github_actions/zizmor…

Merge pull request #411 from maxmind/dependabot/github_actions/zizmor… #69

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@baa11fbfe1d6520db94683bd5c7a3818018e4309 # v5.1.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
env:
MAXMIND_TEST_BASE_DIR: ${{ github.workspace }}/MaxMind.GeoIP2.UnitTests
- name: Pack
run: dotnet pack -c Release MaxMind.GeoIP2/MaxMind.GeoIP2.csproj
- name: Upload artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: nuget-packages
path: MaxMind.GeoIP2/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@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
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 }}