Skip to content

Commit eaf6939

Browse files
committed
Add script to update the git-sync image
1 parent 6cd56d2 commit eaf6939

3 files changed

Lines changed: 63 additions & 15 deletions

File tree

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ HELM_STAGING_DIR := $(OUTPUT_DIR)/third_party/helm
8989
COSIGN_VERSION := v2.4.1
9090
COSIGN := $(BIN_DIR)/cosign
9191

92-
GIT_SYNC_VERSION := v4.4.2-gke.14__linux_amd64
92+
# To automatically update, run this command:
93+
# UPDATE_TYPE=<latest-version|latest-build> make update-git-sync-image
94+
GIT_SYNC_VERSION := v4.4.2-gke.15__linux_amd64
9395
GIT_SYNC_IMAGE_NAME := gcr.io/config-management-release/git-sync:$(GIT_SYNC_VERSION)
9496

9597
OTELCONTRIBCOL_VERSION := v0.127.0-gke.6
@@ -550,6 +552,10 @@ print-%:
550552
update-debian-base-image:
551553
@./scripts/update-debian-base-image.sh
552554

555+
.PHONY: update-git-sync-image
556+
update-git-sync-image:
557+
@./scripts/update-git-sync-image.sh
558+
553559
####################################################################################################
554560
# MANUAL TESTING COMMANDS
555561

scripts/update-debian-base-image.sh

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@
1616

1717
set -euo pipefail
1818

19-
####################################################################################################
20-
# FUNCTION DECLARATIONS
21-
#
22-
# It's crucial that error messages in these functions be sent to stderr with 1>&2.
23-
# Otherwise, they will not bubble up to the make target that calls this script.
24-
25-
err() {
26-
local msg="$1"
27-
echo "${msg}" 1>&2
28-
exit 1
29-
}
30-
31-
####################################################################################################
32-
3319
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
3420
cd "${REPO_ROOT}"
3521

scripts/update-git-sync-image.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2026 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -euo pipefail
18+
19+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
20+
cd "${REPO_ROOT}"
21+
22+
UPDATE_TYPE=${UPDATE_TYPE:-latest-build}
23+
24+
# Get the current tag from the Makefile
25+
CURRENT_TAG=$(grep "^GIT_SYNC_VERSION :=" Makefile | sed 's/.*:= //')
26+
27+
if [[ "${UPDATE_TYPE}" == "latest-version" ]]; then
28+
FILTER="NOT tags:no-new-use-public-image*"
29+
GREP_PATTERN="__linux_amd64"
30+
elif [[ "${UPDATE_TYPE}" == "latest-build" ]]; then
31+
# Strip the -gke.N__linux_amd64 suffix to get the base version
32+
BASE_VERSION=${CURRENT_TAG%-gke.*__linux_amd64}
33+
FILTER="tags:${BASE_VERSION}*"
34+
GREP_PATTERN="^${BASE_VERSION}"
35+
else
36+
echo "Usage: $0 [latest-version|latest-build]" >&2
37+
exit 1
38+
fi
39+
40+
echo "Fetching $(echo "$UPDATE_TYPE" | sed 's/-/ /g') tag for git-sync"
41+
LATEST_TAG=$(gcloud container images list-tags gcr.io/config-management-release/git-sync \
42+
--filter="${FILTER}" \
43+
--format="value(tags)" | tr ',' '\n' | grep "${GREP_PATTERN}" | sort -V | tail -n 1)
44+
45+
if [ -z "${LATEST_TAG}" ]; then
46+
echo "Failed to find latest tag for git-sync" >&2
47+
exit 1
48+
fi
49+
50+
if [ "$LATEST_TAG" == "$CURRENT_TAG" ]; then
51+
echo "GIT_SYNC_VERSION is already up to date ($LATEST_TAG)."
52+
exit 0
53+
fi
54+
55+
echo "Updating GIT_SYNC_VERSION from $CURRENT_TAG to $LATEST_TAG"
56+
sed -i "s|^GIT_SYNC_VERSION := .*|GIT_SYNC_VERSION := ${LATEST_TAG}|" Makefile

0 commit comments

Comments
 (0)