fix(ci): redirect script messages to stderr and support version format X.Y.Z-suffix
Fixed workflow failure by ensuring only data goes to stdout, not informational messages. Also added support for version format X.Y.Z-suffix in addition to X.Y.Z+build.
This commit is contained in:
18
.github/scripts/extract-version.sh
vendored
18
.github/scripts/extract-version.sh
vendored
@@ -8,7 +8,7 @@ set -e
|
||||
APP=$1
|
||||
|
||||
if [ -z "$APP" ]; then
|
||||
echo "❌ Error: App parameter required (worker-mobile-app or client-mobile-app)"
|
||||
echo "❌ Error: App parameter required (worker-mobile-app or client-mobile-app)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -23,26 +23,26 @@ fi
|
||||
|
||||
# Check if pubspec exists
|
||||
if [ ! -f "$PUBSPEC_PATH" ]; then
|
||||
echo "❌ Error: pubspec.yaml not found at $PUBSPEC_PATH"
|
||||
echo "❌ Error: pubspec.yaml not found at $PUBSPEC_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract version (format: X.Y.Z+buildNumber)
|
||||
# Extract version (format: X.Y.Z+buildNumber or X.Y.Z-suffix)
|
||||
VERSION_LINE=$(grep "^version:" "$PUBSPEC_PATH")
|
||||
if [ -z "$VERSION_LINE" ]; then
|
||||
echo "❌ Error: Could not find version in $PUBSPEC_PATH"
|
||||
echo "❌ Error: Could not find version in $PUBSPEC_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract just the semantic version (before the +)
|
||||
VERSION=$(echo "$VERSION_LINE" | sed 's/version: *//' | sed 's/+.*//' | tr -d ' ')
|
||||
# Extract just the semantic version (before the + or -)
|
||||
VERSION=$(echo "$VERSION_LINE" | sed 's/version: *//' | sed 's/[+\-].*//' | tr -d ' ')
|
||||
|
||||
# Validate version format
|
||||
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "❌ Error: Invalid version format in pubspec.yaml: $VERSION"
|
||||
echo "Expected format: X.Y.Z (e.g., 0.1.0)"
|
||||
echo "❌ Error: Invalid version format in pubspec.yaml: $VERSION" >&2
|
||||
echo "Expected format: X.Y.Z (e.g., 0.1.0)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Extracted version from $PUBSPEC_PATH: $VERSION"
|
||||
echo "✅ Extracted version from $PUBSPEC_PATH: $VERSION" >&2
|
||||
echo "$VERSION"
|
||||
|
||||
Reference in New Issue
Block a user