Skip to content

Commit dfdc53a

Browse files
Gradle: turn on release mode through GitLab CI variable
1 parent 90707bf commit dfdc53a

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

.gitlab-ci.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ image: objectboxio/buildenv-core:2024-07-11 # With JDK 17
1515
# - ORG_GRADLE_PROJECT_signingPassword
1616

1717
variables:
18+
OBX_RELEASE:
19+
value: "false"
20+
options: [ "false", "true" ]
21+
description: "Turns on the release flag in the Gradle root build script, which triggers building and publishing a
22+
release of Java libraries to the internal GitLab repository and Maven Central.
23+
Consult the release checklist before turning this on."
24+
1825
# Disable the Gradle daemon. Gradle may run in a Docker container with a shared
1926
# Docker volume containing GRADLE_USER_HOME. If the container is stopped after a job
2027
# Gradle daemons may get killed, preventing proper clean-up of lock files in GRADLE_USER_HOME.
@@ -173,16 +180,16 @@ publish-maven-internal:
173180
script:
174181
- ./gradlew $GITLAB_REPO_ARGS $GITLAB_PUBLISH_ARGS $VERSION_ARGS publishMavenJavaPublicationToGitLabRepository
175182

176-
# Publish Maven artifacts to public Maven repo at Central
183+
# Publish Maven artifacts to public Maven Central repo
177184
publish-maven-central:
178185
stage: publish-maven-central
179186
tags:
180187
- docker
181188
- linux
182189
- x64
183190
rules:
184-
# Only on publish branch, only if no previous stages failed
185-
- if: $CI_COMMIT_BRANCH == "publish"
191+
# Only if release mode is on, only if no previous stages failed
192+
- if: $OBX_RELEASE == "true"
186193
when: on_success
187194
before_script:
188195
- 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)..."
@@ -202,8 +209,8 @@ package-api-docs:
202209
- linux
203210
- x64
204211
rules:
205-
# Only on publish branch, only if no previous stages failed
206-
- if: $CI_COMMIT_BRANCH == "publish"
212+
# Only if release mode is on, only if no previous stages failed
213+
- if: $OBX_RELEASE == "true"
207214
when: on_success
208215
script:
209216
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS :objectbox-java:packageJavadocForWeb
@@ -217,6 +224,9 @@ package-api-docs:
217224
trigger-plugin:
218225
stage: triggers
219226
rules:
227+
# Not when publishing a release
228+
- if: $OBX_RELEASE == "true"
229+
when: never
220230
# Do not trigger publishing of plugin
221231
- if: $CI_COMMIT_BRANCH == "publish"
222232
when: never

build.gradle.kts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// Use to create different versions based on branch/tag.
55
// - sonatypeUsername: Maven Central credential used by Nexus publishing.
66
// - sonatypePassword: Maven Central credential used by Nexus publishing.
7+
// This script supports the following environment variables:
8+
// - OBX_RELEASE: If set to "true" builds release versions without version postfix.
9+
// Otherwise, will build snapshot versions.
710

811
plugins {
912
// https://github.com/ben-manes/gradle-versions-plugin/releases
@@ -15,10 +18,15 @@ plugins {
1518
}
1619

1720
buildscript {
18-
val versionNumber = "4.3.1" // without "-SNAPSHOT", e.g. "2.5.0" or "2.4.0-RC"
19-
val isRelease = false // WARNING: only set true to publish a release on publish branch!
20-
// See the release checklist for details.
21-
// Makes this produce release artifacts, changes dependencies to release versions.
21+
// Version of Maven artifacts
22+
// Should only be changed as part of the release process, see the release checklist in the objectbox repo
23+
val versionNumber = "4.3.1"
24+
25+
// Release mode should only be enabled when manually triggering a CI pipeline,
26+
// see the release checklist in the objectbox repo.
27+
// If true won't build snapshots and removes version post fix (e.g. "-dev-SNAPSHOT"),
28+
// uses release versions of dependencies.
29+
val isRelease = System.getenv("OBX_RELEASE") == "true"
2230

2331
// version post fix: "-<value>" or "" if not defined; e.g. used by CI to pass in branch name
2432
val versionPostFixValue = project.findProperty("versionPostFix")

0 commit comments

Comments
 (0)