build: update .NET SDK
from 8.0.400 to 8.0.401
#245
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
name: "Library" | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "*/**.cs" | |
- "*/**.csproj" | |
- ".editorconfig" | |
- "*.props" | |
- "global.json" | |
- "nuget.config" | |
- "*.sln" | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
pull_request: | |
paths: | |
- "*/**.cs" | |
- "*/**.csproj" | |
- ".editorconfig" | |
- "*.props" | |
- "global.json" | |
- "nuget.config" | |
- "*.sln" | |
concurrency: | |
group: "${{ github.workflow }}-${{ github.ref }}" | |
cancel-in-progress: true | |
env: | |
RELEASE_NAME: "${{ github.ref_name }}" | |
NUGET_OUTPUT_DIRECTORY: "./artifacts/package/release" | |
jobs: | |
builder: | |
name: "Builder" | |
runs-on: "${{ vars.DEFAULT_UBUNTU }}" | |
env: | |
IS_PUSH_EVENT_TO_MAIN_BRANCH: "${{ github.event_name == 'push' && contains(github.ref, 'refs/heads/main') }}" | |
IS_RELEASE: "${{ startsWith(github.ref, 'refs/tags/v') && github.actor == github.repository_owner }}" | |
BUILD_CONFIGURATION: "Release" | |
steps: | |
- name: "Set up repository with all history" | |
uses: "actions/[email protected]" | |
with: | |
fetch-depth: 0 | |
- name: "Set up .NET SDK" | |
uses: "actions/[email protected]" | |
- name: "Restore dependencies" | |
run: "dotnet restore" | |
- name: "Get all changed files" | |
id: "csharp-files" | |
uses: "tj-actions/[email protected]" | |
with: | |
files: "**/*.cs" | |
- name: "Run formatter for all changed files" | |
if: "${{ steps.csharp-files.outputs.any_changed == vars.POSITIVE }}" | |
run: | | |
dotnet format \ | |
--include ${{ steps.csharp-files.outputs.all_changed_files }} \ | |
--no-restore \ | |
--verify-no-changes | |
- name: "Build artifacts" | |
run: | | |
dotnet build \ | |
--no-restore \ | |
--configuration '${{ env.BUILD_CONFIGURATION }}' | |
- name: "Run tests" | |
run: | | |
dotnet test \ | |
--no-build \ | |
--configuration '${{ env.BUILD_CONFIGURATION }}' \ | |
-property:'CollectCoverage=${{ env.IS_PUSH_EVENT_TO_MAIN_BRANCH }}' | |
- name: "Upload coverage results" | |
if: "${{ env.IS_PUSH_EVENT_TO_MAIN_BRANCH == vars.POSITIVE }}" | |
uses: "codecov/[email protected]" | |
with: | |
directory: "./artifacts/coverage" | |
files: "*.xml" | |
fail_ci_if_error: true | |
token: "${{ secrets.CODECOV_TOKEN }}" | |
- name: "Build packages" | |
if: "${{ env.IS_RELEASE == vars.POSITIVE }}" | |
run: | | |
dotnet pack \ | |
--no-build \ | |
--configuration '${{ env.BUILD_CONFIGURATION }}' \ | |
-property:"PackageVersion=${GITHUB_REF_NAME#v}" \ | |
-property:'PackageReleaseNotes=Please see ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}' | |
- name: "Upload artifacts" | |
uses: "actions/[email protected]" | |
if: "${{ env.IS_RELEASE == vars.POSITIVE }}" | |
with: | |
name: "${{ env.RELEASE_NAME }}" | |
path: | | |
${{ env.NUGET_OUTPUT_DIRECTORY }} | |
global.json | |
nuget.config | |
publisher: | |
name: "Publisher" | |
needs: "builder" | |
if: "${{ startsWith(github.ref, 'refs/tags/v') && github.actor == github.repository_owner }}" | |
runs-on: "${{ vars.DEFAULT_UBUNTU }}" | |
env: | |
NUGET_SEARCH_PATTERN: "*.nupkg" | |
steps: | |
- name: "Download artifacts" | |
uses: "actions/[email protected]" | |
with: | |
name: "${{ env.RELEASE_NAME }}" | |
- name: "Set up .NET SDK" | |
uses: "actions/[email protected]" | |
- name: "Publish packages" | |
run: | | |
dotnet nuget push '${{ env.NUGET_OUTPUT_DIRECTORY }}/${{ env.NUGET_SEARCH_PATTERN }}' \ | |
--source 'nuget' \ | |
--api-key '${{ secrets.NUGET_TOKEN }}' \ | |
--skip-duplicate | |
dotnet nuget push '${{ env.NUGET_OUTPUT_DIRECTORY }}/${{ env.NUGET_SEARCH_PATTERN }}' \ | |
--source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' \ | |
--api-key '${{ secrets.GITHUB_TOKEN }}' \ | |
--skip-duplicate | |
- name: "Publish release" | |
uses: "softprops/[email protected]" | |
with: | |
generate_release_notes: true | |
files: "${{ env.NUGET_OUTPUT_DIRECTORY }}/*" |