@@ -16,12 +16,16 @@ image: objectboxio/buildenv-core:2025-07-03 # With JDK 21
1616# - ORG_GRADLE_PROJECT_signingPassword
1717
1818variables :
19- OBX_RELEASE :
19+ OBX_PUBLISH_RELEASE :
2020 value : " false"
2121 options : [ "false", "true" ]
22- description : " Turns on the release flag in the Gradle root build script, which triggers building and publishing a
23- release of Java libraries to the internal GitLab repository and Maven Central.
22+ description : " If enabled, builds and depends on release versions and triggers publishing a
23+ release of the Java library artifacts to the internal GitLab repository and Maven Central.
24+ Don't run multiple times to avoid duplicate artifacts in the GitLab repository.
2425 Consult the release checklist before turning this on."
26+ # If enabled, builds and depends on release versions. Doesn't publish a release.
27+ # See the root Gradle build script for details.
28+ OBX_RELEASE : " false"
2529
2630 # Disable the Gradle daemon. Gradle may run in a Docker container with a shared
2731 # Docker volume containing GRADLE_USER_HOME. If the container is stopped after a job
@@ -50,6 +54,14 @@ workflow:
5054 # Never create a pipeline when a tag is pushed (to simplify version computation in root build script)
5155 - if : $CI_COMMIT_TAG
5256 when : never
57+ # On main branch, always use release versions as old snapshots of dependencies are deleted
58+ - if : $CI_COMMIT_REF_NAME == "main"
59+ variables :
60+ OBX_RELEASE : " true"
61+ # To publish a release must use release versions
62+ - if : $OBX_PUBLISH_RELEASE == "true"
63+ variables :
64+ OBX_RELEASE : " true"
5365 # In all other cases, create a pipeline
5466 - when : always
5567
@@ -166,8 +178,9 @@ publish-maven-internal:
166178 - linux
167179 - x64
168180 rules :
169- # Not for main branch, doing so may duplicate release artifacts (uploaded from publish branch)
170- - if : $CI_COMMIT_BRANCH == "main"
181+ # Not when using release versions and not publishing a release to avoid duplicate artifacts
182+ # (GitLab would allow to upload duplicates for a release version)
183+ - if : $OBX_RELEASE == "true" && $OBX_PUBLISH_RELEASE != "true"
171184 when : never
172185 # Not if triggered by upstream project to save on disk space
173186 - if : $CI_PIPELINE_SOURCE == "pipeline"
@@ -188,8 +201,8 @@ publish-maven-central:
188201 - linux
189202 - x64
190203 rules :
191- # Only if release mode is on , only if no previous stages failed
192- - if : $OBX_RELEASE == "true"
204+ # Only if publishing a release , only if no previous stages failed
205+ - if : $OBX_PUBLISH_RELEASE == "true"
193206 when : on_success
194207 before_script :
195208 - 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)..."
@@ -209,8 +222,8 @@ package-api-docs:
209222 - linux
210223 - x64
211224 rules :
212- # Only if release mode is on , only if no previous stages failed
213- - if : $OBX_RELEASE == "true"
225+ # Only if publishing a release , only if no previous stages failed
226+ - if : $OBX_PUBLISH_RELEASE == "true"
214227 when : on_success
215228 script :
216229 - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS :objectbox-java:packageJavadocForWeb
@@ -225,7 +238,7 @@ trigger-plugin:
225238 stage : triggers
226239 rules :
227240 # Not when publishing a release
228- - if : $OBX_RELEASE == "true"
241+ - if : $OBX_PUBLISH_RELEASE == "true"
229242 when : never
230243 # Do not trigger publishing of plugin
231244 - if : $CI_COMMIT_BRANCH == "publish"
0 commit comments