-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (84 loc) · 3.18 KB
/
Copy pathmain.yml
File metadata and controls
104 lines (84 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: CI
on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]
workflow_dispatch:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
jobs:
build-and-test:
name: Build & Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
dotnet-version: ['8.0.x', '10.0.x']
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better source link support
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run tests (coverage)
if: matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '10.0.x'
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
- name: Run tests
if: ${{ !(matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '10.0.x') }}
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '10.0.x'
uses: codecov/codecov-action@v4
with:
files: ./coverage/**/coverage.cobertura.xml
fail_ci_if_error: false
verbose: true
pack:
name: Pack NuGet Package
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Using version from tag: $VERSION"
shell: bash
- name: Restore dependencies
run: dotnet restore
- name: Build with version
run: dotnet build --configuration Release --no-restore -p:Version=${{ steps.version.outputs.VERSION }}
- name: Pack with version
run: dotnet pack src/lib/LowlandTech.TinyTools.csproj --configuration Release --no-build --output ./artifacts -p:PackageVersion=${{ steps.version.outputs.VERSION }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./artifacts/*.nupkg
retention-days: 30
- name: Publish to GitHub Packages
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/lowlandtech/index.json" --skip-duplicate
continue-on-error: true
- name: Publish to NuGet.org
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate