-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbump.sh
executable file
·48 lines (36 loc) · 1.32 KB
/
bump.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -e -u -o pipefail
cd $BUILD_WORKSPACE_DIRECTORY
MODULE_FILE="MODULE.bazel"
REPO="openroad/orfs"
# Get the latest tag from Docker Hub API
LATEST_TAG=$(curl -s "https://hub.docker.com/v2/repositories/$REPO/tags/?page_size=1" | jq -r '.results[0].name')
if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then
echo "Failed to fetch latest tag."
exit 1
fi
echo "Latest tag: $LATEST_TAG"
# Pull the latest image
docker pull "$REPO:$LATEST_TAG"
# Get the SHA-256 digest
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' "$REPO:$LATEST_TAG" | cut -d'@' -f2)
DIGEST=${DIGEST#sha256:}
if [[ -z "$DIGEST" ]]; then
echo "Failed to fetch SHA-256 digest."
exit 1
fi
sed -i -E \
-e "/orfs\.default\(/,/^\s*\)/ { \
s|(image = \"docker.io/openroad/orfs:)[^\"]+(\")|\1$LATEST_TAG\2|; \
s|(sha256 = \")[^\"]+(\")|\1$DIGEST\2| \
}" \
"$MODULE_FILE"
COMMIT=$(curl -s "https://api.github.com/repos/The-OpenROAD-Project/bazel-orfs/commits/main" | jq -r '.sha')
if [[ -z "$COMMIT" || "$COMMIT" == "null" ]]; then
echo "Failed to fetch latest commit."
exit 1
fi
echo "Latest commit: $COMMIT"
sed -i "/git_override(/{:a;N;/)/!ba};/module_name = \"bazel-orfs\"/s/commit = \"[^\"]*\"/commit = \"$COMMIT\"/" MODULE.bazel
bazelisk mod tidy
git diff --color=always MODULE.bazel | cat