blob: 7aec0393bfda65f56b67f214442dd93193135a42 [file]
# Copyright 2022 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Target for Cloud Scheduler to build `stable`.
steps:
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'bash'
args:
- '-c'
- |
set -euo pipefail
apt-get update && apt-get install -y jq
echo "Fetching Flutter release data for channel: $_CHANNEL..."
# 1. Fetch latest version for the specified channel (stable or beta)
# The -f flag on curl ensures it fails on HTTP errors.
# We pass the Cloud Build substitution $_CHANNEL as an argument to jq.
FLUTTER_VERSION=$$(curl -sf https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json | \
jq -r --arg channel "$_CHANNEL" '.current_release[$$channel] as $$hash | .releases[] | select(.hash == $$hash) | .version')
# Validate that the version was successfully parsed.
# -z "$$FLUTTER_VERSION" checks if the variable is an empty string (e.g., if jq failed entirely).
# "$$FLUTTER_VERSION" == "null" checks if jq succeeded but couldn't find the requested data in the JSON.
if [ -z "$$FLUTTER_VERSION" ] || [ "$$FLUTTER_VERSION" == "null" ]; then
echo "Error: Failed to parse $_CHANNEL Flutter version from JSON."
exit 1
fi
echo "Found $_CHANNEL Flutter version: $$FLUTTER_VERSION"
# 2. Trigger the target build with the version as a substitution
# Note: We use --region=global as found in your trigger description
gcloud builds triggers run flutter-agy-docker \
--region=global \
--branch=main \
--substitutions=_FLUTTER_VERSION="$$FLUTTER_VERSION"
substitutions:
_CHANNEL: "stable"
# Force Cloud Build to send logs directly to Cloud Logging
# instead of an autogenerated GCS bucket
options:
logging: CLOUD_LOGGING_ONLY