Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/besu tag #197

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions besu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ cd ${SCRIPT_DIR}/../source
./gradlew distDocker

# generate the docker image tag based off besu gradle build
# view the calculateVersion gradle function incase of changes upstream
# https://github.com/hyperledger/besu/blob/main/build.gradle
getImageTag() {
local length=${1:-8} # Default length
local gitFolder="$PWD/.git/"
Expand Down Expand Up @@ -36,7 +38,36 @@ getImageTag() {
echo "${lastModified}-develop-${commitHash}"
}

docker tag "hyperledger/besu:$(getImageTag 7)" "${target_repository}:${target_tag}"
# list all docker images
echo "Listing all docker images from gradle build:"
docker images --format "{{.Repository}}:{{.Tag}}"

# list of tags to check for after building from gradle
gradle_tags=(
"${source_repository}:$(getImageTag)"
"${source_repository}:$(getImageTag 7)" # legacy tag
)

echo "Listing all calculated image tags:"
for gradle_tag in "${gradle_tags[@]}"; do
echo "${gradle_tag}"
done

tag=""
for gradle_tag in "${gradle_tags[@]}"; do
if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "${gradle_tag}"; then
tag="${gradle_tag}"
echo "Matched ${gradle_tag} as the correct image tag."
break
fi
done

if [ -z "$tag" ]; then
echo "Error: Can't find expected image tag after building from Gradle. Might be updates to source repository's build.gradle."
exit 1
fi

docker tag "${tag}" "${target_repository}:${target_tag}"
docker push "${target_repository}:${target_tag}"
docker tag "hyperledger/besu:$(getImageTag 7)" "${target_repository}:${target_tag}-${source_git_commit_hash}"
docker tag "${tag}" "${target_repository}:${target_tag}-${source_git_commit_hash}"
docker push "${target_repository}:${target_tag}-${source_git_commit_hash}"