-
Notifications
You must be signed in to change notification settings - Fork 1
125 lines (102 loc) · 3.5 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
114
115
116
117
118
119
120
121
122
123
124
125
name: CI
defaults:
run:
shell: bash
on:
push:
branches:
- main
pull_request:
env:
CONFIGURATION: Release
jobs:
git-version:
runs-on: ubuntu-latest
outputs:
NuGetVersionV2: ${{ steps.gitversion.outputs.NuGetVersionV2 }}
MajorMinorPatch: ${{ steps.gitversion.outputs.MajorMinorPatch }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup 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
configFilePath: ${{ github.workspace }}/GitVersion.yml
build:
runs-on: ${{ matrix.os }}
needs: [ git-version ]
strategy:
fail-fast: false
matrix:
dotnet: [ "8.x" ]
os: [ ubuntu-latest, macOS-latest, windows-latest ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Install dependencies
run: dotnet tool restore && dotnet restore
- name: Build
run: |
dotnet build --no-restore \
-c ${{ env.CONFIGURATION }} \
-p:AssemblyVersion=${{ needs.git-version.outputs.MajorMinorPatch }} \
-p:PackageVersion=${{ needs.git-version.outputs.NuGetVersionV2 }} \
-p:RepositoryUrl=${{ github.repositoryUrl }}
- name: Run tests
run: |
dotnet test --no-restore --no-build \
-c ${{ env.CONFIGURATION }} \
-p:AssemblyVersion=${{ needs.git-version.outputs.MajorMinorPatch }} \
-p:PackageVersion=${{ needs.git-version.outputs.NuGetVersionV2 }} \
-p:RepositoryUrl=${{ github.repositoryUrl }}
- name: Copy packages
run: |
mkdir -p '${{ github.workspace }}/packages/${{ matrix.os }}-net${{ matrix.dotnet }}'
dotnet nuget push '${{ github.workspace }}/**/*.nupkg' -s '${{ github.workspace }}/packages/${{ matrix.os }}-net${{ matrix.dotnet }}'
- name: Prepare packages for publishing
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
retention-days: 5
name: packages-${{ matrix.os }}-net${{ matrix.dotnet }}
path: ${{ github.workspace }}/packages/**/*.nupkg
release:
runs-on: ubuntu-latest
needs: [ git-version, build ]
if: github.ref == 'refs/heads/main'
steps:
- name: Get packages for publishing
uses: actions/download-artifact@v3
id: download
with:
name: packages-ubuntu-latest-net8.x
path: packages
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
- name: Publish packages
run: dotnet nuget push ${{ github.workspace }}/packages/**/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: Create tag
id: create_tag
uses: anothrNick/github-tag-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: v${{ needs.git-version.outputs.MajorMinorPatch }}
- name: Create release
uses: ncipollo/release-action@v1
with:
name: Release ${{ needs.git-version.outputs.MajorMinorPatch }}
tag: ${{ steps.create_tag.outputs.tag }}
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true