Skip to content

Commit

Permalink
GEODE-6259: Refine version specification and consumption (apache#3058)
Browse files Browse the repository at this point in the history
* Streamline version specification -- version can be specified directly, rather than as a combination of versionNumber, releaseQualifier, and releaseType
* Concourse meta-property MAVEN_SNAPSNOT_BUCKET should now be the complete bucket path.
* Concourse uses 'SNAPSHOT' as the semver pre-release token for develop
* Concourse uses semver resource as the source-of-truth for binary build-id and version
* Use semver content to help determine release or snapshot in concourse
* Zero-pad build-id number for publications

Co-authored-by: Robert Houghton <[email protected]>
Co-authored-by: Patrick Rhomberg <[email protected]>
  • Loading branch information
robbadler and PurelyApplied committed Jan 10, 2019
1 parent 65db24c commit 50ea625
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 95 deletions.
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ wrapper {
}

allprojects {
version = versionNumber + releaseQualifier + releaseType
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
ext.isReleaseVersion = true
if(version.contains("SNAPSHOT")) {
ext.isReleaseVersion = false
version = (version as String).replaceFirst(/SNAPSHOT.*/, 'SNAPSHOT')
}

repositories {
mavenLocal()
Expand Down
1 change: 1 addition & 0 deletions ci/pipelines/geode-build/deploy_pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ version-bucket: ${VERSION_BUCKET}
artifact-bucket: ${ARTIFACT_BUCKET}
gradle-global-args: ${GRADLE_GLOBAL_ARGS}
maven-snapshot-bucket: ${MAVEN_SNAPSHOT_BUCKET}
semver-prerelease-token: ${SEMVER_PRERELEASE_TOKEN}
YML


4 changes: 2 additions & 2 deletions ci/pipelines/geode-build/jinja.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jobs:
trigger: true
- get: geode-build-version
params:
pre: build
pre: {{semver-prerelease-token}}
- do:
- put: concourse-metadata-resource
- task: create_instance
Expand Down Expand Up @@ -385,7 +385,7 @@ jobs:
trigger: true
- get: geode-build-version
params:
pre: build
pre: {{semver-prerelease-token}}
- do:
- put: concourse-metadata-resource
- task: create_instance
Expand Down
3 changes: 2 additions & 1 deletion ci/pipelines/meta/meta.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ ARTIFACT_BUCKET=files.apachegeode-ci.info
PUBLIC=true
REPOSITORY_PUBLIC=true
GRADLE_GLOBAL_ARGS=""
MAVEN_SNAPSHOT_BUCKET=maven.apachegeode-ci.info
MAVEN_SNAPSHOT_BUCKET=gcs://maven.apachegeode-ci.info/snapshot/
SEMVER_PRERELEASE_TOKEN=SNAPSHOT
25 changes: 17 additions & 8 deletions ci/scripts/archive_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ fi
SANITIZED_GRADLE_TASK=${GRADLE_TASK##*:}
TMPDIR=${DEST_DIR}/tmp
GEODE_BUILD=${DEST_DIR}/geode
GEODE_BUILD_VERSION_NUMBER=$(echo "${GRADLE_GLOBAL_ARGS}"|tr ' ' '\n' | grep "versionNumber *=" - ${GEODE_BUILD}/gradle.properties | awk -F "=" '{print $2; exit}' | tr -d ' ')
BUILD_TIMESTAMP=$(date +%s)

GEODE_PULL_REQUEST_ID_FILE=${BUILDROOT}/geode/.git/resource/version.json
Expand All @@ -68,21 +67,31 @@ if [ -z ${MAINTENANCE_VERSION+x} ]; then
exit 1
fi

if [ -z "${GEODE_PULL_REQUEST_ID}" ]; then
if [ -e "${GEODE_PULL_REQUEST_ID_FILE}" ]; then
GEODE_PULL_REQUEST_ID=$(cat ${GEODE_PULL_REQUEST_ID_FILE})
FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}"
else
# semver resource, e.g., "1.9.0-SNAPSHOT.325"
CONCOURSE_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE})
CONCOURSE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*}
GEODE_PRODUCT_VERSION=${GEODE_BUILD_VERSION_NUMBER}
# Prune all after '-', yielding e.g., "1.9.0"
GEODE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*}
# Prune all before '-', yielding e.g., "SNAPSHOT.325"
CONCOURSE_BUILD_SLUG=${CONCOURSE_VERSION##*-}
BUILD_ID=${CONCOURSE_VERSION##*.}
FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${CONCOURSE_BUILD_SLUG}
# Prune all before '.', yielding e.g., "SNAPSHOT"
SNAPSHOT_SLUG=${CONCOURSE_BUILD_SLUG##*.}
# Prune all before '.', yielding e.g., "325"
BUILD_ID=$(printf "%04d" ${CONCOURSE_VERSION##*.})

# Rebuild version, zero-padded
FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${SNAPSHOT_SLUG}.${BUILD_ID}

echo "Concourse VERSION is ${CONCOURSE_VERSION}"
echo "Geode product VERSION is ${GEODE_PRODUCT_VERSION}"
echo "Full product VERSION is ${FULL_PRODUCT_VERSION}"
echo "Build ID is ${BUILD_ID}"
else
FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}"
fi


directories_file=${DEST_DIR}/artifact_directories
mkdir -p ${TMPDIR}

Expand Down
19 changes: 14 additions & 5 deletions ci/scripts/execute_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,30 @@ BUILD_DATE=$(date +%s)
if [ -e "${ROOT_DIR}/geode-build-version" ] ; then
GEODE_BUILD_VERSION_FILE=${ROOT_DIR}/geode-build-version/number
GEODE_RESULTS_VERSION_FILE=${ROOT_DIR}/results/number
GEODE_BUILD_VERSION_NUMBER=$(echo "${GRADLE_GLOBAL_ARGS}"|tr ' ' '\n' | grep "versionNumber *=" - geode/gradle.properties | awk -F "=" '{print $2; exit}' | tr -d ' ')
GEODE_BUILD_DIR=/tmp/geode-build
GEODE_PULL_REQUEST_ID_FILE=${ROOT_DIR}/geode/.git/id

if [ -e "${GEODE_PULL_REQUEST_ID_FILE}" ]; then
GEODE_PULL_REQUEST_ID=$(cat ${GEODE_PULL_REQUEST_ID_FILE})
FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}"
else
# semver resource, e.g., "1.9.0-SNAPSHOT.325"
CONCOURSE_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE})
CONCOURSE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*}
GEODE_PRODUCT_VERSION=${GEODE_BUILD_VERSION_NUMBER}
# Prune all after '-', yielding e.g., "1.9.0"
GEODE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*}
# Prune all before '-', yielding e.g., "SNAPSHOT.325"
CONCOURSE_BUILD_SLUG=${CONCOURSE_VERSION##*-}
BUILD_ID=${CONCOURSE_VERSION##*.}
FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${CONCOURSE_BUILD_SLUG}
# Prune all before '.', yielding e.g., "SNAPSHOT"
SNAPSHOT_SLUG=${CONCOURSE_BUILD_SLUG##*.}
# Prune all before '.', yielding e.g., "325"
BUILD_ID=$(printf "%04d" ${CONCOURSE_VERSION##*.})

# Rebuild version, zero-padded
FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${SNAPSHOT_SLUG}.${BUILD_ID}

echo "Concourse VERSION is ${CONCOURSE_VERSION}"
echo "Geode product VERSION is ${GEODE_PRODUCT_VERSION}"
echo "Full product VERSION is ${FULL_PRODUCT_VERSION}"
echo "Build ID is ${BUILD_ID}"
fi

Expand Down Expand Up @@ -99,6 +107,7 @@ GRADLE_ARGS="\
${DEFAULT_GRADLE_TASK_OPTIONS} \
${GRADLE_SKIP_TASK_OPTIONS} \
${GRADLE_GLOBAL_ARGS} \
-Pversion=${FULL_PRODUCT_VERSION} \
-PbuildId=${BUILD_ID} \
build install javadoc spotlessCheck rat checkPom resolveDependencies -x test"

Expand Down
23 changes: 17 additions & 6 deletions ci/scripts/execute_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,30 @@ EMAIL_BODY="results/body"

GEODE_BUILD_VERSION_FILE=${ROOT_DIR}/geode-build-version/number
GEODE_RESULTS_VERSION_FILE=${ROOT_DIR}/results/number
GEODE_BUILD_VERSION_NUMBER=$(echo "${GRADLE_GLOBAL_ARGS}"|tr ' ' '\n' | grep "versionNumber *=" - geode/gradle.properties | awk -F "=" '{print $2; exit}' | tr -d ' ')
GEODE_BUILD_DIR=/tmp/geode-build
GEODE_PULL_REQUEST_ID_FILE=${ROOT_DIR}/geode/.git/id

if [ -e "${GEODE_PULL_REQUEST_ID_FILE}" ]; then
GEODE_PULL_REQUEST_ID=$(cat ${GEODE_PULL_REQUEST_ID_FILE})
FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}"
else
# semver resource, e.g., "1.9.0-SNAPSHOT.325"
CONCOURSE_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE})
CONCOURSE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*}
GEODE_PRODUCT_VERSION=${GEODE_BUILD_VERSION_NUMBER}
# Prune all after '-', yielding e.g., "1.9.0"
GEODE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*}
# Prune all before '-', yielding e.g., "SNAPSHOT.325"
CONCOURSE_BUILD_SLUG=${CONCOURSE_VERSION##*-}
BUILD_ID=${CONCOURSE_VERSION##*.}
FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${CONCOURSE_BUILD_SLUG}
# Prune all before '.', yielding e.g., "SNAPSHOT"
SNAPSHOT_SLUG=${CONCOURSE_BUILD_SLUG##*.}
# Prune all before '.', yielding e.g., "325"
BUILD_ID=$(printf "%04d" ${CONCOURSE_VERSION##*.})

# Rebuild version, zero-padded
FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${SNAPSHOT_SLUG}.${BUILD_ID}

echo "Concourse VERSION is ${CONCOURSE_VERSION}"
echo "Geode product VERSION is ${GEODE_PRODUCT_VERSION}"
echo "Full product VERSION is ${FULL_PRODUCT_VERSION}"
echo "Build ID is ${BUILD_ID}"
fi

Expand All @@ -68,7 +76,10 @@ SET_JAVA_HOME="export JAVA_HOME=/usr/lib/jvm/java-${JAVA_BUILD_VERSION}-openjdk-
GRADLE_COMMAND="./gradlew \
${DEFAULT_GRADLE_TASK_OPTIONS} \
${GRADLE_GLOBAL_ARGS} \
-PbuildId=${BUILD_ID} -PmavenSnapshotBucket=${MAVEN_SNAPSHOT_BUCKET} publish"
-Pversion=${FULL_PRODUCT_VERSION} \
-PbuildId=${BUILD_ID} \
-PmavenRepository=\"${MAVEN_SNAPSHOT_BUCKET}\" \
publish"

echo "${GRADLE_COMMAND}"
ssh ${SSH_OPTIONS} geode@${INSTANCE_IP_ADDRESS} "mkdir -p tmp && cd geode && ${SET_JAVA_HOME} && ${GRADLE_COMMAND}"
13 changes: 8 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@


# Version information for use by Maven artifacts
# The full version string consists of 'versionNumber + releaseQualifier + releaseType'
#
# The versionNumber follows semantic versioning conventions.
versionNumber = 1.9.0

# X.Y.Z - major.minor.patch
# The releaseQualifier uses the following conventions:
# .M? - milestone release
# -beta.? - beta release
# <blank> - release
releaseQualifier =
# The releaseType uses the following conventions:
# -SNAPSHOT - development version
# <blank> - release
releaseType = -SNAPSHOT
#
# The full version string consists of 'versionNumber + releaseQualifier + releaseType'
version = 1.9.0-SNAPSHOT

# Default Maven targets
mavenSnapshotUrl = "gcs://maven.apachegeode-ci.info/snapshots"
mavenReleaseUrl = "https://repository.apache.org/service/local/staging/deploy/maven2"

# Maven also uses the project group as a prefix.
group = org.apache.geode
Expand Down
115 changes: 49 additions & 66 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,58 +34,56 @@ publishing {
maven(MavenPublication) {
from components.java

afterEvaluate {
// uses the tasks created by nexus for sources and javadoc
if (!getTasksByName('sourcesJar', false).isEmpty()) {
artifact sourcesJar
// use the (possibly empty) Jar tasks above for sources and javadoc
artifact sourcesJar
artifact javadocJar

pom {
name = 'Apache Geode'
description = 'Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing'
url = 'http://geode.apache.org'

scm {
url = 'https://github.com/apache/geode'
connection = 'scm:git:https://github.com:apache/geode.git'
developerConnection = 'scm:git:https://github.com:apache/geode.git'
}
if (!getTasksByName('javadocJar', false).isEmpty()) {
artifact javadocJar
}

pom {
name = 'Apache Geode'
description = 'Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing'
url = 'http://geode.apache.org'

scm {
url = 'https://github.com/apache/geode'
connection = 'scm:git:https://github.com:apache/geode.git'
developerConnection = 'scm:git:https://github.com:apache/geode.git'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
withXml {
// This black magic checks to see if a dependency has the flag ext.optional=true
// set on it, and if so marks the dependency as optional in the maven pom
def depMap = project.configurations.compile.dependencies.collectEntries { [it.name, it] }
def runtimeDeps = project.configurations.runtime.dependencies.collectEntries {
[it.name, it]
}

withXml {
//This black magic checks to see if a dependency has the flag ext.optional=true
//set on it, and if so marks the dependency as optional in the maven pom
def depMap = project.configurations.compile.dependencies.collectEntries { [it.name, it] }
def runtimeDeps = project.configurations.runtime.dependencies.collectEntries { [it.name, it] }
def runtimeOnlyDeps = project.configurations.runtimeOnly.dependencies.collectEntries { [it.name, it] }
depMap.putAll(runtimeDeps)
depMap.putAll(runtimeOnlyDeps)
asNode().dependencies.dependency.findAll {
def dep = depMap.get(it.artifactId.text())
return dep?.hasProperty('optional') && dep.optional
}.each {
if (it.optional) {
it.optional.value = 'true'
} else {
it.appendNode('optional', 'true')
}
def runtimeOnlyDeps = project.configurations.runtimeOnly.dependencies.collectEntries {
[it.name, it]
}
depMap.putAll(runtimeDeps)
depMap.putAll(runtimeOnlyDeps)
asNode().dependencies.dependency.findAll {
def dep = depMap.get(it.artifactId.text())
return dep?.hasProperty('optional') && dep.optional
}.each {
if (it.optional) {
it.optional.value = 'true'
} else {
it.appendNode('optional', 'true')
}
}
}
pom {
withXml {
def elem = asElement()
def hdr = elem.ownerDocument().createComment(
'''

withXml {
def elem = asElement()
def hdr = elem.ownerDocument().createComment(
'''
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
Expand All @@ -101,34 +99,19 @@ publishing {
See the License for the specific language governing permissions and
limitations under the License.
''')
elem.insertBefore(hdr, elem.firstChild)
}
elem.insertBefore(hdr, elem.firstChild)
}
}
}
}
repositories {
maven {
if (project.hasProperty("mavenRepository")) {
url = project.mavenRepository
} else if (project.isReleaseVersion) {
url = "https://repository.apache.org/service/local/staging/deploy/maven2"
} else if (project.hasProperty("mavenSnapshotBucket")) {
// If testing from a non-GCE instance, then the shell needs service-account creds
// following the instructions at https://cloud.google.com/docs/authentication/production
url = "gcs://$project.mavenSnapshotBucket/snapshots"
} else {
url = "gcs://maven.apachegeode-ci.info/snapshots"
}
if (!url.toString().startsWith("gcs:")) {
credentials {
if (project.hasProperty("mavenUsername")) {
username = project.mavenUsername
}
if (project.hasProperty("mavenPassword")) {
password = project.mavenPassword
}
}
// Use specified mavenRepository if provided, else use release or snapshot defaults.
url = project.findProperty("mavenRepository") ||
project.isReleaseVersion ? project.mavenReleaseUrl : project.mavenSnapshotUrl
credentials {
username project.findProperty("mavenUsername")
password project.findProperty("mavenPassword")
}
}
}
Expand Down

0 comments on commit 50ea625

Please sign in to comment.