Merge pull request #127 from skwasjer/chore/gitversion #116
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
on: | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
pull_request: | |
name: pipeline | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_NOLOGO: true | |
dotnet-version: | | |
8.0.x | |
7.0.x | |
6.0.x | |
jobs: | |
determine-version: | |
runs-on: ubuntu-latest | |
env: | |
IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1 | |
GITVERSION: '6.0.x' | |
outputs: | |
version: ${{ steps.gitversion.outputs.fullSemVer }} | |
package-version: ${{ steps.gitversion.outputs.fullSemVer }} | |
assembly-version: ${{ steps.gitversion.outputs.assemblySemVer }} | |
file-version: ${{ steps.gitversion.outputs.assemblySemFileVer }} | |
informational-version: ${{ steps.gitversion.outputs.informationalVersion }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Install GitVersion ${{ env.GITVERSION }} | |
uses: gittools/actions/gitversion/setup@v3.1.1 | |
with: | |
versionSpec: ${{ env.GITVERSION }} | |
- name: Determine version | |
uses: gittools/actions/gitversion/execute@v3.1.1 | |
id: gitversion | |
with: | |
useConfigFile: true | |
build: | |
needs: | |
- determine-version | |
name: build (v${{ needs.determine-version.outputs.version }}) | |
runs-on: ubuntu-latest | |
env: | |
msbuild-version-args: /p:Version="${{ needs.determine-version.outputs.version }}" /p:PackageVersion="${{ needs.determine-version.outputs.package-version }}" /p:AssemblyVersion="${{ needs.determine-version.outputs.assembly-version }}" /p:FileVersion="${{ needs.determine-version.outputs.file-version }}" /p:InformationalVersion="${{ needs.determine-version.outputs.informational-version }}" | |
outputs: | |
dotnet-version: ${{ env.dotnet-version }} | |
msbuild-version-args: ${{ env.msbuild-version-args }} | |
steps: | |
# Setup | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.dotnet-version }} | |
- run: dotnet --info | |
# Checkout | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
# NuGet cache | |
- name: Restore NuGet global package cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.targets','**/*.props','**/*.csproj') }} # Can't use packages.lock.json yet, because Dependabot does not support it. | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
# Restore | |
- run: dotnet restore | |
# Build | |
- run: dotnet build --no-restore -c Release ${{ env.msbuild-version-args }} | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: | | |
*/**/bin | |
*/**/obj | |
if-no-files-found: error | |
retention-days: 7 | |
test: | |
needs: build | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-13 | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
# Setup | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.dotnet-version }} | |
# Checkout | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
# Restore build artifacts | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
# Run all tests | |
- run: dotnet test --no-restore --no-build -c Release -- xUnit.AppDomain=denied | |
if: matrix.os == 'ubuntu-latest' | |
- run: dotnet test --no-restore --no-build -c Release --filter Category!=PublicApi -- xUnit.AppDomain=denied | |
if: matrix.os != 'ubuntu-latest' | |
pack: | |
needs: | |
- determine-version | |
- build | |
runs-on: ubuntu-latest | |
steps: | |
# Setup | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.dotnet-version }} | |
# Checkout | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
# NuGet cache (.NET Framework Reference assemblies are needed for pack) | |
- name: Restore NuGet global package cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.targets','**/*.props','**/*.csproj') }} # Can't use packages.lock.json yet, because Dependabot does not support it. | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
fail-on-cache-miss: true | |
# Restore build artifacts | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
# Pack | |
- run: dotnet pack --no-restore --no-build -c Release ${{ needs.build.outputs.msbuild-version-args }} | |
- name: Upload release artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-${{ needs.determine-version.outputs.package-version }} | |
path: | | |
**/*.*nupkg | |
if-no-files-found: error | |
retention-days: 90 | |
deploy: | |
needs: | |
- determine-version | |
- test | |
- pack | |
if: github.event_name == 'release' | |
environment: production | |
runs-on: ubuntu-latest | |
steps: | |
# Restore release artifacts | |
- name: Download release artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: release-${{ needs.determine-version.outputs.package-version }} | |
- name: push - nuget.org | |
env: | |
NUGET_SOURCE_URL: https://api.nuget.org/v3/index.json | |
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s ${{ env.NUGET_SOURCE_URL }} |