Skip to content
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

fix: fix update-dashboard script not work when target is semver style #7638

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/dashboard-version
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This file is updated by running scripts/update-dashboard.sh
# Don't edit it manullay
# the version will become X.Y.Z-<commit-short-hash> format later
baurine marked this conversation as resolved.
Show resolved Hide resolved
2023.12.18.1
29 changes: 24 additions & 5 deletions scripts/update-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,40 @@ CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
BASE_DIR="$(dirname "$CUR_DIR")"
DASHBOARD_VERSION_FILE="$BASE_DIR/scripts/dashboard-version"
# old version
DASHBOARD_VERSION=$(grep -v '^#' "$DASHBOARD_VERSION_FILE")
DASHBOARD_VERSION=v$(grep -v '^#' "$DASHBOARD_VERSION_FILE")

# new version
# Usage: ./scripts/update-dashboard.sh <version>
# Example: ./scripts/update-dashboard.sh 2023.12.18.1
# Example: ./scripts/update-dashboard.sh v7.6.0-f7bbcdcf
if [ "$#" -ge 1 ]; then
DASHBOARD_VERSION=$1
echo $1 > $DASHBOARD_VERSION_FILE

# if DASHBOARD_VERSION not start with `v`, then exit
if [[ ! $DASHBOARD_VERSION =~ ^v[0-9]+\. ]]; then
echo "Invalid dashboard version: $DASHBOARD_VERSION, it should start with \"v\""
exit 1
fi

# when writing to DASHBOARD_VERSION_FILE, remove the leading `v`,
# so that we don't need to modify the embed-dashboard-ui.sh logic
TO_FILE_VERSION=${DASHBOARD_VERSION#v}

echo "# This file is updated by running scripts/update-dashboard.sh" > $DASHBOARD_VERSION_FILE
echo "# Don't edit it manullay" >> $DASHBOARD_VERSION_FILE
echo $TO_FILE_VERSION >> $DASHBOARD_VERSION_FILE
fi

echo "+ Update dashboard version to v$DASHBOARD_VERSION"
echo "+ Update dashboard version to $DASHBOARD_VERSION"

cd $BASE_DIR

go get -d github.com/pingcap/tidb-dashboard@v$DASHBOARD_VERSION
# if DASHBOARD_VERSION match "vX.Y.Z-<commit-short-hash>" format,
# then extract the commit hash as tidb-dashboard target
if [[ $DASHBOARD_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-[0-9a-f]{7,8} ]]; then
DASHBOARD_VERSION=$(echo $DASHBOARD_VERSION | cut -d'-' -f2)
fi

go get -d github.com/pingcap/tidb-dashboard@$DASHBOARD_VERSION
go mod tidy
make pd-server
go mod tidy
Expand Down
Loading