-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (98 loc) · 3.47 KB
/
Copy pathci.yml
File metadata and controls
119 lines (98 loc) · 3.47 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NUGET_DIRECTORY: ${{ github.workspace }}/nuget
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal --logger "console;verbosity=detailed" --collect:"XPlat Code Coverage"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: '**/coverage.cobertura.xml'
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
pack:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Get version
id: version
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
VERSION=1.0.0-${BRANCH_NAME}-${GITHUB_SHA::7}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Restore dependencies
run: dotnet restore
- name: Build and Pack
run: |
dotnet build --configuration Release --no-restore
dotnet pack --configuration Release --no-build /p:Version=${{ steps.version.outputs.VERSION }} --output ${{ env.NUGET_DIRECTORY }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NUGET_DIRECTORY }}/*.nupkg
publish-preview:
runs-on: ubuntu-latest
needs: pack
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
permissions:
packages: write
contents: read
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NUGET_DIRECTORY }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Publish to GitHub Packages
run: |
for file in ${{ env.NUGET_DIRECTORY }}/*.nupkg
do
dotnet nuget push "$file" --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate
done
- name: Publish to NuGet.org (Preview)
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
continue-on-error: true
run: |
if [ -n "${{ secrets.NUGET_API_KEY }}" ]; then
for file in ${{ env.NUGET_DIRECTORY }}/*.nupkg
do
dotnet nuget push "$file" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
done
else
echo "NUGET_API_KEY not set, skipping NuGet.org publish"
fi