fix: android ci/cd fix

This commit is contained in:
misha
2026-11-17 14:03:39 +03:00
parent 215224f458
commit 8f0ec6d2a3

View File

@@ -118,19 +118,34 @@ jobs:
run: |
FLUTTER_DIR="${{ env.my_local_cache_dir }}flutter"
EXPECTED_VERSION="${{ env.flutter_version }}"
echo "Checking Flutter at $FLUTTER_DIR (need ${EXPECTED_VERSION})"
CACHED_VERSION=""
if [ -x "$FLUTTER_DIR/bin/flutter" ]; then
CACHED_VERSION="$("$FLUTTER_DIR/bin/flutter" --version 2>/dev/null | head -n 1 | awk '{print $2}')"
if [ -d "$FLUTTER_DIR" ]; then
git config --global --add safe.directory "$FLUTTER_DIR" || true
# flutter --version writes several lines; with pipefail, head closes
# the pipe and the step exits before any log line.
set +e
set +o pipefail
CACHED_VERSION="$(git -C "$FLUTTER_DIR" describe --tags --exact-match 2>/dev/null)"
CACHED_VERSION="${CACHED_VERSION#v}"
if [ -z "$CACHED_VERSION" ] && [ -x "$FLUTTER_DIR/bin/flutter" ]; then
VERSION_LINE="$("$FLUTTER_DIR/bin/flutter" --version 2>&1 | head -n 1)"
echo "flutter --version: ${VERSION_LINE:-<empty>}"
CACHED_VERSION="$(printf '%s\n' "$VERSION_LINE" | awk '{print $2}')"
fi
set -e
set -o pipefail
fi
echo "Cached Flutter version: '${CACHED_VERSION:-none}'"
if [ "$CACHED_VERSION" != "$EXPECTED_VERSION" ]; then
echo "Flutter cache miss (have '${CACHED_VERSION:-none}', need '${EXPECTED_VERSION}')"
rm -rf "$FLUTTER_DIR"
echo "Downloading Flutter ${EXPECTED_VERSION}..."
curl -fsSL -o /tmp/flutter.tar.xz "https://storage.googleapis.com/flutter_infra_release/releases/${{ env.flutter_channel }}/linux/flutter_linux_${EXPECTED_VERSION}-${{ env.flutter_channel }}.tar.xz"
rm -rf "$FLUTTER_DIR"
curl -fL --retry 3 --retry-delay 2 -o /tmp/flutter.tar.xz "https://storage.googleapis.com/flutter_infra_release/releases/${{ env.flutter_channel }}/linux/flutter_linux_${EXPECTED_VERSION}-${{ env.flutter_channel }}.tar.xz"
echo "Extracting Flutter..."
mkdir -p "${{ env.my_local_cache_dir }}"
tar xf /tmp/flutter.tar.xz -C "${{ env.my_local_cache_dir }}"
rm /tmp/flutter.tar.xz
git config --global --add safe.directory "$FLUTTER_DIR" || true
else
echo "Flutter ${EXPECTED_VERSION} already cached at $FLUTTER_DIR"
fi