Skip to content

Commit

Permalink
Staging for version increment automation (#1932)
Browse files Browse the repository at this point in the history
* Version increment automation

Signed-off-by: pgodithi <[email protected]>
(cherry picked from commit 235d256)
  • Loading branch information
prudhvigodithi authored and peternied committed Aug 15, 2022
1 parent 1ca7b21 commit eb2a197
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ jobs:

- run: ./gradlew clean assemble -Dbuild.version_qualifier=${{ env.TEST_QUALIFIER }} && test -s ./build/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION_ONLY_NUMBER }}-${{ env.TEST_QUALIFIER }}-SNAPSHOT.jar

- run: |
## EXISTING_OS_VERSION outputs the major version, example as 2
EXISTING_OS_VERSION=$(./gradlew properties | grep opensearch.version | cut -d':' -f2- | awk '{$1=$1};1' | cut -d '-' -f1 | cut -d '.' -f1)
## INCREMENT_OS_VERSION in an increment of 1, example if EXISTING_OS_VERSION is 2, INCREMENT_OS_VERSION is 3
INCREMENT_OS_VERSION=$((++EXISTING_OS_VERSION))
./gradlew clean updateVersion -DnewVersion=$INCREMENT_OS_VERSION.0.0-SNAPSHOT
test `./gradlew properties | grep opensearch.version | cut -d':' -f2- | awk '{$1=$1};1'` = $INCREMENT_OS_VERSION.0.0-SNAPSHOT
- name: List files in the build directory if there was an error
run: ls -al ./build/
if: failure()
80 changes: 80 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,83 @@ allprojects {
}
}
}

// This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name
afterEvaluate {
ospackage {
packageName = "${name}"
release = isSnapshot ? "0.1" : '1'
version = "${project.version}" - "-SNAPSHOT"

into '/usr/share/opensearch/plugins'
from(zipTree(bundlePlugin.archivePath)) {
into opensearchplugin.name
}

user 'root'
permissionGroup 'root'
fileMode 0644
dirMode 0755

requires('opensearch', versions.opensearch, EQUAL)
packager = 'Amazon'
vendor = 'Amazon'
os = 'LINUX'
prefix '/usr'

license 'ASL-2.0'
maintainer 'OpenSearch <[email protected]>'
url 'https://opensearch.org/downloads.html'
summary '''
Security plugin for OpenSearch.
Reference documentation can be found at https://opensearch.org/docs/latest/.
'''.stripIndent().replace('\n', ' ').trim()
}

buildRpm {
arch = 'NOARCH'
dependsOn 'assemble'
finalizedBy 'renameRpm'
task renameRpm(type: Copy) {
from("$buildDir/distributions")
into("$buildDir/distributions")
include archiveName
rename archiveName, "${packageName}-${version}.rpm"
doLast { delete file("$buildDir/distributions/$archiveName") }
}
}

buildDeb {
arch = 'all'
dependsOn 'assemble'
finalizedBy 'renameDeb'
task renameDeb(type: Copy) {
from("$buildDir/distributions")
into("$buildDir/distributions")
include archiveName
rename archiveName, "${packageName}-${version}.deb"
doLast { delete file("$buildDir/distributions/$archiveName") }
}
}

task buildPackages(type: GradleBuild) {
tasks = ['build', 'buildRpm', 'buildDeb']
}
}

// 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(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) {
fileset(dir: projectDir) {
// Include the required files that needs to be updated with new Version
include(name: "bwc-test/build.gradle")
}
}
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}

0 comments on commit eb2a197

Please sign in to comment.