global #89
This file contains 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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: .NET | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
jobs: | |
build: | |
name: .NET | |
runs-on: windows-latest | |
env: | |
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
OUTPUT_PATH: output | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
- name: Cache NuGet | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('Directory.Packages.props') }} #hash of project files | |
restore-keys: ${{ runner.os }}-nuget- | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build (Debug) | |
run: dotnet build --no-restore | |
- name: Test (Debug) | |
run: dotnet test --no-build --verbosity normal | |
- name: Build (Release) | |
run: dotnet build --configuration Release --no-restore | |
- name: Pack (Release) | |
run: dotnet pack --configuration Release --no-build --output ${{ env.OUTPUT_PATH }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ github.event.repository.name }}.nupkg | |
path: ${{ env.OUTPUT_PATH }}/*.*nupkg | |
publish: | |
name: Publish to NuGet | |
if: ${{ github.event_name == 'release' }} | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
- name: Download Package artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ github.event.repository.name }}.nupkg | |
- name: Upload Release Assets | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: "*.nupkg" | |
- name: Publish to Nuget | |
run: 'dotnet nuget push "*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_KEY }} --skip-duplicate' |