forked from wispoffates/ArtMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
161 lines (142 loc) · 5.49 KB
/
.gitlab-ci.yml
File metadata and controls
161 lines (142 loc) · 5.49 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
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.7
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"'
only:
- master
publish:jdk17:
extends: .publish
needs: ["release:generate-release","build:jdk17"]
variables:
JDK: "JDK17"
publish:jdk21:
extends: .publish
needs: ["release:generate-release","build:jdk21"]
variables:
JDK: "JDK21"
################################################################################################
# Integration - Just some debugging for now - Intention is to use docker and test startup on various MC versions
################################################################################################
integration:
stage: integration
needs: ["build:jdk21"]
script:
- echo $NEXT_VERSION
- echo $CURRENT_VERSION
################################################################################################
# Versioning Release
################################################################################################
#Updates POM versions to keep them in line with the release
#Only pushes if there are changes
release:maven-release:
extends: .jdk21
stage: release
needs: ["release:generate-release","publish:jdk17","release:tag"]
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
only:
- master
#Generates the version number and adds it to build.env so its available for later steps
release:generate-release:
image: node:20-buster-slim
stage: generate-release
before_script:
- apt-get update && apt-get install -y --no-install-recommends git-core ca-certificates
- npm install -g semantic-release @semantic-release/gitlab
- npm install @semantic-release/git @semantic-release/changelog @semantic-release/exec -D
script:
- semantic-release --dry-run
- cat build.env
artifacts:
reports:
dotenv: build.env
only:
- master
release:tag:
stage: release
extends: release:generate-release
needs: ["publish:jdk17","publish:jdk21"]
script:
- semantic-release