Skip to content

working-directory

working-directory #22

Workflow file for this run

name: .NET Build, Test, and Validate & Publish Nuget Package
on:
push:
branches:
- "**"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches:
- "**"
env:
NuGetArtifactName: "NuGet package"
NuGetDirectory: ${{ github.workspace }}/nupkgs
NuGetVersion: 0.0.0
jobs:
build_test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8"
- name: Build
run: dotnet build
working-directory: "Jvw.DevToys.SemverCalculator"
- name: Test
run: dotnet test --no-build
working-directory: "Jvw.DevToys.SemverCalculator"
nuget_pack:
name: Pack NuGet package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8"
- name: Set version variable
if: ${{ github.ref_type == 'tag' }}
env:
TAG: ${{ github.ref_name }}
run: echo "NuGetVersion=${TAG#v}" >> $GITHUB_ENV
- name: Pack NuGet package
run: dotnet pack --output ${{ env.NuGetDirectory }} /p:PackageVersion=$NuGetVersion
working-directory: "Jvw.DevToys.SemverCalculator"
- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
name: ${{ env.NuGetArtifactName }}
path: ${{ env.NuGetDirectory }}/*.nupkg
nuget_validate:
name: Validate NuGet package
runs-on: ubuntu-latest
needs: [nuget_pack]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8"
- name: Install nuget validator
run: dotnet tool install Meziantou.Framework.NuGetPackageValidation.Tool --global
- uses: actions/download-artifact@v4
with:
name: ${{ env.NuGetArtifactName }}
path: ${{ env.NuGetDirectory }}
- name: Validate package
shell: pwsh
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")
nuget_publish:
name: Publish NuGet package
runs-on: ubuntu-latest
needs: [nuget_validate, build_test]
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8"
- uses: actions/download-artifact@v4
with:
name: ${{ env.NuGetArtifactName }}
- name: Publish NuGet package
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg -k ${{ secrets.NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json