From d87a704d4d03a8610d5c1f9c8340eb455af3d2d1 Mon Sep 17 00:00:00 2001 From: Prudhvi Godithi Date: Tue, 26 Jul 2022 16:37:52 -0400 Subject: [PATCH] Staging for version increment automation (#391) * Version increment automation Signed-off-by: pgodithi * Version increment automation Signed-off-by: pgodithi * Version increment automation Signed-off-by: pgodithi * Version increment automation Signed-off-by: pgodithi * Version increment automation Signed-off-by: pgodithi * Version increment automation: task rename updateVersion Signed-off-by: pgodithi (cherry picked from commit 6667bfb483343d7e86bba99dc6ead5351213ae21) Signed-off-by: prudhvigodithi --- reports-scheduler/build.gradle | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/reports-scheduler/build.gradle b/reports-scheduler/build.gradle index fbd098ee..c58a63df 100644 --- a/reports-scheduler/build.gradle +++ b/reports-scheduler/build.gradle @@ -488,3 +488,21 @@ if (!usingRemoteCluster && !usingMultiNode) { } apply from: 'build-tools/pkgbuild.gradle' + +// updateVersion: Task to auto increment to the next development iteration +task updateVersion { + onlyIf { System.getProperty('newVersion') } + doLast { + ext.newVersion = System.getProperty('newVersion') + println "Setting version to ${newVersion}." + // String tokenization to support -SNAPSHOT + ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true) + ant.replaceregexp(file:'../.github/workflows/dashboards-reports-test-and-build-workflow.yml', match:'OPENSEARCH_PLUGIN_VERSION: \\d+.\\d+.\\d+.\\d+', replace:'OPENSEARCH_PLUGIN_VERSION: ' + newVersion.tokenize('-')[0] + '.0', flags:'g', byline:true) + ant.replaceregexp(file:'../.github/workflows/draft-release-notes-workflow.yml', match:'version: \\d+.\\d+.\\d+.\\d+', replace:'version: ' + newVersion.tokenize('-')[0] + '.0', flags:'g', byline:true) + // Match key version in JSON files. + ant.replaceregexp(file:'../dashboards-reports/opensearch_dashboards.json', match:'"version": "\\d+.\\d+.\\d+.\\d+', replace:'"version": ' + '"' + newVersion.tokenize('-')[0] + '.0', flags:'g', byline:true) + ant.replaceregexp(file:'../dashboards-reports/package.json', match:'"version": "\\d+.\\d+.\\d+.\\d+', replace:'"version": ' + '"' + newVersion.tokenize('-')[0] + '.0', flags:'g', byline:true) + // Match key opensearchDashboardsVersion in JSON files. + ant.replaceregexp(file:'../dashboards-reports/opensearch_dashboards.json', match:'"opensearchDashboardsVersion": "\\d+.\\d+.\\d+', replace:'"opensearchDashboardsVersion": ' + '"' + newVersion.tokenize('-')[0], flags:'g', byline:true) + } +}