Modernize #58
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
CONFIGURATION: Release | |
# Directories | |
OUTPUT_DIR: output | |
TEMP_DIR: temp | |
TEST_RESULTS_DIR: ./output/test-results | |
REPORTS_DIR: ./output/reports | |
COVERAGE_REPORT_DIR: ./output/reports/coverage-report | |
COVERAGE_HISTORY_DIR: ./temp/coverage-history | |
REPOSITORY_NAME: ${{ github.event.repository.name }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
global-json-file: global.json | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
with: | |
useConfigFile: true | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: | | |
dotnet build --no-restore \ | |
/property:ContinuousIntegrationBuild=True \ | |
/property:DeterministicSourcePaths=True \ | |
/property:RepositoryUrl=https://github.com/${{ github.repository }} \ | |
/property:AssemblyVersion=${{ env.GitVersion_AssemblySemVer }} \ | |
/property:FileVersion=${{ env.GitVersion_AssemblySemFileVer }} \ | |
/property:InformationalVersion=${{ env.GitVersion_InformationalVersion }} | |
- name: Setup test dependencies | |
run: docker compose up -d --wait | |
- name: Test | |
run: | | |
dotnet test --no-restore --no-build \ | |
--logger "trx;LogFileName=${{ env.REPOSITORY_NAME }}.trx" \ | |
--results-directory ${{ env.TEST_RESULTS_DIR }} \ | |
--collect:"XPlat Code Coverage" \ | |
/property:CollectCoverage=True \ | |
/property:CoverletOutputFormat=opencover \ | |
/property:CoverletOutput=${{ env.TEST_RESULTS_DIR }}/${{ env.REPOSITORY_NAME }}.xml | |
- name: ReportGenerator | |
uses: danielpalme/[email protected] | |
with: | |
reports: "${{ env.TEST_RESULTS_DIR }}/**/coverag*.cobertura.xml" | |
targetdir: ${{ env.COVERAGE_REPORT_DIR }} | |
reporttypes: 'HtmlInline;Cobertura' | |
historydir: ${{ env.COVERAGE_HISTORY_DIR }} | |
- name: Upload coverage report artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: CoverageReport | |
path: ${{ env.COVERAGE_REPORT_DIR }} | |
- name: Pack | |
run: dotnet pack --no-restore --no-build -p:PackageVersion=${{ steps.gitversion.outputs.NuGetVersionV2 }} -o ./packages | |
- name: Teardown test dependencies | |
if: always() | |
run: | | |
docker compose down | |
- name: Publish packages | |
if: (github.ref == 'refs/heads/main') | |
run: dotnet nuget push ${{ github.workspace }}/packages/**/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json | |
- name: Tag published version | |
uses: actions/github-script@v7 | |
if: (github.ref == 'refs/heads/main') | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{ steps.gitversion.outputs.MajorMinorPatch }}', | |
sha: context.sha, | |
force: true | |
}) | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
if: (github.ref == 'refs/heads/main') | |
with: | |
name: Release ${{ steps.gitversion.outputs.MajorMinorPatch }} | |
tag: ${{ steps.gitversion.outputs.MajorMinorPatch }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
generateReleaseNotes: true |