-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (96 loc) · 3.46 KB
/
ci.yaml
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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full depth (not shallow) for GitVersion and better relevancy of Sonar analysis
- name: Set up GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: 6.x
- name: Execute GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
additionalArguments: /updateprojectfiles
- name: Use .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
# Begin ci-build.ps1
- name: dotnet restore
run: dotnet restore
- name: dotnet build
run: dotnet build -c release --no-restore
- name: dotnet pack
run: dotnet pack -c release --no-build
# End ci-build.ps1
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: actions/upload-artifact@v4
id: nupkg-upload-step
with:
name: nupkg
path: artifacts/package/release/${{ github.event.repository.name }}.${{ env.GitVersion_SemVer }}.nupkg
if-no-files-found: error
retention-days: 1 # Minimal retention b/c only needed for job passing; release manager uploads the same artifact
compression-level: 0 # NuGet pack already compresses so do not re-compress? (Not confirmed)
publish:
name: Publish
needs: Build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: nupkg
path: nupkg
- name: Set up GitReleaseManager
uses: gittools/actions/gitreleasemanager/[email protected]
with:
versionSpec: '0.18.x'
- name: Set nupkg path (GitVersion-ed)
run: |
echo 'NUPKG_PATH=nupkg/${{ github.event.repository.name }}.${{ env.GitVersion_SemVer }}.nupkg' >> "$GITHUB_ENV"
- name: TESTING
run: ls -R nupkg
- name: dotnet nuget push
if: ${{ github.ref == 'refs/heads/main' }}
run: >-
dotnet nuget push ${{ env.NUPKG_PATH }}
--api-key $NUGET_AUTH_TOKEN
--no-symbols
--skip-duplicate
--source https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_AUTH_TOKEN }}
- uses: gittools/actions/gitreleasemanager/[email protected]
if: ${{ github.ref == 'refs/heads/main' }}
name: Create release with GitReleaseManager
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
repository: ${{ github.event.repository.name }}
milestone: ${{ env.GitVersion_SemVer }}
name: v${{ env.GitVersion_SemVer }}
assets: |
${{ env.NUPKG_PATH }}
- uses: gittools/actions/gitreleasemanager/[email protected]
if: ${{ github.ref == 'refs/heads/main' }}
name: Publish release with GitReleaseManager
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
repository: ${{ github.event.repository.name }}
milestone: ${{ env.GitVersion_SemVer }}