Skip to content

Commit a71230b

Browse files
committed
ci: Added gitlab CI pipeline
1 parent e071b86 commit a71230b

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.gitlab-ci.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
variables:
2+
# Opt out of telemetry (turbo and others), see https://consoledonottrack.com/
3+
DO_NOT_TRACK: 1
4+
# Enable debug services
5+
CI_DEBUG_SERVICES: "true"
6+
# Enable service network
7+
FF_NETWORK_PER_BUILD: "true"
8+
# Nupkg folder
9+
NUPKG_FOLDER: ".packages"
10+
NUGET_SOURCE: https://nuget.rapidsoft.ru/nuget/Rapidsoft-Nuget/v3/index.json
11+
NUGETORG_SOURCE: https://nuget.rapidsoft.ru/nuget/RapidSoft-NuGetORG/v3/index.json
12+
GITHUB_SOURCE: https://nuget.pkg.github.com/DbUp/index.json
13+
# All console output of dotnet should be in English
14+
LANG: C
15+
LCID: 1033
16+
# Disable dotnet first time experience
17+
DOTNET_NOLOGO: true
18+
# Disable Husky in dotnet tools restore
19+
HUSKY: 0
20+
21+
stages:
22+
- build
23+
- test
24+
- publish
25+
- release
26+
27+
workflow:
28+
rules:
29+
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG'
30+
when: never
31+
- if: $CI_COMMIT_BRANCH
32+
when: always
33+
34+
include:
35+
- component: $CI_SERVER_FQDN/open-source/ci-components/ultimate-auto-semversioning@0.1.3
36+
37+
build:
38+
image: mcr.microsoft.com/dotnet/sdk:8.0
39+
stage: build
40+
variables:
41+
PACKAGE_VERSION: ${GitVersion_LegacySemVer}
42+
script:
43+
- |
44+
echo "Building version ${PACKAGE_VERSION}"
45+
if [[ "${CI_SCRIPT_TRACE}" == "true" ]] || [[ -n "${CI_DEBUG_TRACE}" ]]; then
46+
echo "Debugging enabled"
47+
set -xv
48+
fi
49+
dotnet nuget update source nuget.org -s "$NUGETORG_SOURCE"
50+
dotnet nuget add source "$NUGET_SOURCE" --name nuget.rapidsoft.ru
51+
dotnet nuget add source "$GITHUB_SOURCE" --name github --username shokurov --password $GITHUB_REPO_KEY --store-password-in-clear-text
52+
53+
dotnet restore --packages .nuget/packages/ ./src/dbup-clickhouse.sln
54+
dotnet build --no-restore --packages .nuget/packages/ -c Release -p:Version=$PACKAGE_VERSION ./src/dbup-clickhouse.sln
55+
dotnet pack --no-build --no-restore -c Release -p:Version=$PACKAGE_VERSION -o $NUPKG_FOLDER --include-symbols --include-source ./src/dbup-clickhouse.sln
56+
artifacts:
57+
expire_in: 1 week # to save gitlab server space, we copy the files we need to deploy folder later on
58+
paths:
59+
- "$NUPKG_FOLDER/"
60+
61+
publish:internal:
62+
image: mcr.microsoft.com/dotnet/sdk:8.0
63+
stage: publish
64+
variables:
65+
PACKAGE_VERSION: ${GitVersion_LegacySemVer}
66+
script:
67+
- echo "Publishing version $PACKAGE_VERSION internally to $NUGET_SOURCE"
68+
- dotnet nuget push "$NUPKG_FOLDER/*.nupkg" --source $NUGET_SOURCE --api-key $NUGET_API_KEY
69+
needs:
70+
- build
71+
when: manual
72+
73+
# Please see [Release CI/CD examples](https://docs.gitlab.com/ee/user/project/releases/release_cicd_examples.html) for many rich examples for triggering a release only on specific conditions.
74+
release_job:
75+
stage: release
76+
when: manual
77+
image: registry.gitlab.com/gitlab-org/release-cli
78+
rules:
79+
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED != "false"'
80+
#This last rule will do a release for any protected branch. Literal branch names can be used if desired.
81+
script:
82+
- echo "running release_job"
83+
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
84+
tag_name: '$CI_COMMIT_TAG'
85+
description: '$CI_COMMIT_TAG'

0 commit comments

Comments
 (0)