Skip to content

validate_nuget

validate_nuget #11

Workflow file for this run

name: .NET Build, Test, and Publish Nuget Package
on:
push:
branches:
- "**"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches:
- "**"
env:
VERSION: 0.0.0
NuGetDirectory: ${{ github.workspace}}/nupkgs
NuGetArtifactName: "NuGet package"
defaults:
run:
working-directory: "Jvw.DevToys.SemverCalculator"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set version variable
if: ${{ github.ref_type == 'tag' }}
env:
TAG: ${{ github.ref_name }}
run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8"
- name: Build
run: dotnet build /p:Version=$VERSION
- name: Test
run: dotnet test --no-build
- name: Pack NuGet package
run: dotnet pack --output ${{ env.NuGetDirectory }} /p:PackageVersion=$VERSION
- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
name: ${{ env.NuGetArtifactName }}
path: ${{ env.NuGetDirectory }}/*.nupkg
- name: Publish NuGet package
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg -k ${{ secrets.NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json
validate_nuget:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8"
- uses: actions/download-artifact@v4
with:
name: ${{ env.NuGetArtifactName }}
path: ${{ env.NuGetDirectory }}
- name: Install nuget validator
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
# Validate metadata and content of the NuGet package
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
# If some rules are not applicable, you can disable them
# using the --excluded-rules or --excluded-rule-ids option
- name: Validate package
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")