flutter/bin/internal/update_engine_version.sh
auto-submit[bot] 34a11c405d
Reverts "Write an identical value to bin/cache/engine.stamp to prepare for migration (#164317)" (#164396)
<!-- start_original_pr_link -->
Reverts: flutter/flutter#164317
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: matanlurey
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: `bin/cache` does not exist on a fresh checkout,
and `echo bin/cache/...` will fail as a result.

This blocked the google3 roll, but would also break new checkouts of
Flutter, for regular users/contributors.
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: matanlurey
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {jtmcdole}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
Towards https://github.com/flutter/flutter/issues/164315.

This PR just writes `bin/cache/engine.stamp` identically to how
`bin/internal/engine.version` would otherwise be written, with a caveat
that _if_ `engine.version` is tracked, it is now _copied_ to
`bin/cache/engine.stamp`.

After this lands, I'll send PRs to update tooling that looks for
`engine.version` and give a heads up to the larger team (i.e. Dart HH
bot or whomever we will break by doing this).
<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
2025-02-28 20:16:36 +00:00

69 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2014 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.
# Want to test this script?
# $ cd dev/tools
# $ dart test test/update_engine_version_test.dart
# ---------------------------------- NOTE ---------------------------------- #
#
# Please keep the logic in this file consistent with the logic in the
# `update_engine_version.ps1` script in the same directory to ensure that Flutter
# continues to work across all platforms!
#
# -------------------------------------------------------------------------- #
set -e
# Allow overriding the intended engine version via FLUTTER_PREBUILT_ENGINE_VERSION.
#
# This is for systems, such as Github Actions, where we know ahead of time the
# base-ref we want to use (to download the engine binaries and avoid trying
# to compute one below), or for the Dart HH bot, which wants to try the current
# Flutter framework/engine with a different Dart SDK.
#
# This environment variable is EXPERIMENTAL. If you are not on the Flutter infra
# or Dart infra teams, this code path might be removed at anytime and cease
# functioning. Please file an issue if you have workflow needs.
if [ -n "${FLUTTER_PREBUILT_ENGINE_VERSION}" ]; then
ENGINE_VERSION="${FLUTTER_PREBUILT_ENGINE_VERSION}"
fi
FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
# On stable, beta, and release tags, the engine.version is tracked by git - do not override it.
TRACKED_ENGINE="$(git -C "$FLUTTER_ROOT" ls-files bin/internal/engine.version)"
if [[ -n "$TRACKED_ENGINE" ]]; then
exit
fi
# Test for fusion repository and no environment variable override.
if [ -z "$ENGINE_VERSION" ] && [ -f "$FLUTTER_ROOT/DEPS" ] && [ -f "$FLUTTER_ROOT/engine/src/.gn" ]; then
# In a fusion repository; the engine.version comes from the git hashes.
if [ -z "${LUCI_CONTEXT}" ]; then
set +e
# Run the git command and capture the exit code
git -C "$FLUTTER_ROOT" remote get-url upstream > /dev/null 2>&1
exit_code=$?
set -e
if [[ $exit_code -eq 0 ]]; then
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" merge-base HEAD upstream/master)
else
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" merge-base HEAD origin/master)
fi
else
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" rev-parse HEAD)
fi
fi
# Write the engine version out so downstream tools know what to look for.
echo $ENGINE_VERSION > "$FLUTTER_ROOT/bin/internal/engine.version"
# The realm on CI is passed in.
if [ -n "${FLUTTER_REALM}" ]; then
echo $FLUTTER_REALM > "$FLUTTER_ROOT/bin/internal/engine.realm"
fi