@@ -249,32 +249,17 @@ jobs:
249249 - name : Extract version from build.gradle
250250 id : extract_version
251251 run : |
252- # Extract the base OpenSearch version from build.gradle
253- OPENSEARCH_VERSION=$(grep -o 'opensearch_version = System.getProperty("opensearch.version", "[^"]*' build.gradle | sed 's/.*"\(.*\)"/\1/')
252+ # Extract the opensearch_version from the property declaration in build.gradle
253+ OPENSEARCH_VERSION=$(grep 'opensearch_version =' build.gradle | awk -F'"' '{print $(NF-1)}')
254+ echo "opensearch_version: ${OPENSEARCH_VERSION}"
254255
255- # Extract the base version without snapshot or other qualifiers
256- BASE_VERSION=$(echo $OPENSEARCH_VERSION | cut -d'-' -f1)
256+ # Get the first part before any dash (equivalent to tokenize('-')[0] in Groovy)
257+ BASE_VERSION=$(echo "$OPENSEARCH_VERSION" | cut -d'-' -f1)
258+ echo "Base version: ${BASE_VERSION}"
257259
258- # OpenSearch SQL version follows pattern: <base_version>.0
259- VERSION="${BASE_VERSION}.0"
260-
261- # Check if it's a snapshot (true by default in build.gradle)
262- IS_SNAPSHOT=$(grep -o 'isSnapshot = "[^"]*' build.gradle | sed 's/.*"\(.*\)"/\1/')
263- if [[ "$IS_SNAPSHOT" == "true" ]]; then
264- VERSION="${VERSION}-SNAPSHOT"
265- fi
266-
267- # Check for version qualifier
268- BUILD_VERSION_QUALIFIER=$(grep -o 'buildVersionQualifier = System.getProperty("build.version_qualifier", "[^"]*' build.gradle | sed 's/.*"\(.*\)"/\1/')
269- if [[ -n "$BUILD_VERSION_QUALIFIER" ]]; then
270- # Insert qualifier before -SNAPSHOT if present
271- if [[ "$VERSION" == *"-SNAPSHOT"* ]]; then
272- VERSION="${VERSION/-SNAPSHOT/}"
273- VERSION="${VERSION}-${BUILD_VERSION_QUALIFIER}-SNAPSHOT"
274- else
275- VERSION="${VERSION}-${BUILD_VERSION_QUALIFIER}"
276- fi
277- fi
260+ # Form the version as in build.gradle allprojects block
261+ # According to build.gradle, version = opensearch_version.tokenize('-')[0] + '.0' + '-SNAPSHOT'
262+ VERSION="${BASE_VERSION}.0-SNAPSHOT"
278263
279264 echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
280265 echo "Extracted version: ${VERSION}"
0 commit comments