-
Notifications
You must be signed in to change notification settings - Fork 19
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 #495 from piyush-jena/toml-copy
scripts: Create script to copy contents from previous minor version to current
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 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,21 @@ | ||
# Script: Copy documentation from previous minor version to current minor version | ||
|
||
This script is used to generate the data for `content/[lang]/os/[version]/` and `data/settings/[version]`. You will need to run it on every minor version before running any other script. | ||
|
||
## Prerequisites | ||
|
||
This script works on Linux or MacOS and is unlikely to work in Windows. | ||
|
||
## Running the script | ||
|
||
There is one script in this directory: | ||
|
||
- `copy_files_from_prev_version.sh`: Copies contents from previous minor version to current minor version and removes unnecessary files. The only argument it accepts is the version (usually the latest) for which we want to copy content. | ||
|
||
### Usage | ||
|
||
As an example, if we want to copy the contents from 1.25 to 1.26, then, you can run the following: | ||
|
||
```bash | ||
./copy_files_from_prev_version.sh 1.26.0 | ||
``` |
48 changes: 48 additions & 0 deletions
48
scripts/website-boiler-plate-generator/copy_files_from_prev_version.sh
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,48 @@ | ||
#!/bin/bash | ||
|
||
# Path to website repository | ||
BOTTLEROCKET_WEBSITE_REPO_DIR="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")" | ||
|
||
# Check if the correct number of arguments is provided | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <version>" | ||
exit 1 | ||
fi | ||
|
||
VERSION="${1}" | ||
|
||
# Check if the version format is valid (X.Y.Z) | ||
if ! [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Invalid version format. Expected: X.Y.Z" | ||
exit 1 | ||
fi | ||
|
||
MAJOR=$(echo "${VERSION}" | cut -d'.' -f1) | ||
MINOR=$(echo "${VERSION}" | cut -d'.' -f2) | ||
PATCH=$(echo "${VERSION}" | cut -d'.' -f3) | ||
|
||
# Check if MINOR is 0, which is an invalid case | ||
if [ "${MINOR}" -eq 0 ]; then | ||
echo "Invalid version format. Minor version cannot be 0." | ||
exit 1 | ||
fi | ||
|
||
# Check if PATCH is not 0, which is an invalid case | ||
if [ "${PATCH}" -ne 0 ]; then | ||
echo "Invalid version format. Patch version must be 0. This script is only meant to copy contents for new minor version." | ||
exit 1 | ||
fi | ||
|
||
PREV_MINOR=$((MINOR - 1)) | ||
MAJOR_MINOR_X="${MAJOR}.${MINOR}.x" | ||
PREV_MAJOR_MINOR_X="${MAJOR}.${PREV_MINOR}.x" | ||
|
||
# Copy previous minor version content to the latest minor version | ||
cp -R "${BOTTLEROCKET_WEBSITE_REPO_DIR}/content/en/os/${PREV_MAJOR_MINOR_X}/" \ | ||
"${BOTTLEROCKET_WEBSITE_REPO_DIR}/content/en/os/${MAJOR_MINOR_X}/" | ||
cp -R "${BOTTLEROCKET_WEBSITE_REPO_DIR}/data/settings/${PREV_MAJOR_MINOR_X}/" \ | ||
"${BOTTLEROCKET_WEBSITE_REPO_DIR}/data/settings/${MAJOR_MINOR_X}/" | ||
|
||
# Remove invalid files and folders | ||
rm -rf "${BOTTLEROCKET_WEBSITE_REPO_DIR}/content/en/os/${MAJOR_MINOR_X}/version-information/packages/${MAJOR}.*" | ||
rm -rf "${BOTTLEROCKET_WEBSITE_REPO_DIR}/content/en/os/${MAJOR_MINOR_X}/version-information/gpu-drivers/${MAJOR}.*" |