@@ -28,11 +28,19 @@ variables:
2828# Using multiple test stages to avoid running some things in parallel (see job notes).
2929stages :
3030 - test
31- - upload-to -internal
32- - upload-to -central
31+ - publish-maven -internal
32+ - publish-maven -central
3333 - package-api-docs
3434 - triggers
3535
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+
3644test :
3745 stage : test
3846 tags : [ docker, linux, x64 ]
4755 # "|| true" for an OK exit code if no file is found
4856 - rm **/hs_err_pid*.log || true
4957 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
5161 artifacts :
5262 when : always
5363 paths :
@@ -120,22 +130,32 @@ test-jdk-x86:
120130 TEST_WITH_JAVA_X86 : " true"
121131 script : ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build
122132
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
125136 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"
131149 script :
132150 - ./gradlew $GITLAB_REPO_ARGS $GITLAB_PUBLISH_ARGS $VERSION_ARGS publishMavenJavaPublicationToGitLabRepository
133151
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
136155 tags : [ docker, x64 ]
137- only :
138- - publish
156+ rules :
157+ # Only on publish branch
158+ - if : $CI_COMMIT_BRANCH == "publish"
139159 before_script :
140160 - 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)..."
141161 script :
@@ -146,11 +166,13 @@ upload-to-central:
146166 - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library:* *$CI_JOB_STATUS* for $CI_JOB_NAME"
147167 - 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."
148168
169+ # Create Java API docs archive
149170package-api-docs :
150171 stage : package-api-docs
151172 tags : [ docker, x64 ]
152- only :
153- - publish
173+ rules :
174+ # Only on publish branch
175+ - if : $CI_COMMIT_BRANCH == "publish"
154176 script :
155177 - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS :objectbox-java:packageJavadocForWeb
156178 after_script :
@@ -159,14 +181,18 @@ package-api-docs:
159181 paths :
160182 - " objectbox-java/build/dist/objectbox-java-web-api-docs.zip"
161183
184+ # Trigger Gradle plugin build to test new Maven snapshots of this project
162185trigger-plugin :
163186 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"
167193 inherit :
168194 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
170196 trigger :
171197 project : objectbox/objectbox-plugin
172198 branch : $CI_COMMIT_BRANCH
0 commit comments