-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
158 lines (142 loc) · 4.23 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
workflow:
auto_cancel:
on_new_commit: interruptible
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "push"
- if: $CI_PIPELINE_SOURCE == "schedule"
stages:
- build
- security
- publish
- release
- deploy
variables:
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/build/${CI_COMMIT_TAG}"
GRADLE_OPTS: -Dorg.gradle.daemon=false
# ------------------------------ Conditions
.if-merge-request-or-main: &if-merge-request-or-main
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^\(nobuild\)/'
when: never
.if-release: &if-release
- if: '$CI_COMMIT_TAG =~ /^\d+.\d+.\d+.*/'
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
# ------------------------------ Security
security:dependencies:
stage: security
interruptible: true
needs: [ ]
variables:
TRIVY_CACHE_DIR: ".trivycache/"
cache:
paths:
- .trivycache/
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
allow_failure: true
- if: '$CI_COMMIT_TAG =~ /^\d+.\d+.\d+.*/'
allow_failure: false
- if: $CI_PIPELINE_SOURCE == "schedule"
allow_failure: false
artifacts:
when: always
reports:
dependency_scanning: report.json
script:
- trivy repo ./ --exit-code 0
- trivy repo ./ --exit-code 0 --format template --template "@/contrib/gitlab.tpl" --output report.json
- trivy repo ./ --exit-code 1 --severity CRITICAL
tags:
- linux
# ------------------------------ Build
build:debug:
stage: build
rules:
- *if-merge-request-or-main
before_script:
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
script:
- ./gradlew
clean
linkDebugExecutable{MacosX64,MacosArm64,LinuxX64,LinuxArm64,MingwX64}
tags:
- macos
build:release:
stage: build
rules:
- *if-release
artifacts:
paths:
- rad/build/bin/**
expire_in: 1 week
before_script:
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
script:
- ./gradlew
clean
linkReleaseExecutable{MacosX64,MacosArm64,LinuxX64,LinuxArm64,MingwX64}
tags:
- macos
# ------------------------------ Publish
publish:
stage: publish
rules:
- *if-release
dependencies:
- build:release
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "rad/build/bin/linuxX64/releaseExecutable/rad.kexe" "${PACKAGE_REGISTRY_URL}/rad-linux-x64"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "rad/build/bin/linuxArm64/releaseExecutable/rad.kexe" "${PACKAGE_REGISTRY_URL}/rad-linux-arm64"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "rad/build/bin/macosX64/releaseExecutable/rad.kexe" "${PACKAGE_REGISTRY_URL}/rad-macos-x64"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "rad/build/bin/macosArm64/releaseExecutable/rad.kexe" "${PACKAGE_REGISTRY_URL}/rad-macos-arm64"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "rad/build/bin/mingwX64/releaseExecutable/rad.exe" "${PACKAGE_REGISTRY_URL}/rad-windows-x64.exe"
tags:
- macos
# ------------------------------ Release
release:
stage: release
rules:
- *if-release
dependencies:
- publish
script:
- echo "Running release job for $CI_COMMIT_TAG"
release:
tag_name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG'
assets:
links:
- name: "Linux x64"
url: ${PACKAGE_REGISTRY_URL}/rad-linux-x64
- name: "Linux arm64"
url: ${PACKAGE_REGISTRY_URL}/rad-linux-arm64
- name: "macOS x64"
url: ${PACKAGE_REGISTRY_URL}/rad-macos-x64
- name: "macOS arm64"
url: ${PACKAGE_REGISTRY_URL}/rad-macos-arm64
- name: "Windows x64"
url: ${PACKAGE_REGISTRY_URL}/rad-windows-x64.exe
tags:
- linux
# ------------------------------ Deploy
deploy:
stage: deploy
rules:
- *if-release
dependencies:
- release
script:
- ssh [email protected] 'cd /home/tools/rad && ./deploy.sh'
- echo "Rad service deployed (code $?)"
tags:
- macos