Skip to content

Commit

Permalink
Attempt to generate swticher
Browse files Browse the repository at this point in the history
  • Loading branch information
clebreto committed Sep 20, 2024
1 parent 1fdd034 commit 9ef8354
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ jobs:
source /builds/miniconda3/etc/profile.d/conda.sh
conda activate corese-core-documentation
sphinx-multiversion docs/source build/html -D 'exhale_args.containmentFolder=${sourcedir}/java_api'
cp docs/source/_static/switcher.json ./build/html
chmod u+x docs/swticher_generator.sh
./docs/swticher_generator.sh build/html/switcher.json
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
2 changes: 1 addition & 1 deletion docs/source/_static/switcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
{
"name": "v4.5.6 (stable)",
"version": "stable",
"url": "https://corese-stack.github.io/corese-core/v4.5.6/",
"url": "https://corese-stack.github.io/corese-core/v4.5.6/"
}
]
42 changes: 42 additions & 0 deletions docs/swticher_generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Get all Git tags
tags=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$')

# Initialize an empty array to hold JSON objects
json_array=()

# Initialize the first flag to identify the latest tag
is_first=true

# Loop through each tag
for tag in $tags; do
# Determine if this is the latest version
if $is_first; then
preferred="true"
name="$tag (latest)"
is_first=false
else
preferred="false"
name="$tag (stable)"
fi

# Create a JSON object for the tag
json_object=$(cat <<EOF
{
"Name": "$name",
"version": "stable",
"url": "https://corese-stack.github.io/corese-core/$tag/",
"preferred": $preferred
}
EOF
)
# Add the JSON object to the array
json_array+=("$json_object")
done

# Join the JSON objects into a single array
json_output=$(printf ",\n%s" "${json_array[@]}")

# Wrap the JSON array with square brackets
echo -e "[\n${json_output:2}\n]"

0 comments on commit 9ef8354

Please sign in to comment.