-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
100 lines (91 loc) · 2.95 KB
/
.gitlab-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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
image: mcr.microsoft.com/dotnet/sdk:5.0.301-alpine3.13-amd64
variables:
BUILD_CONF: Release
NUGET_FOLDER: ./nuget
BuildType: V2
stages:
- build
- test
- deploy
- post-deploy
cache: &global_cache
key: nuget
paths:
- $NUGET_FOLDER
build:
stage: build
script:
- dotnet restore --packages $NUGET_FOLDER
- dotnet build --no-restore -c $BUILD_CONF --source $NUGET_FOLDER
- dotnet pack --no-build -c $BUILD_CONF ./IndicoV2/IndicoV2.csproj -o ./artifacts/nuget/
artifacts:
paths:
- "**/bin/"
- "**/obj/"
- "./artifacts/nuget/"
expire_in: 5 days
test:
stage: test
needs: [build]
dependencies: [build]
cache:
<<: *global_cache
policy: pull
script:
- dotnet test --no-build --no-restore -c $BUILD_CONF --results-directory:'./artifacts/test/' --logger:"junit;LogFileName=./results/{assembly}-test-result.xml" --collect:'XPlat Code Coverage' --filter FullyQualifiedName\!~IntegrationTests -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
- dotnet tool restore
- dotnet reportgenerator -reports:./artifacts/test/*/coverage.cobertura.xml -targetdir:./artifacts/test/coverage/ -assemblyFilters:-Indicore -sourcedirs:$PWD -reporttypes:cobertura\;TextSummary
# fix filename (absolute -> relative path)
- cat ./artifacts/test/coverage/Cobertura.xml | sed "s/filename=\"$(pwd -P | sed -e 's/\//\\\//g')\//filename=\"/g" > ./artifacts/test/coverage/Cobertura-fixed.xml
- cat ./artifacts/test/coverage/Summary.txt
artifacts:
reports:
junit: ./artifacts/test/results/*
cobertura: ./artifacts/test/coverage/Cobertura-fixed.xml
deploy:
only: [master, develop]
stage: deploy
when: manual
needs: [build, test]
dependencies: [build]
script:
- dotnet nuget push ./artifacts/nuget/IndicoClient.*.nupkg -s https://api.nuget.org/v3/index.json --api-key $NUGET_KEY
cache: {}
build-pages:
stage: build
image: managedcode/docfx-automation
cache: {}
script:
- ./docfx_project/docfx.sh build
artifacts:
paths:
- ./docfx_project/_site
expire_in: 5 days
pages:
only: [master, develop]
stage: post-deploy
needs: [deploy, build-pages]
dependencies: [build-pages]
cache: {}
script:
- mv ./docfx_project/_site ./public
artifacts:
paths:
- public
release:
only: [master, develop]
stage: post-deploy
image: registry.gitlab.com/gitlab-org/release-cli:latest
dependencies: [build]
needs: [build, deploy]
cache: {}
script:
- VERSION=$(ls ./artifacts/nuget/IndicoClient.*.nupkg | grep -o -E '[[:digit:]]+(.[[:digit:]]+){2}(-[[:alpha:]]+)?.[[:digit:]]+' )
- "echo Creating GitLab realease for version $VERSION"
- >
release-cli create
--tag-name "v$VERSION"
--name "IndicoClient v$VERSION"
--description "IndicoClient v$VERSION"
--assets-link "{ \"name\": \"Nuget file\", \"url\": \"https://www.nuget.org/packages/IndicoClient/$VERSION\" }"
--ref $CI_COMMIT_SHA