Skip to content

Commit

Permalink
[Backport 1.3] Staging for version increment automation (#2029)
Browse files Browse the repository at this point in the history
* Staging for version increment automation (#1932)

Incorporating changes from
#1741

Specifically build.gradle changes, see 2744081#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7

Signed-off-by: pgodithi <[email protected]>
Signed-off-by: Peter Nied <[email protected]>
Co-authored-by: Prudhvi Godithi <[email protected]>
(cherry picked from commit 235d256)
  • Loading branch information
peternied authored Sep 28, 2022
1 parent 5829eaa commit 6b32c47
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 10 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,49 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./build/jacoco/test/jacocoTestReport.xml

build-artifact-names:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: 11

- run: |
security_plugin_version=$(./gradlew properties -q | grep -E '^version:' | awk '{print $2}')
security_plugin_version_no_snapshot=$(echo $security_plugin_version | sed 's/-SNAPSHOT//g')
security_plugin_version_only_number=$(echo $security_plugin_version_no_snapshot | cut -d- -f1)
test_qualifier=alpha2
echo "SECURITY_PLUGIN_VERSION=$security_plugin_version" >> $GITHUB_ENV
echo "SECURITY_PLUGIN_VERSION_NO_SNAPSHOT=$security_plugin_version_no_snapshot" >> $GITHUB_ENV
echo "SECURITY_PLUGIN_VERSION_ONLY_NUMBER=$security_plugin_version_only_number" >> $GITHUB_ENV
echo "TEST_QUALIFIER=$test_qualifier" >> $GITHUB_ENV
- run: |
echo ${{ env.SECURITY_PLUGIN_VERSION }}
echo ${{ env.SECURITY_PLUGIN_VERSION_NO_SNAPSHOT }}
echo ${{ env.SECURITY_PLUGIN_VERSION_ONLY_NUMBER }}
echo ${{ env.TEST_QUALIFIER }}
- run: ./gradlew clean assemble && test -s ./build/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION }}.jar

- run: ./gradlew clean assemble -Dbuild.snapshot=false && test -s ./build/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION_NO_SNAPSHOT }}.jar

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

- 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()
40 changes: 30 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,18 @@ repositories {
}

ext {
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
opensearch_version = System.getProperty("opensearch.version", "1.3.6-SNAPSHOT")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
opensearch_build_nosnapshot = opensearch_build
}
if (isSnapshot) {
opensearch_build += "-SNAPSHOT"
}
}

configurations.all {
Expand Down Expand Up @@ -123,13 +134,8 @@ dependencies {
compileOnly "org.opensearch:opensearch:${opensearch_version}"
}

ext {
securityPluginVersion = '1.3.6.0'
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
}

group = 'org.opensearch'
version = "${securityPluginVersion}" + (isSnapshot ? "-SNAPSHOT" : "")
version = opensearch_build
description = 'OpenSearch Security'


Expand Down Expand Up @@ -304,16 +310,13 @@ task bundleSecurityAdminStandaloneTarGz(dependsOn: jar, type: Tar) {
}

task createPluginDescriptor() {
if (opensearch_version.contains("-SNAPSHOT")) {
opensearch_version=opensearch_version.substring(0, opensearch_version.length() - 9)
}
List<String> descriptorProperties = [
"description=Provide access control related features for OpenSearch",
"version=${version}",
"name=opensearch-security",
"classname=org.opensearch.security.OpenSearchSecurityPlugin",
"java.version=${java.targetCompatibility}",
"opensearch.version=${opensearch_version}",
"opensearch.version=${version_tokens[0]}",
]

new File("plugin-descriptor.properties").text = descriptorProperties.join ("\n")
Expand Down Expand Up @@ -374,3 +377,20 @@ buildDeb {
arch = 'all'
archiveName "${packageName}-${version}.deb"
}

// 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
// No BWC tests in this major release
}
}
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}

0 comments on commit 6b32c47

Please sign in to comment.