|
3 | 3 | set -e
|
4 | 4 | cd "$(dirname $0)/.."
|
5 | 5 |
|
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 |
8 | 8 | exit 1
|
9 | 9 | fi
|
10 | 10 |
|
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 | + ') |
16 | 22 |
|
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 | + ') |
22 | 34 |
|
23 | 35 | find . -name '*.md' -exec sed -i \
|
24 | 36 | -e "s#https://github.com/opencontainers/runtime-spec/blob/main/#https://github.com/opencontainers/runtime-spec/blob/${runtime_tag}/#g" \
|
|
0 commit comments