diff --git a/tools/update-container-image-versions.sh b/tools/update-container-image-versions.sh index 75b711e..4ba5320 100755 --- a/tools/update-container-image-versions.sh +++ b/tools/update-container-image-versions.sh @@ -19,17 +19,17 @@ set -eu -o pipefail get_image_version() { repo="$1"; shift - grep -E "github\.com/buildbarn/${repo}" go.mod \ + grep -E "github\.com/buildbarn/$repo" go.mod \ | sed 's#.* v0.0.0-\([0-9]\{8\}\)\([0-9]\{6\}\)-\([0-9a-f]\{7\}\)[0-9a-f]\+#\1T\2Z-\3#' } get_full_git_commit_hash() { repo="$1"; shift # Reuse the same sed expression as in get_image_version. - short_commit_hash=$(grep -E "github\.com/buildbarn/${repo}" go.mod \ + short_commit_hash=$(grep -E "github\.com/buildbarn/$repo" go.mod \ | sed 's#.* v0.0.0-\([0-9]\{8\}\)\([0-9]\{6\}\)-\([0-9a-f]\+\)#\3#') # Let GitHub resolve the full commit hash. - curl "https://github.com/buildbarn/$repo/commit/$short_commit_hash" \ + curl -s "https://github.com/buildbarn/$repo/commit/$short_commit_hash" \ | grep '.*#\1#' } @@ -41,15 +41,16 @@ update_image_version() { image_version=$(get_image_version "$repo") timestamp=$(echo "$image_version" | sed 's#\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)T\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)Z.*#\1-\2-\3 \4:\5:\6#') commit_hash=$(get_full_git_commit_hash "$repo") + checks_url="https://github.com/buildbarn/$repo/commit/$commit_hash/checks" # Replace image version. - sed -i "s#\(ghcr\.io/buildbarn/${image_name}:\)[0-9tzTZ]*-[0-9a-f]*#\1${image_version}#g" \ + sed -i "s#\(ghcr\.io/buildbarn/$image_name:\)[0-9tzTZ]*-[0-9a-f]*#\1$image_version#g" \ README.md docker-compose/docker-compose.yml kubernetes/*.yaml # Replace timestamp and CI Build link. sed -i \ - -e "s#^\(| ${image_name} .*| \)\([^|]* UTC |\)#\1${timestamp} UTC |#" \ - -e "s#| [^|]*/buildbarn/${repo}/commit/[0-9a-f]*/checks#| [\`${commit_hash}\`](https://github.com/buildbarn/${repo}/commit/${commit_hash}/checks#" \ + -e "s#^\(| $image_name .*| \)\([^|]* UTC |\)#\1$timestamp UTC |#" \ + -e "s#| [^|]*/buildbarn/$repo/commit/[0-9a-f]*/checks#| [\`$commit_hash\`]($checks_url#" \ README.md }