-
Notifications
You must be signed in to change notification settings - Fork 3
83 lines (83 loc) · 2.27 KB
/
build.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
80
81
82
83
name: Build
on:
push:
branches:
- master
tags:
- "*"
pull_request:
jobs:
calculate-version:
runs-on: ubuntu-20.04
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.8.1"
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Version
id: version
run: |
version=${{ steps.gitversion.outputs.nuGetVersionV2 }}
if [ "${{ github.event_name }}" == "pull_request" ]
then
version=${version}-${{ steps.gitversion.outputs.shortSha }}
fi
echo "::set-output name=version::${version}"
build:
runs-on: ${{ matrix.os }}
needs: [calculate-version]
strategy:
matrix:
include:
- os: ubuntu-20.04
nugetPush: false
- os: windows-2019
nugetPush: true
- os: macos-10.15
nugetPush: false
steps:
- name: Checkout code
uses: actions/checkout@master
with:
fetch-depth: 0
submodules: recursive
- name: Setup dotnet SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.101"
- name: Build
run: |
dotnet build -c Release -p:Version=${{ needs.calculate-version.outputs.version }}
shell: bash
- name: Test
run: dotnet test -c Release --no-build
shell: bash
- name: Archive NuGet Packages
uses: actions/upload-artifact@v2
if: ${{ matrix.nugetPush }}
with:
name: packages
path: |
**/*.nupkg
**/*.snupkg
retention-days: 1
nuget-push:
runs-on: ubuntu-20.04
needs: [build]
if: github.event_name != 'pull_request'
steps:
- name: Download NuGet Packages
uses: actions/[email protected]
with:
name: packages
- name: NuGet Push
run: dotnet nuget push **/*.nupkg -s https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}