Skip to content

readme

readme #3

Workflow file for this run

name: .NET
on:
push:
branches: [ "master", "workflows" ]
pull_request:
branches: [ "master" ]
env:
DOTNET_VERSION: '8.0.x'
jobs:
build:
runs-on: ubuntu-latest
outputs:
semVer: ${{ steps.gitversion.outputs.SemVer }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.11
with:
versionSpec: '5.x'
- name: Calculate version with GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.11
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build project
run: dotnet build --no-restore --configuration Release
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
**/bin
**/obj
test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Run tests
run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test_results.xml"
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: "**/TestResults"
nuget:
if: github.event_name == 'push'
needs: [build, test]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Create NuGet package
run: dotnet pack --no-build --configuration Release /p:PackageVersion=${{ needs.build.outputs.semVer }} --output ./nupkgs
- name: Push NuGet package
run: |
dotnet nuget push -k ${{ secrets.GITHUB_TOKEN }} -s "https://nuget.pkg.github.com/${{ github.actor }}/index.json" ./nupkgs/*.nupkg
dotnet nuget push -k ${{ secrets.GITHUB_TOKEN }} -s "https://nuget.pkg.github.com/${{ github.actor }}/index.json" ./nupkgs/*.snupkg
release:
if: github.event_name == 'push'
needs: [build, test, nuget]
runs-on: ubuntu-latest
steps:
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.semVer }}
release_name: Release ${{ needs.build.outputs.semVer }}
draft: false
prerelease: false