@@ -28,11 +28,19 @@ variables:
28
28
# Using multiple test stages to avoid running some things in parallel (see job notes).
29
29
stages :
30
30
- test
31
- - upload-to -internal
32
- - upload-to -central
31
+ - publish-maven -internal
32
+ - publish-maven -central
33
33
- package-api-docs
34
34
- triggers
35
35
36
+ workflow :
37
+ rules :
38
+ # Never create a pipeline when a tag is pushed (to simplify release checks in root build script)
39
+ - if : $CI_COMMIT_TAG
40
+ when : never
41
+ # Otherwise, only create a pipeline when a branch is pushed
42
+ - if : $CI_PIPELINE_SOURCE == "push"
43
+
36
44
test :
37
45
stage : test
38
46
tags : [ docker, linux, x64 ]
47
55
# "|| true" for an OK exit code if no file is found
48
56
- rm **/hs_err_pid*.log || true
49
57
script :
50
- - ./scripts/test-with-asan.sh $GITLAB_REPO_ARGS $VERSION_ARGS clean build
58
+ # build to assemble, run tests and spotbugs
59
+ # javadocForWeb to catch API docs errors before releasing
60
+ - ./scripts/test-with-asan.sh $GITLAB_REPO_ARGS $VERSION_ARGS clean build javadocForWeb
51
61
artifacts :
52
62
when : always
53
63
paths :
@@ -120,22 +130,32 @@ test-jdk-x86:
120
130
TEST_WITH_JAVA_X86 : " true"
121
131
script : ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build
122
132
123
- upload-to-internal :
124
- stage : upload-to-internal
133
+ # Publish Maven artifacts to internal Maven repo
134
+ publish-maven-internal :
135
+ stage : publish-maven-internal
125
136
tags : [ docker, x64 ]
126
- except :
127
- - main # Do not upload duplicate release artifacts
128
- - pipelines # Do not upload artifacts if triggered by upstream project to save on disk space
129
- - schedules # Do not upload artifacts from scheduled jobs to save on disk space
130
- - tags # Only upload artifacts from branches
137
+ rules :
138
+ # Not from main branch, doing so may duplicate release artifacts (uploaded from publish branch)
139
+ - if : $CI_COMMIT_BRANCH == "main"
140
+ when : never
141
+ # Not if triggered by upstream project to save on disk space
142
+ - if : $CI_PIPELINE_SOURCE == "pipeline"
143
+ when : never
144
+ # Not from scheduled pipelines to save on disk space
145
+ - if : $CI_PIPELINE_SOURCE == "schedule"
146
+ when : never
147
+ # Otherwise, only on push to branch
148
+ - if : $CI_PIPELINE_SOURCE == "push"
131
149
script :
132
150
- ./gradlew $GITLAB_REPO_ARGS $GITLAB_PUBLISH_ARGS $VERSION_ARGS publishMavenJavaPublicationToGitLabRepository
133
151
134
- upload-to-central :
135
- stage : upload-to-central
152
+ # Publish Maven artifacts to public Maven repo at Central
153
+ publish-maven-central :
154
+ stage : publish-maven-central
136
155
tags : [ docker, x64 ]
137
- only :
138
- - publish
156
+ rules :
157
+ # Only on publish branch
158
+ - if : $CI_COMMIT_BRANCH == "publish"
139
159
before_script :
140
160
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library:* job $CI_JOB_NAME from branch $CI_COMMIT_BRANCH ($CI_COMMIT_SHORT_SHA)..."
141
161
script :
@@ -146,11 +166,13 @@ upload-to-central:
146
166
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library:* *$CI_JOB_STATUS* for $CI_JOB_NAME"
147
167
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "Check https://repo1.maven.org/maven2/io/objectbox/ in a few minutes."
148
168
169
+ # Create Java API docs archive
149
170
package-api-docs :
150
171
stage : package-api-docs
151
172
tags : [ docker, x64 ]
152
- only :
153
- - publish
173
+ rules :
174
+ # Only on publish branch
175
+ - if : $CI_COMMIT_BRANCH == "publish"
154
176
script :
155
177
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS :objectbox-java:packageJavadocForWeb
156
178
after_script :
@@ -159,14 +181,18 @@ package-api-docs:
159
181
paths :
160
182
- " objectbox-java/build/dist/objectbox-java-web-api-docs.zip"
161
183
184
+ # Trigger Gradle plugin build to test new Maven snapshots of this project
162
185
trigger-plugin :
163
186
stage : triggers
164
- except :
165
- - schedules # Do not trigger when run on schedule, e.g. integ tests have own schedule.
166
- - publish
187
+ rules :
188
+ # Do not trigger publishing of plugin
189
+ - if : $CI_COMMIT_BRANCH == "publish"
190
+ when : never
191
+ # Otherwise, only on push to branch (also set allow_failure in case branch does not exist downstream)
192
+ - if : $CI_PIPELINE_SOURCE == "push"
167
193
inherit :
168
194
variables : false
169
- allow_failure : true # Branch might not exist, yet, in plugin project.
195
+ allow_failure : true # Branch might not exist in plugin project
170
196
trigger :
171
197
project : objectbox/objectbox-plugin
172
198
branch : $CI_COMMIT_BRANCH
0 commit comments