Switch to codecov #25
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
--- | |
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
permissions: | |
pull-requests: write | |
contents: read | |
name: .NET Build (CziShrink) | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
workflow_dispatch: {} | |
jobs: | |
build: | |
defaults: | |
run: | |
working-directory: czishrink | |
name: ${{matrix.config.name}} | |
runs-on: ${{matrix.config.os}} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: windows, | |
os: windows-latest, | |
osfamily: win, | |
} | |
- { | |
name: ubuntu, | |
os: ubuntu-latest, | |
osfamily: linux, | |
} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.0.x | |
- name: Get Version from Directory.Build.props | |
id: getversion | |
run: | | |
$xml = [xml](Get-Content -Path "Directory.Build.props") | |
$version = $xml.SelectSingleNode('//VersionPrefix').'#text' + "-" + $xml.SelectSingleNode('//VersionSuffix').'#text' | |
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
shell: pwsh | |
- name: Add build ID to version in Directory.Build.props | |
run: | | |
Write-Output "Add build ID ${{ github.run_id }} to VersionSuffix in Directory.Build.props" | |
$file = Get-Item "Directory.Build.props" | |
$xml = [xml](Get-Content -Path $file.FullName) | |
$versionElement = $xml.SelectSingleNode('//VersionSuffix') | |
$versionElement.'#text' += '+${{ github.run_id }}' | |
$xml.Save($file.FullName) | |
shell: pwsh | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore -c Debug | |
- name: Test | |
run: > | |
dotnet test | |
-c Debug | |
--no-build | |
--verbosity normal | |
--logger trx | |
--results-directory "TestResults" | |
-p:CollectCoverage=true | |
-p:CoverletOutputFormat=cobertura | |
-p:CoverletOutput=${{ github.workspace }}/TestResults/coverage.cobertura.xml | |
-p:ExcludeByAttribute=GeneratedCodeAttribute%2cObsoleteAttribute | |
-p:ExcludeByFile=**/*.axaml%2c**/*.g.cs | |
-p:Exclude='[netczicompress]netczicompress.Views.*' | |
- name: Upload coverage reports for czishrink to Codecov | |
if: matrix.config.name == 'ubuntu' | |
uses: codecov/codecov-action@v3 | |
with: | |
fail_ci_if_error: true | |
directory: ${{ github.workspace }}/TestResults | |
files: coverage.cobertura.xml | |
verbose: true | |
- name: Upload dotnet test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dotnet-results-${{ matrix.config.name }} | |
path: TestResults | |
# Use always() to also publish test results when there are test failures | |
if: ${{ always() }} | |
- name: Publish | |
if: github.event_name == 'push' | |
run: > | |
dotnet publish netczicompress.Desktop/netczicompress.Desktop.csproj | |
-c Release | |
-a x64 | |
--self-contained | |
-p:PublishSingleFile=true | |
-p:PublishReadyToRun=true | |
-p:PublishReadyToRunShowWarnings=true | |
-o ${{ github.workspace }}/publish | |
- name: Upload published binaries | |
uses: actions/upload-artifact@v3 | |
if: github.event_name == 'push' | |
with: | |
name: CziShrink_${{ steps.getversion.outputs.version }}_${{ matrix.config.osfamily}}-x64 | |
path: publish |