-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1208 from sudo-bmitch/pr-pin-urls-on-release
Feat: Pin external references on a release
- Loading branch information
Showing
2 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
cd "$(dirname $0)/.." | ||
|
||
if ! { command -v jq && command -v find && command -v sed; } > /dev/null; then | ||
echo "This command requires the following to run: find, jq, and sed" >&2 | ||
exit 1 | ||
fi | ||
|
||
runtime_tag=$(git ls-remote https://github.com/opencontainers/runtime-spec.git 'refs/tags/v[0-9]*' \ | ||
| jq -rnR ' | ||
[ | ||
inputs | ||
| split("/")[2] # "commit-hash\trefs/tags/xxx^{}" -> "xxx^{}" | ||
| split("^")[0] # "xxx^{}" -> "xxx" | ||
| select(contains("-") | not) # ignore pre-releases | ||
] | ||
| unique_by(ltrimstr("v") | split(".") | map(tonumber? // .)) # very very rough version sorting (and dedupe) | ||
| .[-1] # we only care about "latest" (the last entry) | ||
') | ||
|
||
distribution_tag=$(git ls-remote https://github.com/opencontainers/distribution-spec.git 'refs/tags/v[0-9]*' \ | ||
| jq -rnR ' | ||
[ | ||
inputs | ||
| split("/")[2] # "commit-hash\trefs/tags/xxx^{}" -> "xxx^{}" | ||
| split("^")[0] # "xxx^{}" -> "xxx" | ||
| select(contains("-") | not) # ignore pre-releases | ||
] | ||
| unique_by(ltrimstr("v") | split(".") | map(tonumber? // .)) # very very rough version sorting (and dedupe) | ||
| .[-1] # we only care about "latest" (the last entry) | ||
') | ||
|
||
find . -name '*.md' -exec sed -i \ | ||
-e "s#https://github.com/opencontainers/runtime-spec/blob/main/#https://github.com/opencontainers/runtime-spec/blob/${runtime_tag}/#g" \ | ||
-e "s#https://github.com/opencontainers/distribution-spec/blob/main/#https://github.com/opencontainers/distribution-spec/blob/${distribution_tag}/#g" \ | ||
'{}' \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters