-
Notifications
You must be signed in to change notification settings - Fork 4
104 lines (83 loc) · 2.96 KB
/
01_build_test_publish.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
name: "01 - Build, Test, Publish"
on:
push:
# run on all commits
pull_request:
# run on all pull requests
workflow_dispatch:
# allows you to run this workflow manually from the Actions tab
jobs:
build_test_publish:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
BUILD_PATH: ./src
CONFIG_NAME: Release
# relative to BUILD_PATH
PUBLISH_PATH: ../.build/app
steps:
- uses: actions/checkout@v4
with:
# needed for gitversion to work
fetch-depth: 0
- name: gitversion
run: |
# calling "dotnet tool install" when already installed will give an error
# see https://github.com/dotnet/sdk/issues/9500
if ( ! dotnet tool list --global | grep -q "gitversion.tool" )
then
dotnet tool install --global GitVersion.Tool --version 5.8.2
fi
dotnet-gitversion
dotnet-gitversion /showvariable "FullSemVer"
BUILD_NUMBER=$(
# convert to a docker-friendly version number
dotnet-gitversion /showvariable "FullSemVer" \
| sed "s/+/-/g"
)
echo "build number = $BUILD_NUMBER"
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
- name: setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: dotnet info
working-directory: ${{ env.BUILD_PATH }}
run: dotnet --info
- name: dotnet restore
working-directory: ${{ env.BUILD_PATH }}
run: dotnet restore
- name: dotnet build
working-directory: ${{ env.BUILD_PATH }}
run: dotnet build --configuration "$CONFIG_NAME" --no-restore
- name: dotnet test
working-directory: ${{ env.BUILD_PATH }}
run: dotnet test --configuration "$CONFIG_NAME" --no-build --filter "TestCategory!=Performance"
- name: dotnet publish
working-directory: ${{ env.BUILD_PATH }}
run: dotnet publish "./Kingsland.MofParser/Kingsland.MofParser.csproj" --configuration "$CONFIG_NAME" --no-build --output "$PUBLISH_PATH"
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: app
path: .build/app
- name: dotnet tool jb inspectcode
working-directory: ${{ env.BUILD_PATH }}
run: |
dotnet new tool-manifest
dotnet tool install JetBrains.ReSharper.GlobalTools
dotnet tool run jb inspectcode "./Kingsland.MofParser.sln" -output="../.build/out/jb-inspectcode.xml" --no-build
- name: upload jb-inspectcode.xml
uses: actions/upload-artifact@v3
with:
name: jb-inspectcode.xml
path: .build/out/jb-inspectcode.xml
- name: nuget pack
run: nuget pack src/Kingsland.MofParser.nuspec
- name: upload nuget package
uses: actions/upload-artifact@v4
with:
name: nupkg
path: ./*.nupkg