-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
95 lines (84 loc) · 2.7 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
include:
- project: 'fusonic/devops/images/gitlab-ci-tools'
file: 'dotnet_test.yml'
ref: '5.10'
- project: "fusonic/devops/images/gitlab-ci-tools"
file: "release_tool.yml"
ref: "5.10"
stages:
- build
- test
- publish
variables:
BUILD_IMAGE: mcr.microsoft.com/dotnet/sdk:8.0
default:
interruptible: true
workflow:
rules:
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH =~ /^release\// || $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule"
build:
stage: build
image: ${BUILD_IMAGE}
before_script:
# Workaround for SourceLink: See: https://github.com/dotnet/sourcelink/issues/689
- git config url."https://github.com/fusonic/dotnet-extensions".insteadOf https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/fusonic/devops/dotnet/extensions
script:
- dotnet pack -c Release
artifacts:
when: on_success
paths:
- ./artifacts/package/release/*.nupkg
- ./artifacts/package/release/*.snupkg
rules:
- when: always
test:
stage: test
image: ${BUILD_IMAGE}
extends: .dotnet-test
services:
- name: postgres:15.4
alias: postgres
variables:
POSTGRES_PASSWORD: admin
BACKEND_SRC_DIR: src/**
SLN_PATH: Extensions.sln
ConnectionStrings__Npgsql: Host=postgres;Database=test_npgsql;Username=postgres;Password=admin
ConnectionStrings__Hangfire: Host=postgres;Database=test_hangfire;Username=postgres;Password=admin
rules:
- when: always
dotnet:check-warnings:
stage: test
extends: .dotnet:check-warnings
image: ${BUILD_IMAGE}
variables:
SLN_PATH: Extensions.sln
release:lint-merge-request:
stage: test
release:create:
stage: publish
extends: .release-script
needs: []
dependencies: []
before_script:
- export RELEASE_VERSION=`sed -n 's/.*<Version>\(.*\)<\/Version>.*/\1/p' ./src/Directory.Build.props`
rules:
- if: '$CI_COMMIT_REF_SLUG == "main"'
when: manual
publish:
image: ${BUILD_IMAGE}
stage: publish
variables:
GIT_STRATEGY: none
allow_failure: true
script:
- |
if [ $CI_PIPELINE_SOURCE != "merge_request_event" ]; then
echo "Publishing to NuGet.org"
dotnet nuget push "artifacts/package/release/*.nupkg" -k $Nuget_Key -s https://api.nuget.org/v3/index.json --skip-duplicate
fi
- echo "Publishing to GitLab"
- dotnet nuget push "artifacts/package/release/*.nupkg" --source "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/nuget/index.json" --api-key $CI_JOB_TOKEN
rules:
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH =~ /^release\// || $CI_COMMIT_TAG || $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual