-
Notifications
You must be signed in to change notification settings - Fork 28
Add tooling to bump container-toolkit version #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,51 @@ | ||
{ | ||
"latest": "1.17.8", | ||
"versions": | ||
[ | ||
{ | ||
"version": "1.17.8" | ||
}, | ||
{ | ||
"version": "1.17.7" | ||
}, | ||
{ | ||
"version": "1.17.6" | ||
}, | ||
{ | ||
"version": "1.17.5" | ||
}, | ||
{ | ||
"version": "1.17.4" | ||
}, | ||
{ | ||
"version": "1.17.3" | ||
}, | ||
{ | ||
"version": "1.17.2" | ||
}, | ||
{ | ||
"version": "1.17.1" | ||
}, | ||
{ | ||
"version": "1.17.0" | ||
}, | ||
{ | ||
"version": "1.16.2" | ||
}, | ||
{ | ||
"version": "1.16.1" | ||
}, | ||
{ | ||
"version": "1.16.0" | ||
} | ||
] | ||
} | ||
[ | ||
{ | ||
"preferred": "true", | ||
"url": "../1.17.8", | ||
"version": "1.17.8" | ||
}, | ||
{ | ||
"url": "../1.17.7", | ||
"version": "1.17.7" | ||
}, | ||
{ | ||
"url": "../1.17.6", | ||
"version": "1.17.6" | ||
}, | ||
{ | ||
"url": "../1.17.5", | ||
"version": "1.17.5" | ||
}, | ||
{ | ||
"url": "../1.17.4", | ||
"version": "1.17.4" | ||
}, | ||
{ | ||
"url": "../1.17.3", | ||
"version": "1.17.3" | ||
}, | ||
{ | ||
"url": "../1.17.2", | ||
"version": "1.17.2" | ||
}, | ||
{ | ||
"url": "../1.17.1", | ||
"version": "1.17.1" | ||
}, | ||
{ | ||
"url": "../1.17.0", | ||
"version": "1.17.0" | ||
}, | ||
{ | ||
"url": "../1.16.2", | ||
"version": "1.16.2" | ||
}, | ||
{ | ||
"url": "../1.16.1", | ||
"version": "1.16.1" | ||
}, | ||
{ | ||
"url": "../1.16.0", | ||
"version": "1.16.0" | ||
} | ||
] |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,71 @@ | ||||||||||||||||||
#!/bin/bash | ||||||||||||||||||
|
||||||||||||||||||
# Function to print usage | ||||||||||||||||||
print_usage() { | ||||||||||||||||||
echo "Usage: $0 <component-name> <new-version>" | ||||||||||||||||||
echo "Example: $0 container-toolkit 1.17.9" | ||||||||||||||||||
exit 1 | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
# Check if yq is installed | ||||||||||||||||||
check_yq() { | ||||||||||||||||||
if ! command -v yq &> /dev/null; then | ||||||||||||||||||
echo "Error: yq is not installed" | ||||||||||||||||||
echo "Please install yq first. On macOS, you can use: brew install yq" | ||||||||||||||||||
exit 1 | ||||||||||||||||||
fi | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
# Validate input parameters | ||||||||||||||||||
if [[ $# -ne 2 ]]; then | ||||||||||||||||||
print_usage | ||||||||||||||||||
fi | ||||||||||||||||||
|
||||||||||||||||||
COMPONENT="$1" | ||||||||||||||||||
NEW_VERSION="$2" | ||||||||||||||||||
|
||||||||||||||||||
# Check if yq is available | ||||||||||||||||||
check_yq | ||||||||||||||||||
|
||||||||||||||||||
# Validate component exists both as a directory and in repo.toml | ||||||||||||||||||
if [[ ! -d "$COMPONENT" ]]; then | ||||||||||||||||||
echo "Error: Component directory '${COMPONENT}' not found" | ||||||||||||||||||
exit 1 | ||||||||||||||||||
fi | ||||||||||||||||||
|
||||||||||||||||||
# Check if the version field exists and get current version | ||||||||||||||||||
CURRENT_VERSION=$(yq ".repo_docs.projects.${COMPONENT}.version" repo.toml) | ||||||||||||||||||
if [[ "$CURRENT_VERSION" == "null" ]]; then | ||||||||||||||||||
echo "Error: Component '${COMPONENT}' version field not found in repo.toml" | ||||||||||||||||||
exit 1 | ||||||||||||||||||
fi | ||||||||||||||||||
|
||||||||||||||||||
# Update versions.json if it exists | ||||||||||||||||||
VERSIONS_JSON="$COMPONENT/versions.json" | ||||||||||||||||||
if [[ -f "$VERSIONS_JSON" ]]; then | ||||||||||||||||||
echo "Updating $VERSIONS_JSON..." | ||||||||||||||||||
yq -p=json -o=json -i '. = [{"preferred": "true", "url": "../'"${NEW_VERSION}"'", "version": "'"${NEW_VERSION}"'"}] + [(.[0] | del(.preferred))] + .[1:]' "$VERSIONS_JSON" | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The complex inline yq command impacts readability and maintainability; consider refactoring parts into intermediate variables or adding inline comments to clarify its intent.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
if [[ $? -ne 0 ]]; then | ||||||||||||||||||
echo "Error: Failed to update $VERSIONS_JSON" | ||||||||||||||||||
exit 1 | ||||||||||||||||||
fi | ||||||||||||||||||
fi | ||||||||||||||||||
|
||||||||||||||||||
# Update version in repo.toml using sed | ||||||||||||||||||
echo "Updating version in repo.toml..." | ||||||||||||||||||
# Remove quotes from current version for sed | ||||||||||||||||||
CURRENT_VERSION=${CURRENT_VERSION//\"/} | ||||||||||||||||||
if [[ $(uname) == "Darwin" ]]; then | ||||||||||||||||||
# macOS requires an empty string for -i | ||||||||||||||||||
sed -i '' "s/version = \"${CURRENT_VERSION}\"/version = \"${NEW_VERSION}\"/" repo.toml | ||||||||||||||||||
else | ||||||||||||||||||
# Linux version of sed | ||||||||||||||||||
sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${NEW_VERSION}\"/" repo.toml | ||||||||||||||||||
fi | ||||||||||||||||||
|
||||||||||||||||||
if [[ $? -ne 0 ]]; then | ||||||||||||||||||
echo "Error: Failed to update repo.toml" | ||||||||||||||||||
exit 1 | ||||||||||||||||||
fi | ||||||||||||||||||
|
||||||||||||||||||
echo "Successfully updated version to ${NEW_VERSION} for ${COMPONENT}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were two reasons for using
versions1.json
:versions1.json
is a bit of a convention across docs projects at NVIDIA, kinda because we've nearly all migrated to using NVIDIA Sphinx Theme.IMO, not worth changing and kind of worth it to keep as-is for continuity across projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Are the docs not built from a specific commit? Meaning that as long as that specific commit has the "correct" version information then using
versions.json
should be fine?