fix: harden get_version_name against missing file and extraction failures
Made-with: Cursor
This commit is contained in:
12
build.sh
12
build.sh
@@ -35,7 +35,17 @@ warn() { echo -e "${YELLOW}⚠${NC} $1"; }
|
|||||||
error() { echo -e "${RED}✗${NC} $1"; }
|
error() { echo -e "${RED}✗${NC} $1"; }
|
||||||
|
|
||||||
get_version_name() {
|
get_version_name() {
|
||||||
grep 'versionName' "$GRADLE_BUILD_FILE" | head -1 | sed 's/.*"\(.*\)".*/\1/'
|
if [[ ! -f "$GRADLE_BUILD_FILE" ]]; then
|
||||||
|
error "Build file not found: $GRADLE_BUILD_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
local v
|
||||||
|
v=$(grep 'versionName' "$GRADLE_BUILD_FILE" | head -1 | sed 's/.*"\([^"]*\)".*/\1/')
|
||||||
|
if [[ -z "$v" ]]; then
|
||||||
|
error "Could not extract version from $GRADLE_BUILD_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "$v"
|
||||||
}
|
}
|
||||||
|
|
||||||
preflight_check() {
|
preflight_check() {
|
||||||
|
|||||||
Reference in New Issue
Block a user