-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
66 lines (58 loc) · 2.01 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
image: registry.digify/dotnet/sdk:8.0
variables:
GITLAB_NUGET_URL: ${CI_API_V4_URL}/projects/5/packages/nuget/index.json
MAIN_PROJECT: ${CI_PROJECT_DIR}/src/partial.csproj
TEST_PROJECT: ${CI_PROJECT_DIR}/tests/tests.csproj
ASSEMBLY: PartialSourceGen
USERNAME: ${GITLAB_PACKAGE_REGISTRY_USERNAME}
PASSWORD: ${GITLAB_PACKAGE_REGISTRY_PASSWORD}
workflow:
rules:
- if: $CI_COMMIT_TAG =~ /v\.\d+\.\d+\.\d+\-?.*/ && $CI_DEFAULT_BRANCH
stages:
- test-and-build
- deploy
before_script:
- PACKAGE_VERSION=${CI_COMMIT_TAG:2}
- PACKAGE=release/${ASSEMBLY}.${PACKAGE_VERSION}.nupkg
build:
stage: test-and-build
artifacts:
untracked: false
when: on_success
expire_in: "30 days"
paths:
- "release/"
script:
- dotnet build ${MAIN_PROJECT} -c Release -p:PackageVersion=${PACKAGE_VERSION}
- dotnet test ${TEST_PROJECT} --filter "Category=SnapshotTest" -p:PackageVersion=${PACKAGE_VERSION}
- dotnet pack ${MAIN_PROJECT} -c Release -p:PackageVersion=${PACKAGE_VERSION} -o release
deploy_gitlab:
stage: deploy
dependencies:
- "build"
before_script:
# Self signed CA
- cp /mnt/certs/tls.crt /usr/local/share/ca-certificates/my-ca.crt
- update-ca-certificates
- dotnet nuget add source "${GITLAB_NUGET_URL}" --name gitlab --username "${USERNAME}" --password "${PASSWORD}" --store-password-in-clear-text
# Re-declare
- PACKAGE_VERSION=${CI_COMMIT_TAG:2}
- PACKAGE=release/${ASSEMBLY}.${PACKAGE_VERSION}.nupkg
script:
# Private Gitlab nuget registry
- dotnet nuget push "${PACKAGE}" -s gitlab -k "${PASSWORD}" --skip-duplicate
deploy_nuget:
stage: deploy
dependencies:
- "build"
script:
# Public nuget.org registry
- dotnet nuget push -s https://api.nuget.org/v3/index.json ${PACKAGE} -k ${NUGET_KEY} --skip-duplicate
deploy_github:
stage: deploy
dependencies:
- "build"
script:
# Public github.com registry
- dotnet nuget push -s https://nuget.pkg.github.com/Newex/index.json -k ${GITHUB_KEY} ${PACKAGE} --skip-duplicate