1- # This workflow will build a .NET project
2- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3-
4- name : lowlandtech/tinytools
1+ name : CI
52
63on :
74 push :
85 branches : [ "main" ]
96 pull_request :
107 branches : [ "main" ]
8+ workflow_dispatch :
9+
10+ env :
11+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
12+ DOTNET_CLI_TELEMETRY_OPTOUT : true
13+ DOTNET_NOLOGO : true
1114
1215jobs :
13- build :
16+ build-and-test :
17+ name : Build & Test
18+ runs-on : ${{ matrix.os }}
19+ strategy :
20+ fail-fast : false
21+ matrix :
22+ os : [ubuntu-latest, windows-latest, macos-latest]
23+ dotnet-version : ['8.0.x', '9.0.x']
24+
25+ steps :
26+ - name : Checkout code
27+ uses : actions/checkout@v4
28+ with :
29+ fetch-depth : 0 # Full history for better source link support
30+
31+ - name : Setup .NET SDK
32+ uses : actions/setup-dotnet@v4
33+ with :
34+ dotnet-version : ${{ matrix.dotnet-version }}
35+
36+ - name : Restore dependencies
37+ run : dotnet restore
38+
39+ - name : Build
40+ run : dotnet build --configuration Release --no-restore
41+
42+ - name : Run tests
43+ run : dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
44+
45+ - name : Upload coverage to Codecov
46+ if : matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '9.0.x'
47+ uses : codecov/codecov-action@v4
48+ with :
49+ files : ./coverage/**/coverage.cobertura.xml
50+ fail_ci_if_error : false
51+ verbose : true
1452
53+ pack :
54+ name : Pack NuGet Package
1555 runs-on : ubuntu-latest
16-
56+ needs : build-and-test
57+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
58+
1759 steps :
18- - uses : actions/checkout@v3
19- - name : Setup .NET
20- uses : actions/setup-dotnet@v3
60+ - name : Checkout code
61+ uses : actions/checkout@v4
62+ with :
63+ fetch-depth : 0
64+
65+ - name : Setup .NET SDK
66+ uses : actions/setup-dotnet@v4
2167 with :
22- dotnet-version : 7.0.x
68+ dotnet-version : ' 9.0.x'
69+
2370 - name : Restore dependencies
2471 run : dotnet restore
72+
2573 - name : Build
26- run : dotnet build --no-restore
27- - name : Test
28- run : dotnet test --configuration Release
74+ run : dotnet build --configuration Release --no-restore
75+
2976 - name : Pack
30- run : dotnet pack src/lowlandtech.tinytools/LowlandTech.TinyTools.csproj -c Release
31- - name : Publish to GitHub packages
32- run : dotnet nuget push src/lowlandtech.tinytools/bin/Release/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "lowlandtech" --skip-duplicate
77+ run : dotnet pack src/lowlandtech.tinytools/LowlandTech.TinyTools.csproj --configuration Release --no-build --output ./artifacts
78+
79+ - name : Upload artifacts
80+ uses : actions/upload-artifact@v4
81+ with :
82+ name : nuget-packages
83+ path : ./artifacts/*.nupkg
84+ retention-days : 7
85+
86+ - name : Publish to GitHub Packages
87+ run : dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/lowlandtech/index.json" --skip-duplicate
88+ continue-on-error : true
0 commit comments