From 7ecaf79c6638d1a90fd60a0fa13046af24f0b015 Mon Sep 17 00:00:00 2001 From: josephj Date: Thu, 5 Sep 2024 17:20:39 +0200 Subject: [PATCH] Update version name fetching script COAND-977 --- .github/workflows/publish_release.yml | 4 +--- build.gradle | 12 +++++++++++- scripts/version_name.sh | 19 ------------------- 3 files changed, 12 insertions(+), 23 deletions(-) delete mode 100755 scripts/version_name.sh diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 2eae1e7f7e..5ecb39c3ff 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -58,10 +58,8 @@ jobs: # Get the version name from a script and save to environment variable. - name: Set PROJECT_VERSION run: | - echo "▸ Set run permission." - chmod +x scripts/version_name.sh echo "▸ Getting version name" - PROJECT_VERSION=$(./scripts/version_name.sh) + PROJECT_VERSION=$(${{github.workspace}}/gradlew -q printVersionName) echo "▸ Variable PROJECT_VERSION set to: ${PROJECT_VERSION}" echo "▸ Adding PROJECT_VERSION variable with: $PROJECT_VERSION" echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV diff --git a/build.gradle b/build.gradle index 6b8ae54900..77ef0249c2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { alias libs.plugins.android.application apply false alias libs.plugins.android.library apply false - alias libs.plugins.jetbrains.kotlin.android apply false + alias libs.plugins.jetbrains.kotlin.android apply false alias libs.plugins.ksp apply false alias libs.plugins.hilt apply false alias libs.plugins.detekt @@ -74,4 +74,14 @@ subprojects { } } +tasks.register("printVersionName") { + def version_validation_regex = "^[0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,2}(-(alpha|beta|rc)[0-9]{2}){0,1}\$" + def version_name = libs.versions.version.name.get() + if (version_name ==~ version_validation_regex) { + println version_name + } else { + throw new GradleException("Error: invalid version name [$version_name], please validate that the specified version follows the regex $version_validation_regex") + } +} + apply from: file('config/gradle/dependencyGraph.gradle') diff --git a/scripts/version_name.sh b/scripts/version_name.sh deleted file mode 100755 index 4ef85e79f3..0000000000 --- a/scripts/version_name.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -function release_version() { -# TODO: read from version catalog - local build_file="${GITHUB_WORKSPACE}/dependencies.gradle" - local version_name_key="version_name" - local version_name_regex="^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-(alpha|beta|rc)[0-9]{2}){0,1}$" - - local version=$(sed -n "s/.*${version_name_key}[[:space:]]*=[[:space:]]*[\"\']\(.*\)[\"\'].*/\1/p" ${build_file}) - - if [[ ! ${version} =~ ${version_name_regex} ]]; then - echo "Error: invalid version name [$version], please validate that [$version_name_key] at [$build_file] follows regex $version_name_regex ." - exit 1 - fi - - echo "$version" -} - -release_version