forked from DhanushNehru/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-latest-version.sh
More file actions
executable file
·33 lines (26 loc) · 1016 Bytes
/
build-latest-version.sh
File metadata and controls
executable file
·33 lines (26 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -e
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 $CONFIG_FILE"
exit 1
fi
echo "Found lastVersion: $LAST_VERSION"
# 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 "$@"