Skip to content

Commit d44515e

Browse files
committed
Changes requested from review
Changes for the command and avoiding the github api requested by tianon. Please send any support requests for that jq command to tianon. :) Signed-off-by: Brandon Mitchell <git@bmitch.net>
1 parent 5db69d9 commit d44515e

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

.tool/pin-release.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,34 @@
33
set -e
44
cd "$(dirname $0)/.."
55

6-
if [ ! -x "$(command -v curl )" ] || [ ! -x "$(command -v jq )" ] || [ ! -x "$(command -v find )" ] || [ ! -x "$(command -v sed )" ]; then
7-
echo "This command requires the following to run: curl, find, jq, and sed" >&2
6+
if ! { command -v jq && command -v find && command -v sed; } > /dev/null; then
7+
echo "This command requires the following to run: find, jq, and sed" >&2
88
exit 1
99
fi
1010

11-
runtime_tag=$(curl -L \
12-
-H "Accept: application/vnd.github+json" \
13-
-H "X-GitHub-Api-Version: 2022-11-28" \
14-
https://api.github.com/repos/opencontainers/runtime-spec/releases/latest \
15-
| jq -r .tag_name)
11+
runtime_tag=$(git ls-remote https://github.com/opencontainers/runtime-spec.git 'refs/tags/v[0-9]*' \
12+
| jq -rnR '
13+
[
14+
inputs
15+
| split("/")[2] # "commit-hash\trefs/tags/xxx^{}" -> "xxx^{}"
16+
| split("^")[0] # "xxx^{}" -> "xxx"
17+
| select(contains("-") | not) # ignore pre-releases
18+
]
19+
| unique_by(ltrimstr("v") | split(".") | map(tonumber? // .)) # very very rough version sorting (and dedupe)
20+
| .[-1] # we only care about "latest" (the last entry)
21+
')
1622

17-
distribution_tag=$(curl -L \
18-
-H "Accept: application/vnd.github+json" \
19-
-H "X-GitHub-Api-Version: 2022-11-28" \
20-
https://api.github.com/repos/opencontainers/distribution-spec/releases/latest \
21-
| jq -r .tag_name)
23+
distribution_tag=$(git ls-remote https://github.com/opencontainers/distribution-spec.git 'refs/tags/v[0-9]*' \
24+
| jq -rnR '
25+
[
26+
inputs
27+
| split("/")[2] # "commit-hash\trefs/tags/xxx^{}" -> "xxx^{}"
28+
| split("^")[0] # "xxx^{}" -> "xxx"
29+
| select(contains("-") | not) # ignore pre-releases
30+
]
31+
| unique_by(ltrimstr("v") | split(".") | map(tonumber? // .)) # very very rough version sorting (and dedupe)
32+
| .[-1] # we only care about "latest" (the last entry)
33+
')
2234

2335
find . -name '*.md' -exec sed -i \
2436
-e "s#https://github.com/opencontainers/runtime-spec/blob/main/#https://github.com/opencontainers/runtime-spec/blob/${runtime_tag}/#g" \

0 commit comments

Comments
 (0)