-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (57 loc) · 2.07 KB
/
build.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
name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
6.x.x
7.x.x
- name: Calculate Version Parameters
id: version
run: |
build=${{github.run_number}}
template=`cat ./VERSION`
shortsha=$(git rev-parse --short ${{ github.sha }})
echo "template=$template" >> $GITHUB_OUTPUT
echo "template=$template"
echo "shortsha=$shortsha" >> $GITHUB_OUTPUT
echo "shortsha=$shortsha"
echo "semver=${template//build/$build}+sha.$shortsha" >> $GITHUB_OUTPUT
echo "semver=${template//build/$build}+sha.$shortsha"
echo "msver=${template//build/$build}.0" >> $GITHUB_OUTPUT
echo "msver=${template//build/$build}.0"
- name: Restore dependencies
working-directory: ./src
run: dotnet restore
- name: Build
working-directory: ./src
run: >
dotnet build --configuration Release --no-restore
/p:Version=${{steps.version.outputs.semver}}
/p:PackageVersion=${{steps.version.outputs.semver}}
/p:AssemblyVersion=${{steps.version.outputs.msver}}
/p:FileVersion=${{steps.version.outputs.msver}}
- name: Test
working-directory: ./src
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Package
working-directory: ./src
run: >
dotnet pack --configuration Release --no-restore
/p:Version=${{steps.version.outputs.semver}}
/p:PackageVersion=${{steps.version.outputs.semver}}
/p:AssemblyVersion=${{steps.version.outputs.msver}}
/p:FileVersion=${{steps.version.outputs.msver}}
- name: Publish
if: github.event_name == 'push'
working-directory: ./src
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate