-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (75 loc) · 2.34 KB
/
ci.yml
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
name: ci
on:
push:
branches: [ "main" ]
paths: [ "src/**/*.cs" ]
defaults:
run:
shell: pwsh
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
BUILD_NUGET_OUTPUTDIRECTORY: ${{ github.workspace}}/nuget
jobs:
build:
runs-on: ubuntu-latest
outputs:
fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Pack
run: dotnet pack --configuration Release --no-restore --output ${{ env.BUILD_NUGET_OUTPUTDIRECTORY }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: package
if-no-files-found: error
retention-days: 0
path: ${{ env.BUILD_NUGET_OUTPUTDIRECTORY }}/**.*nupkg
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
needs: [ build ]
steps:
- uses: actions/download-artifact@v4
with:
name: package
path: ${{ env.BUILD_NUGET_OUTPUTDIRECTORY }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Publish
run: |
Get-ChildItem "${{ env.BUILD_NUGET_OUTPUTDIRECTORY }}" -Recurse -Include *.nupkg | ForEach-Object {
dotnet nuget push $_ --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}
- name: Create release
env:
CREATERELEASE_FULLSEMVER: ${{ needs.build.outputs.fullSemVer }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v$env:CREATERELEASE_FULLSEMVER" --generate-notes --repo="$env:GITHUB_REPOSITORY"