Skip to content

Commit f7a12c4

Browse files
authored
Fix timestamps in the version table (#174)
This refactors the version table generation from a search-and-replace algorithm to de novo construction of the desired values. Fixes #173
1 parent 76ea8df commit f7a12c4

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ at the top right in the GitHub Actions page.
3434

3535
| Repository | Container images and binaries |
3636
| ---------- | ----------------------------- |
37-
| [bb-browser](https://github.com/buildbarn/bb-browser) [`9b44996f7d`](https://github.com/buildbarn/bb-browser/commits/9b44996f7d6a04185f61e7752cbe8649aaa59f16)<br/>2023-09-17 04:20:39 UTC | [ghcr.io/buildbarn/bb-browser:20250414T180739Z-9b44996](https://ghcr.io/buildbarn/bb-browser:20250414T180739Z-9b44996)<br/>[CI artifacts](https://github.com/buildbarn/bb-browser/actions/runs/14452582814) |
38-
| [bb-remote-execution](https://github.com/buildbarn/bb-remote-execution) [`1c726bdc27`](https://github.com/buildbarn/bb-remote-execution/commits/1c726bdc27e7793c685d8788913f8f91f59bc887)<br/>2023-10-04 10:23:25 UTC | [ghcr.io/buildbarn/bb-runner-installer:20250411T124310Z-1c726bd](https://ghcr.io/buildbarn/bb-runner-installer:20250411T124310Z-1c726bd)<br/>[ghcr.io/buildbarn/bb-scheduler:20250411T124310Z-1c726bd](https://ghcr.io/buildbarn/bb-scheduler:20250411T124310Z-1c726bd)<br/>[ghcr.io/buildbarn/bb-worker:20250411T124310Z-1c726bd](https://ghcr.io/buildbarn/bb-worker:20250411T124310Z-1c726bd)<br/>[CI artifacts](https://github.com/buildbarn/bb-remote-execution/actions/runs/14403397088) |
39-
| [bb-storage](https://github.com/buildbarn/bb-storage) [`1d733a3748`](https://github.com/buildbarn/bb-storage/commits/1d733a37487a01416bda38eff6f61eb78103c7f0)<br/>2023-10-08 11:11:12 UTC | [ghcr.io/buildbarn/bb-storage:20250408T112116Z-1d733a3](https://ghcr.io/buildbarn/bb-storage:20250408T112116Z-1d733a3)<br/>[CI artifacts](https://github.com/buildbarn/bb-storage/actions/runs/14332223689) |
37+
| [bb-browser](https://github.com/buildbarn/bb-browser) [`9b44996f7d`](https://github.com/buildbarn/bb-browser/commits/9b44996f7d6a04185f61e7752cbe8649aaa59f16)<br/>2025-04-14 18:07:39 UTC | [ghcr.io/buildbarn/bb-browser:20250414T180739Z-9b44996](https://ghcr.io/buildbarn/bb-browser:20250414T180739Z-9b44996)<br/>[CI artifacts](https://github.com/buildbarn/bb-browser/actions/runs/14452582814) |
38+
| [bb-remote-execution](https://github.com/buildbarn/bb-remote-execution) [`1c726bdc27`](https://github.com/buildbarn/bb-remote-execution/commits/1c726bdc27e7793c685d8788913f8f91f59bc887)<br/>2025-04-11 12:43:10 UTC | [ghcr.io/buildbarn/bb-runner-installer:20250411T124310Z-1c726bd](https://ghcr.io/buildbarn/bb-runner-installer:20250411T124310Z-1c726bd)<br/>[ghcr.io/buildbarn/bb-scheduler:20250411T124310Z-1c726bd](https://ghcr.io/buildbarn/bb-scheduler:20250411T124310Z-1c726bd)<br/>[ghcr.io/buildbarn/bb-worker:20250411T124310Z-1c726bd](https://ghcr.io/buildbarn/bb-worker:20250411T124310Z-1c726bd)<br/>[CI artifacts](https://github.com/buildbarn/bb-remote-execution/actions/runs/14403397088) |
39+
| [bb-storage](https://github.com/buildbarn/bb-storage) [`1d733a3748`](https://github.com/buildbarn/bb-storage/commits/1d733a37487a01416bda38eff6f61eb78103c7f0)<br/>2025-04-08 11:21:16 UTC | [ghcr.io/buildbarn/bb-storage:20250408T112116Z-1d733a3](https://ghcr.io/buildbarn/bb-storage:20250408T112116Z-1d733a3)<br/>[CI artifacts](https://github.com/buildbarn/bb-storage/actions/runs/14332223689) |
4040

4141
## Changelog
4242

tools/update-container-image-versions.sh

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,29 +84,53 @@ check_module_overrides() {
8484
}
8585

8686
update_image_version() {
87-
repo="$1"; shift
88-
image_name="$1"; shift
87+
# Update kubernetes and docker-compose image versions.
88+
local repo="$1"; shift
89+
local image_name="$1"; shift
90+
91+
local image_version
92+
image_version=$(get_image_version "$repo")
93+
94+
sed -i "s#\(ghcr\.io/buildbarn/$image_name:\)[0-9tzTZ]*-[0-9a-f]*#\1$image_version#g" \
95+
docker-compose/docker-compose.yml kubernetes/*.yaml
96+
}
97+
98+
update_version_table() {
99+
# Update the version table in the README.
100+
local repo="$1"; shift
101+
# images are left as arguments;
89102

103+
local image_version
90104
image_version=$(get_image_version "$repo")
105+
local timestamp
106+
# shellcheck disable=SC2001
91107
timestamp=$(echo "$image_version" \
92108
| 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#')
109+
timestamp="$timestamp UTC"
110+
local commit_hash
93111
commit_hash=$(get_full_git_commit_hash "$repo")
94-
short_commit_hash="${commit_hash:0:10}"
95-
checks_url="https://github.com/buildbarn/$repo/commit/$commit_hash/checks"
96-
actions_url=$(actions_summary_page "$checks_url")
97-
98-
# Replace image version.
99-
sed -i "s#\(ghcr\.io/buildbarn/$image_name:\)[0-9tzTZ]*-[0-9a-f]*#\1$image_version#g" \
100-
README.md docker-compose/docker-compose.yml kubernetes/*.yaml
101-
102-
# Replace timestamp, commit URLs and CI build result link.
103-
git_log_stem="https://github.com/buildbarn/$repo/commits"
104-
actions_url_stem="https://github.com/buildbarn/$repo/actions/runs"
105-
sed -i \
106-
-e "s#^\(| $image_name .*| \)\([^|]* UTC |\)#\1$timestamp UTC |#" \
107-
-e "s#\[\`[0-9a-f]*\`\]($git_log_stem/[0-9a-f]*)#[\`$short_commit_hash\`]($git_log_stem/$commit_hash)#" \
108-
-e "s#$actions_url_stem/[0-9a-f]*#$actions_url#" \
109-
README.md
112+
local short_commit_hash="${commit_hash:0:10}"
113+
local github_project_url="https://github.com/buildbarn/$repo"
114+
local checks_url="$github_project_url/commit/$commit_hash/checks"
115+
local artifact_url
116+
artifact_url=$(actions_summary_page "$checks_url")
117+
118+
local git_log_stem="https://github.com/buildbarn/$repo/commits"
119+
local commit_url="$git_log_stem/$commit_hash"
120+
121+
# TODO: move 'UTC' into the timestamp variable.
122+
local images=""
123+
for image_name in "$@"; do
124+
image_timestamp=$image_version
125+
local image_qualifier="ghcr.io/buildbarn/$image_name:$image_timestamp"
126+
local image_url="https://$image_qualifier"
127+
images="${images}[$image_qualifier]($image_url)<br/>"
128+
done
129+
130+
local left="[$repo]($github_project_url) [\`$short_commit_hash\`]($commit_url)<br/>$timestamp"
131+
local right="${images}[CI artifacts]($artifact_url)"
132+
local entry="| $left | $right |"
133+
sed -i "s#| \[$repo\].*#$entry#" README.md
110134
}
111135

112136
update_image_version bb-browser bb-browser
@@ -115,6 +139,10 @@ update_image_version bb-remote-execution bb-scheduler
115139
update_image_version bb-remote-execution bb-worker
116140
update_image_version bb-storage bb-storage
117141

142+
update_version_table bb-browser bb-browser
143+
update_version_table bb-remote-execution bb-runner-installer bb-scheduler bb-worker
144+
update_version_table bb-storage bb-storage
145+
118146
check_module_overrides bb-browser
119147
check_module_overrides bb-storage
120148
check_module_overrides bb-remote-execution

0 commit comments

Comments
 (0)