v1.0.0 #29
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: "Build" | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- "**/*.md" | |
- "**/*.gitignore" | |
- "**/*.gitattributes" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
actions: read | |
checks: write | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
DOTNET_GENERATE_ASPNET_CERTIFICATE: false | |
DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false | |
DOTNET_MULTILEVEL_LOOKUP: 0 | |
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true | |
TERM: xterm | |
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
dotnet-quality: ga | |
cache: true | |
cache-dependency-path: "**/packages.lock.json" | |
- name: Restore packages | |
run: dotnet restore --locked-mode | |
- name: Restore local tools | |
run: dotnet tool restore | |
- name: Build | |
run: dotnet build --configuration Release --no-restore | |
- name: Test | |
run: dotnet test --logger trx --collect:"XPlat Code Coverage" | |
- name: Create check run with test report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: Tests | |
path: ClockifyExport.Tests/TestResults/*.trx | |
reporter: dotnet-trx | |
- name: Generate code coverage report | |
run: dotnet reportgenerator -reports:ClockifyExport.Tests/TestResults/*/coverage.cobertura.xml -targetdir:./coverage -reporttypes:MarkdownSummary | |
- name: Create check run with code coverage report | |
uses: LouisBrunner/[email protected] | |
if: always() | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Code coverage | |
conclusion: ${{ job.status }} | |
output: '{"summary":"Code coverage"}' | |
output_text_description_file: coverage/Summary.md | |
- name: Check for tag in current commit | |
run: echo "tag=$(git describe --tags --abbrev=0 --match 'v*' --exact-match)" >> "$GITHUB_ENV" | |
- name: Create NuGet package | |
if: startsWith(env.tag, 'v') | |
run: dotnet pack --configuration Release --no-build | |
- name: Publish NuGet package | |
if: startsWith(env.tag, 'v') | |
run: dotnet nuget push nupkg/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://nuget.org | |
- name: Create GitHub release | |
if: startsWith(env.tag, 'v') | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ env.tag }} | |
run: gh release create "$tag" nupkg/*.nupkg --generate-notes |