From da6fa471d716ff92318710382801d66ad8497f45 Mon Sep 17 00:00:00 2001 From: Adish M Date: Tue, 16 Jul 2024 23:58:40 +0530 Subject: [PATCH 1/3] Modification in docs PR app's bash file to pick last version from docusaurus.config.js file --- docs/build-latest-version.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/build-latest-version.sh b/docs/build-latest-version.sh index 06a62d817f..076f9bcfff 100644 --- a/docs/build-latest-version.sh +++ b/docs/build-latest-version.sh @@ -1,9 +1,21 @@ #!/bin/bash set -e -jq '[.[0]]' versions.json > tmp_versions.json +# Extract lastVersion from docusaurus.config.js +LAST_VERSION=$(grep -Po '(?<=lastVersion: ")[^"]*' docusaurus.config.js) + +if [ -z "$LAST_VERSION" ]; then + echo "Error: lastVersion not found in docusaurus.config.js" + exit 1 +fi + +echo "Found lastVersion: $LAST_VERSION" + +# Update versions.json to include only lastVersion +jq -n --arg version "$LAST_VERSION" '[$version]' > tmp_versions.json mv tmp_versions.json versions.json +# Install dependencies and build the project npm i && npm run build exec "$@" From c9a476279ca4a89ad6343ea844b12e316d29c2b2 Mon Sep 17 00:00:00 2001 From: Adish M Date: Wed, 17 Jul 2024 00:09:16 +0530 Subject: [PATCH 2/3] modified the grep to sed to get LastVersion --- docs/build-latest-version.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/build-latest-version.sh b/docs/build-latest-version.sh index 076f9bcfff..1b4661fcb1 100644 --- a/docs/build-latest-version.sh +++ b/docs/build-latest-version.sh @@ -1,8 +1,8 @@ #!/bin/bash set -e -# Extract lastVersion from docusaurus.config.js -LAST_VERSION=$(grep -Po '(?<=lastVersion: ")[^"]*' docusaurus.config.js) +# Extract lastVersion from docusaurus.config.js using sed +LAST_VERSION=$(sed -n 's/.*lastVersion:[[:space:]]*'\''\([^'\'']*\)'\''.*/\1/p' docusaurus.config.js) if [ -z "$LAST_VERSION" ]; then echo "Error: lastVersion not found in docusaurus.config.js" @@ -12,8 +12,7 @@ fi echo "Found lastVersion: $LAST_VERSION" # Update versions.json to include only lastVersion -jq -n --arg version "$LAST_VERSION" '[$version]' > tmp_versions.json -mv tmp_versions.json versions.json +jq -n --arg version "$LAST_VERSION" '[$version]' > versions.json # Install dependencies and build the project npm i && npm run build From fe2d735c2bca2469c193641d09d884bfe1dd931e Mon Sep 17 00:00:00 2001 From: Adish M Date: Wed, 17 Jul 2024 00:55:26 +0530 Subject: [PATCH 3/3] modified the bash to pick-up the versions --- docs/build-latest-version.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) mode change 100644 => 100755 docs/build-latest-version.sh diff --git a/docs/build-latest-version.sh b/docs/build-latest-version.sh old mode 100644 new mode 100755 index 1b4661fcb1..e8004f169d --- a/docs/build-latest-version.sh +++ b/docs/build-latest-version.sh @@ -1,20 +1,33 @@ #!/bin/bash set -e -# Extract lastVersion from docusaurus.config.js using sed -LAST_VERSION=$(sed -n 's/.*lastVersion:[[:space:]]*'\''\([^'\'']*\)'\''.*/\1/p' docusaurus.config.js) +CONFIG_FILE="docusaurus.config.js" +# Extract lastVersion from docusaurus.config.js using sed +LAST_VERSION=$(sed -n "s/.*lastVersion: *'\\([^']*\\)'.*/\\1/p" "$CONFIG_FILE") if [ -z "$LAST_VERSION" ]; then - echo "Error: lastVersion not found in docusaurus.config.js" + echo "Error: lastVersion not found in $CONFIG_FILE" exit 1 fi - echo "Found lastVersion: $LAST_VERSION" -# Update versions.json to include only lastVersion -jq -n --arg version "$LAST_VERSION" '[$version]' > versions.json +# Extract all version numbers from the entire file +ALL_VERSIONS=$(grep -oE "'[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z]+)?'" "$CONFIG_FILE" | sed "s/'//g" | sort -u -V -r) +if [ -z "$ALL_VERSIONS" ]; then + echo "Error: No versions found in $CONFIG_FILE" + exit 1 +fi +echo "Found raw versions:" +echo "$ALL_VERSIONS" + +# Convert the extracted versions into a JSON array format +VERSION_ARRAY=$(echo "$ALL_VERSIONS" | jq -R -s -c 'split("\n")[:-1] + ["'"$LAST_VERSION"'"] | unique') +echo "Updating versions.json with: $VERSION_ARRAY" + +# Update versions.json with combined data +echo $VERSION_ARRAY | jq . > versions.json # Install dependencies and build the project npm i && npm run build -exec "$@" +exec "$@" \ No newline at end of file