Skip to content

Commit

Permalink
Update version name fetching script
Browse files Browse the repository at this point in the history
COAND-977
  • Loading branch information
jreij committed Sep 6, 2024
1 parent 0f109b1 commit 4fb1a3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -74,4 +74,8 @@ subprojects {
}
}

tasks.register("printVersionName") {
println "${libs.versions.version.name.get()}"
}

apply from: file('config/gradle/dependencyGraph.gradle')
12 changes: 5 additions & 7 deletions scripts/version_name.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/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_validation_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})
local version=$(${{github.workspace}}/gradlew -q printVersionName)

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 ."

if [[ ! ${version} =~ ${version_validation_regex} ]]; then
echo "Error: invalid version name [$version], please validate that the specified version follows the regex $version_validation_regex ."
exit 1
fi

Expand Down

0 comments on commit 4fb1a3c

Please sign in to comment.