forked from Fupery/ArtMap
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
202 lines (184 loc) · 7.44 KB
/
.gitlab-ci.yml
File metadata and controls
202 lines (184 loc) · 7.44 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
stages:
- generate-release
- sast
- build
- coverage
- integration
- publish
- release
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository
################################################################################################
# Build
################################################################################################
# 1.18
.jdk17:
image: maven:3.9-eclipse-temurin-17
variables:
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true -DskipTests -Dmaven.test.skip=true"
# 1.20.5+
.jdk21:
image: maven:3.9-eclipse-temurin-21
#use maven verify we don't need to pollute the cache with the build artifacts
.build:
stage: build
script:
- mvn versions::set -DnewVersion=${NEXT_VERSION}
- mvn versions::commit
- 'mvn $MAVEN_CLI_OPTS verify'
artifacts:
paths:
- plugin/target/*.jar #Grab the built jars
- plugin/target/site/jacoco/jacoco.xml
reports:
junit:
- plugin/target/surefire-reports/TEST-*.xml
- plugin/target/failsafe-reports/TEST-*.xml
build:jdk17:
extends: [.jdk17, .build]
build:jdk21:
extends: [.jdk21, .build]
coverage:
stage: coverage
image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.11
script:
# convert report from jacoco to cobertura, using relative project path
- python /opt/cover2cover.py plugin/target/site/jacoco/jacoco.xml $CI_PROJECT_DIR/plugin/src/main/java/ > plugin/target/site/cobertura.xml
needs: ["build:jdk21"]
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: plugin/target/site/cobertura.xml
################################################################################################
# Publish
################################################################################################
.publish:
stage: publish
script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file plugin/target/ArtMap-${NEXT_VERSION}.jar "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ArtMap/${NEXT_VERSION}/ArtMap-${JDK}-${NEXT_VERSION}.jar"'
rules:
- if: '$CI_COMMIT_TAG'
publish:jdk17:
extends: .publish
needs: ["build:jdk17"]
variables:
JDK: "JDK17"
publish:jdk21:
extends: .publish
needs: ["build:jdk21"]
variables:
JDK: "JDK21"
################################################################################################
# Integration - Start a real Paper server in Docker and verify ArtMap loads cleanly.
################################################################################################
integration:
stage: integration
image: docker:latest
# docker:dind provides the Docker daemon. TLS is disabled so the Docker CLI
# in the outer container can reach it without certificate setup.
services:
- name: docker:dind
command: ["--tls=false"]
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://docker:2375"
# Minecraft / ProtocolLib versions used for the integration test.
# Override these in the GitLab project variables to test a different version.
MC_VERSION: "1.21.11"
PROTOCOLLIB_VERSION: "dev-build"
TIMEOUT: "600"
needs: ["build:jdk21"]
before_script:
# The dind service needs a moment to start. Poll until the daemon answers.
- until docker info >/dev/null 2>&1; do echo "Waiting for Docker daemon..."; sleep 2; done
script:
- chmod +x integration/run-integration-test.sh
- ./integration/run-integration-test.sh
artifacts:
# Always upload the server log so failed runs can be diagnosed.
when: always
paths:
- integration/server.log
expire_in: 1 week
################################################################################################
# Release
################################################################################################
# Creates the GitLab Release and attaches the two published JARs as package
# assets. Runs only on tags, after both publish jobs have succeeded.
release:gitlab-release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs: ["publish:jdk17", "publish:jdk21"]
variables:
# Full history is required so we can walk back to the previous tag.
GIT_DEPTH: 0
before_script:
- apk add --no-cache git
script:
# Find the tag that immediately preceded this one (version-sorted).
- PREV_TAG=$(git tag --sort=-version:refname | grep -v "^${CI_COMMIT_TAG}$" | head -1)
# Build the commit range: either since the last tag, or the whole history.
- |
if [ -n "$PREV_TAG" ]; then
echo "## Changes since ${PREV_TAG}" > release_notes.md
RANGE="${PREV_TAG}..${CI_COMMIT_TAG}"
else
echo "## Changes" > release_notes.md
RANGE="${CI_COMMIT_TAG}"
fi
# List commits, skipping merge commits and the automated release bumps.
- git log --pretty=format:"- %s" --no-merges --invert-grep --grep="chore(release)" $RANGE >> release_notes.md
- printf '\n' >> release_notes.md
- cat release_notes.md
release:
tag_name: '$CI_COMMIT_TAG'
name: 'ArtMap $CI_COMMIT_TAG'
description: './release_notes.md'
assets:
links:
- name: 'ArtMap-JDK17-${NEXT_VERSION}.jar (Minecraft 1.18–1.20.4, Java 17)'
url: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ArtMap/${NEXT_VERSION}/ArtMap-JDK17-${NEXT_VERSION}.jar'
link_type: package
- name: 'ArtMap-JDK21-${NEXT_VERSION}.jar (Minecraft 1.20.5+, Java 21)'
url: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ArtMap/${NEXT_VERSION}/ArtMap-JDK21-${NEXT_VERSION}.jar'
link_type: package
rules:
- if: '$CI_COMMIT_TAG'
# Updates POM versions to keep them in line with the release tag.
# Only pushes if there are changes.
release:maven-release:
extends: .jdk21
stage: release
needs: ["publish:jdk21"]
variables:
COMMIT_MESSAGE: "chore(release): [skip ci] Release ${NEXT_VERSION}"
before_script:
- git remote set-url origin https://GITLAB_TOKEN:${GITLAB_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_ID}"
script:
- git checkout master
- mvn versions::set -DnewVersion=${NEXT_VERSION}
- mvn versions::commit
- git add .
- |-
CHANGES=$(git status --porcelain | wc -l)
if [ "$CHANGES" -gt "0" ]; then
git status
git commit -m "${COMMIT_MESSAGE}"
git push
fi
rules:
- if: '$CI_COMMIT_TAG'