@@ -68,9 +68,13 @@ def buildAndTest(nodeLabel, target, rakeEnv, encrypted) {
6868}
6969
7070@NonCPS
71- def isReleaseVersion (versionFile ) {
72- def versionMatcher = versionFile =~ / #define CLOUDANT_SYNC_VERSION \" (.*)\" /
73- return versionMatcher. matches() && ! versionMatcher. group(1 ). toUpperCase(Locale . ENGLISH ). contains(" SNAPSHOT" )
71+ def getVersion (versionFile ) {
72+ def versionMatcher = versionFile =~ / #define CLOUDANT_SYNC_VERSION "(.*)"/
73+ return versionMatcher[0 ][1 ]
74+ }
75+
76+ def isReleaseVersion (version ) {
77+ return ! version. toUpperCase(Locale . ENGLISH ). contains(" SNAPSHOT" )
7478}
7579
7680stage(' Checkout' ) {
@@ -121,20 +125,29 @@ stage('Publish') {
121125 node {
122126 checkout scm // re-checkout to be able to git tag
123127
124- // read the version name
128+ // read the version string
125129 def versionFile = readFile(' CDTDatastore/Version.h' ). trim()
130+ def version = getVersion(versionFile)
126131
127132 // if it is a release build then do the git tagging
128- if (isReleaseVersion(versionFile )) {
133+ if (isReleaseVersion(version )) {
129134
135+ def inMessage = false
130136 // Read the CHANGELOG.md to get the tag message
131137 tagMessage = ' '
138+ // find the message following the first "##" header
132139 for (line in readFile(' CHANGELOG.md' ). readLines()) {
133- if (! ' ' . equals(line)) {
140+ if (line =~ / ^##/ ) {
141+ if (! inMessage) {
142+ inMessage = true
143+ continue
144+ } else {
145+ break
146+ }
147+ }
148+ if (inMessage) {
134149 // append the line to the tagMessage
135150 tagMessage = " ${ tagMessage}${ line} \n "
136- } else {
137- break
138151 }
139152 }
140153
0 commit comments