Skip to content

Commit 34ca4b6

Browse files
Copilotphlax
andcommitted
bazel: Use bazel run //sha:replace instead of direct script call
Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
1 parent 9c17aaf commit 34ca4b6

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

.github/workflows/_release.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ jobs:
146146
SYSROOT_2_28_13_AMD64=$(compute_sha256 "sysroot-glibc2.28-libstdc++13-amd64.tar.xz")
147147
SYSROOT_2_28_13_ARM64=$(compute_sha256 "sysroot-glibc2.28-libstdc++13-arm64.tar.xz")
148148
149-
echo "Updating ${VERSIONS_FILE} using bazel/sha/replace.sh..."
149+
echo "Updating ${VERSIONS_FILE} using bazel //sha:replace..."
150150
151151
# Build replacement pairs: old_hash:new_hash
152152
# Extract current hashes from versions.bzl and create replacement pairs
@@ -176,37 +176,50 @@ jobs:
176176
fi
177177
178178
# Get current sysroot hashes from the nested sysroot_hashes dict
179-
# Extract the entire sysroot_hashes section and parse it
179+
# Extract the entire sysroot_hashes section
180180
SYSROOT_SECTION=$(sed -n '/"sysroot_hashes":/,/^[[:space:]]*},$/p' "${VERSIONS_FILE}")
181181
182-
# Helper to extract hash from sysroot section for specific glibc/variant/arch
182+
# Helper to extract hash from sysroot section
183183
get_sysroot_hash() {
184184
local glibc=$1
185185
local variant=$2
186186
local arch=$3
187-
echo "$SYSROOT_SECTION" | sed -n "/${glibc}/,/^[[:space:]]*},/p" | \
188-
sed -n "/${variant}/,/^[[:space:]]*},/p" | \
189-
grep "\"${arch}\":" | sed -n 's/.*"\([a-f0-9]\{64\}\)".*/\1/p'
187+
local glibc_section=$(echo "$SYSROOT_SECTION" | sed -n "/\"${glibc}\":/,/^[[:space:]]*},$/p")
188+
local variant_section=$(echo "$glibc_section" | sed -n "/\"${variant}\":/,/^[[:space:]]*},$/p")
189+
echo "$variant_section" | grep "\"${arch}\":" | sed -n 's/.*"\([a-f0-9]\{64\}\)".*/\1/p'
190190
}
191191
192192
# Add sysroot hash replacements
193+
declare -A SYSROOT_HASHES=(
194+
["2_31_BASE_AMD64"]="${SYSROOT_2_31_BASE_AMD64}"
195+
["2_31_BASE_ARM64"]="${SYSROOT_2_31_BASE_ARM64}"
196+
["2_31_13_AMD64"]="${SYSROOT_2_31_13_AMD64}"
197+
["2_31_13_ARM64"]="${SYSROOT_2_31_13_ARM64}"
198+
["2_28_BASE_AMD64"]="${SYSROOT_2_28_BASE_AMD64}"
199+
["2_28_BASE_ARM64"]="${SYSROOT_2_28_BASE_ARM64}"
200+
["2_28_13_AMD64"]="${SYSROOT_2_28_13_AMD64}"
201+
["2_28_13_ARM64"]="${SYSROOT_2_28_13_ARM64}"
202+
)
203+
193204
for glibc in "2.31" "2.28"; do
194205
for variant in "base" "13"; do
195206
for arch in "amd64" "arm64"; do
196-
VAR_NAME="SYSROOT_${glibc//./_}_${variant/base/BASE}_${arch^^}"
197-
NEW_HASH="${!VAR_NAME}"
198-
CURRENT_HASH=$(get_sysroot_hash "$glibc" "\"$variant\"" "$arch")
207+
# Build variable name
208+
VAR_NAME="${glibc//./_}_${variant^^}_${arch^^}"
209+
NEW_HASH="${SYSROOT_HASHES[$VAR_NAME]}"
210+
CURRENT_HASH=$(get_sysroot_hash "$glibc" "$variant" "$arch")
199211
if [[ -n "${CURRENT_HASH}" && "${CURRENT_HASH}" != "${NEW_HASH}" ]]; then
200212
REPLACEMENTS+=("${CURRENT_HASH}:${NEW_HASH}")
201213
fi
202214
done
203215
done
204216
done
205217
206-
# Use bazel/sha/replace.sh to perform all replacements
218+
# Use bazel to run the sha replace tool
207219
if [[ ${#REPLACEMENTS[@]} -gt 0 ]]; then
208220
echo "Performing ${#REPLACEMENTS[@]} hash replacements..."
209-
bash bazel/sha/replace.sh . "${REPLACEMENTS[@]}"
221+
cd bazel
222+
bazel run //sha:replace -- "$(pwd)/.." "${REPLACEMENTS[@]}"
210223
else
211224
echo "No hash updates needed - all hashes are already current"
212225
fi

0 commit comments

Comments
 (0)