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:
12
.github/scripts/attach-apk-to-release.sh
vendored
12
.github/scripts/attach-apk-to-release.sh
vendored
@@ -28,8 +28,8 @@ VERSION="$4"
|
||||
ENV="$5"
|
||||
|
||||
if [ -z "$TAG_NAME" ] || [ -z "$APP" ] || [ -z "$APP_NAME" ] || [ -z "$VERSION" ] || [ -z "$ENV" ]; then
|
||||
echo "❌ Error: Missing required arguments"
|
||||
echo "Usage: $0 <tag_name> <app> <app_name> <version> <environment>"
|
||||
echo "❌ Error: Missing required arguments" >&2
|
||||
echo "Usage: $0 <tag_name> <app> <app_name> <version> <environment>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -37,8 +37,8 @@ fi
|
||||
APK_PATH="apps/mobile/apps/${APP_NAME}/build/app/outputs/flutter-apk/app-release.apk"
|
||||
|
||||
if [ ! -f "$APK_PATH" ]; then
|
||||
echo "❌ Error: APK not found at $APK_PATH"
|
||||
echo "Searching for APK files..."
|
||||
echo "❌ Error: APK not found at $APK_PATH" >&2
|
||||
echo "Searching for APK files..." >&2
|
||||
find apps/mobile/apps/${APP_NAME} -name "*.apk"
|
||||
exit 1
|
||||
fi
|
||||
@@ -54,7 +54,7 @@ fi
|
||||
cp "$APK_PATH" "/tmp/$APK_NAME"
|
||||
|
||||
# Upload to GitHub Release
|
||||
echo "📤 Uploading $APK_NAME to release $TAG_NAME..."
|
||||
echo "📤 Uploading $APK_NAME to release $TAG_NAME..." >&2
|
||||
gh release upload "$TAG_NAME" "/tmp/$APK_NAME" --clobber
|
||||
|
||||
echo "✅ APK attached to release: $APK_NAME"
|
||||
echo "✅ APK attached to release: $APK_NAME" >&2
|
||||
|
||||
14
.github/scripts/extract-release-notes.sh
vendored
14
.github/scripts/extract-release-notes.sh
vendored
@@ -11,8 +11,8 @@ TAG_NAME=$4
|
||||
OUTPUT_FILE=$5
|
||||
|
||||
if [ -z "$APP" ] || [ -z "$VERSION" ] || [ -z "$ENV" ] || [ -z "$TAG_NAME" ] || [ -z "$OUTPUT_FILE" ]; then
|
||||
echo "❌ Error: Missing required parameters"
|
||||
echo "Usage: ./extract-release-notes.sh <app> <version> <environment> <tag_name> <output_file>"
|
||||
echo "❌ Error: Missing required parameters" >&2
|
||||
echo "Usage: ./extract-release-notes.sh <app> <version> <environment> <tag_name> <output_file>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -27,14 +27,14 @@ fi
|
||||
|
||||
# Try to extract release notes for this version
|
||||
if [ -f "$CHANGELOG_PATH" ]; then
|
||||
echo "📝 Found CHANGELOG at $CHANGELOG_PATH"
|
||||
echo "📝 Found CHANGELOG at $CHANGELOG_PATH" >&2
|
||||
|
||||
# Extract section for this version
|
||||
# Look for ## [VERSION] and collect until next ## [ or end of file
|
||||
NOTES=$(awk "/## \[${VERSION}\]/,/^## \[/" "$CHANGELOG_PATH" | sed '1d;$d' | sed '/^$/d')
|
||||
|
||||
if [ -z "$NOTES" ]; then
|
||||
echo "⚠️ Warning: No CHANGELOG entry found for version $VERSION"
|
||||
echo "⚠️ Warning: No CHANGELOG entry found for version $VERSION" >&2
|
||||
NOTES="Release $VERSION for $APP_NAME
|
||||
|
||||
⚠️ No CHANGELOG entry found for this version. Please update the CHANGELOG manually.
|
||||
@@ -42,7 +42,7 @@ if [ -f "$CHANGELOG_PATH" ]; then
|
||||
**Environment:** $ENV
|
||||
**Tag:** $TAG_NAME"
|
||||
else
|
||||
echo "✅ Extracted release notes for version $VERSION"
|
||||
echo "✅ Extracted release notes for version $VERSION" >&2
|
||||
NOTES="# $APP_NAME - Release $VERSION
|
||||
|
||||
$NOTES
|
||||
@@ -53,7 +53,7 @@ $NOTES
|
||||
**Tag:** $TAG_NAME"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ Warning: CHANGELOG not found at $CHANGELOG_PATH"
|
||||
echo "⚠️ Warning: CHANGELOG not found at $CHANGELOG_PATH" >&2
|
||||
NOTES="Release $VERSION for $APP_NAME
|
||||
|
||||
**Environment:** $ENV
|
||||
@@ -62,4 +62,4 @@ fi
|
||||
|
||||
# Save to output file
|
||||
echo "$NOTES" > "$OUTPUT_FILE"
|
||||
echo "✅ Release notes saved to $OUTPUT_FILE"
|
||||
echo "✅ Release notes saved to $OUTPUT_FILE" >&2
|
||||
|
||||
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"
|
||||
|
||||
4
.github/scripts/generate-tag-name.sh
vendored
4
.github/scripts/generate-tag-name.sh
vendored
@@ -9,8 +9,8 @@ ENV=$2
|
||||
VERSION=$3
|
||||
|
||||
if [ -z "$APP" ] || [ -z "$ENV" ] || [ -z "$VERSION" ]; then
|
||||
echo "❌ Error: Missing required parameters"
|
||||
echo "Usage: ./generate-tag-name.sh <app> <environment> <version>"
|
||||
echo "❌ Error: Missing required parameters" >&2
|
||||
echo "Usage: ./generate-tag-name.sh <app> <environment> <version>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
22
.github/scripts/setup-apk-signing.sh
vendored
22
.github/scripts/setup-apk-signing.sh
vendored
@@ -32,12 +32,12 @@ ENV="$2"
|
||||
TEMP_DIR="$3"
|
||||
|
||||
if [ -z "$APP" ] || [ -z "$ENV" ] || [ -z "$TEMP_DIR" ]; then
|
||||
echo "❌ Error: Missing required arguments"
|
||||
echo "Usage: $0 <app> <environment> <temp_dir>"
|
||||
echo "❌ Error: Missing required arguments" >&2
|
||||
echo "Usage: $0 <app> <environment> <temp_dir>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🔐 Setting up Android signing for $APP in $ENV environment..."
|
||||
echo "🔐 Setting up Android signing for $APP in $ENV environment..." >&2
|
||||
|
||||
# Determine which keystore to use
|
||||
if [ "$APP" = "worker-mobile-app" ]; then
|
||||
@@ -68,9 +68,9 @@ KEY_PASSWORD="${!KEY_PASSWORD_VAR}"
|
||||
|
||||
# Check if secrets are configured
|
||||
if [ -z "$KEYSTORE_BASE64" ]; then
|
||||
echo "⚠️ WARNING: Keystore secret $KEYSTORE_BASE64_VAR is not configured!"
|
||||
echo "⚠️ APK will be built UNSIGNED for $ENV environment."
|
||||
echo "⚠️ Please configure GitHub Secrets as documented in docs/RELEASE/APK_SIGNING_SETUP.md"
|
||||
echo "⚠️ WARNING: Keystore secret $KEYSTORE_BASE64_VAR is not configured!" >&2
|
||||
echo "⚠️ APK will be built UNSIGNED for $ENV environment." >&2
|
||||
echo "⚠️ Please configure GitHub Secrets as documented in docs/RELEASE/APK_SIGNING_SETUP.md" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -83,12 +83,12 @@ KEYSTORE_PATH="$KEYSTORE_DIR/release.jks"
|
||||
echo "$KEYSTORE_BASE64" | base64 -d > "$KEYSTORE_PATH"
|
||||
|
||||
if [ ! -f "$KEYSTORE_PATH" ]; then
|
||||
echo "❌ Failed to decode keystore!"
|
||||
echo "❌ Failed to decode keystore!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Keystore decoded successfully"
|
||||
echo "📦 Keystore size: $(ls -lh "$KEYSTORE_PATH" | awk '{print $5}')"
|
||||
echo "✅ Keystore decoded successfully" >&2
|
||||
echo "📦 Keystore size: $(ls -lh "$KEYSTORE_PATH" | awk '{print $5}')" >&2
|
||||
|
||||
# Export environment variables for build.gradle.kts
|
||||
# Using CodeMagic-compatible variable names
|
||||
@@ -98,5 +98,5 @@ echo "CM_KEYSTORE_PASSWORD_${APP_NAME}=$KEYSTORE_PASSWORD" >> $GITHUB_ENV
|
||||
echo "CM_KEY_ALIAS_${APP_NAME}=$KEY_ALIAS" >> $GITHUB_ENV
|
||||
echo "CM_KEY_PASSWORD_${APP_NAME}=$KEY_PASSWORD" >> $GITHUB_ENV
|
||||
|
||||
echo "✅ Signing environment configured for $APP_NAME ($ENV environment)"
|
||||
echo "🔑 Using key alias: $KEY_ALIAS"
|
||||
echo "✅ Signing environment configured for $APP_NAME ($ENV environment)" >&2
|
||||
echo "🔑 Using key alias: $KEY_ALIAS" >&2
|
||||
|
||||
34
.github/scripts/verify-apk-signature.sh
vendored
34
.github/scripts/verify-apk-signature.sh
vendored
@@ -18,41 +18,41 @@ set -e
|
||||
APK_PATH="$1"
|
||||
|
||||
if [ -z "$APK_PATH" ]; then
|
||||
echo "❌ Error: Missing APK path"
|
||||
echo "Usage: $0 <apk_path>"
|
||||
echo "❌ Error: Missing APK path" >&2
|
||||
echo "Usage: $0 <apk_path>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$APK_PATH" ]; then
|
||||
echo "❌ APK not found at: $APK_PATH"
|
||||
echo "❌ APK not found at: $APK_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🔍 Verifying APK signature..."
|
||||
echo "🔍 Verifying APK signature..." >&2
|
||||
|
||||
# Check if APK is signed
|
||||
if jarsigner -verify -verbose "$APK_PATH" 2>&1 | grep -q "jar verified"; then
|
||||
echo "✅ APK is properly signed!"
|
||||
echo "✅ APK is properly signed!" >&2
|
||||
|
||||
# Extract certificate details
|
||||
echo ""
|
||||
echo "📜 Certificate Details:"
|
||||
echo "" >&2
|
||||
echo "📜 Certificate Details:" >&2
|
||||
jarsigner -verify -verbose -certs "$APK_PATH" 2>&1 | grep -A 3 "X.509" || true
|
||||
|
||||
# Get signer info
|
||||
echo ""
|
||||
echo "🔑 Signer Information:"
|
||||
echo "" >&2
|
||||
echo "🔑 Signer Information:" >&2
|
||||
keytool -printcert -jarfile "$APK_PATH" | head -n 15
|
||||
|
||||
else
|
||||
echo "⚠️ WARNING: APK signature verification failed or APK is unsigned!"
|
||||
echo ""
|
||||
echo "This may happen if:"
|
||||
echo " 1. GitHub Secrets are not configured for this environment"
|
||||
echo " 2. Keystore credentials are incorrect"
|
||||
echo " 3. Build configuration didn't apply signing"
|
||||
echo ""
|
||||
echo "See: docs/RELEASE/APK_SIGNING_SETUP.md for setup instructions"
|
||||
echo "⚠️ WARNING: APK signature verification failed or APK is unsigned!" >&2
|
||||
echo "" >&2
|
||||
echo "This may happen if:" >&2
|
||||
echo " 1. GitHub Secrets are not configured for this environment" >&2
|
||||
echo " 2. Keystore credentials are incorrect" >&2
|
||||
echo " 3. Build configuration didn't apply signing" >&2
|
||||
echo "" >&2
|
||||
echo "See: docs/RELEASE/APK_SIGNING_SETUP.md for setup instructions" >&2
|
||||
|
||||
# Don't fail the build, just warn
|
||||
# exit 1
|
||||
|
||||
Reference in New Issue
Block a user