|
|
@@ -36,30 +36,30 @@ increment_version() {
|
|
|
local choice="$2"
|
|
|
|
|
|
# Split version into parts
|
|
|
- IFS='.' read -ra VERSION_PARTS <<< "$current_version"
|
|
|
+ IFS='.' read -ra VERSION_PARTS <<<"$current_version"
|
|
|
local major=${VERSION_PARTS[0]}
|
|
|
local minor=${VERSION_PARTS[1]}
|
|
|
local patch=${VERSION_PARTS[2]}
|
|
|
|
|
|
case $choice in
|
|
|
- 1)
|
|
|
- # Increment major, reset minor and patch to 0
|
|
|
- major=$((major + 1))
|
|
|
- minor=0
|
|
|
- patch=0
|
|
|
- ;;
|
|
|
- 2)
|
|
|
- # Increment minor, reset patch to 0
|
|
|
- minor=$((minor + 1))
|
|
|
- patch=0
|
|
|
- ;;
|
|
|
- 3)
|
|
|
- # Increment patch only
|
|
|
- patch=$((patch + 1))
|
|
|
- ;;
|
|
|
- *)
|
|
|
- error_exit "Invalid choice: $choice"
|
|
|
- ;;
|
|
|
+ 1)
|
|
|
+ # Increment major, reset minor and patch to 0
|
|
|
+ major=$((major + 1))
|
|
|
+ minor=0
|
|
|
+ patch=0
|
|
|
+ ;;
|
|
|
+ 2)
|
|
|
+ # Increment minor, reset patch to 0
|
|
|
+ minor=$((minor + 1))
|
|
|
+ patch=0
|
|
|
+ ;;
|
|
|
+ 3)
|
|
|
+ # Increment patch only
|
|
|
+ patch=$((patch + 1))
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ error_exit "Invalid choice: $choice"
|
|
|
+ ;;
|
|
|
esac
|
|
|
|
|
|
echo "$major.$minor.$patch"
|
|
|
@@ -92,42 +92,13 @@ update_package_json() {
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
-# Function to update version in public/webConfigApi.js
|
|
|
-update_webconfig_version() {
|
|
|
- local version="$1"
|
|
|
- local webconfig_file="public/webConfigApi.js"
|
|
|
-
|
|
|
- if [ ! -f "$webconfig_file" ]; then
|
|
|
- info_message "$webconfig_file not found. Skipping version update."
|
|
|
- return 0
|
|
|
- fi
|
|
|
-
|
|
|
- info_message "Updating version in $webconfig_file to $version"
|
|
|
-
|
|
|
- # Update version using sed (macOS compatible)
|
|
|
- if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
- sed -i '' "s/version: '[^']*'/version: '$version'/" "$webconfig_file"
|
|
|
- sed -i '' "s/\/\/ 版本: [^ ]*/\/\/ 版本: $version/" "$webconfig_file"
|
|
|
- else
|
|
|
- sed -i "s/version: '[^']*'/version: '$version'/" "$webconfig_file"
|
|
|
- sed -i "s/\/\/ 版本: [^ ]*/\/\/ 版本: $version/" "$webconfig_file"
|
|
|
- fi
|
|
|
-
|
|
|
- # Verify the change
|
|
|
- if grep -q "version: '$version'" "$webconfig_file"; then
|
|
|
- success_message "$webconfig_file version updated to $version"
|
|
|
- else
|
|
|
- error_exit "Failed to update $webconfig_file version"
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
section_header "🚀 Interactive Release Process"
|
|
|
|
|
|
-# Step 1: Check if we are on dev or main branch
|
|
|
+# Step 1: Check if we are on dev or master branch
|
|
|
info_message "Checking current branch..."
|
|
|
CURRENT_BRANCH=$(git branch --show-current)
|
|
|
-if [ "$CURRENT_BRANCH" != "dev" ] && [ "$CURRENT_BRANCH" != "main" ]; then
|
|
|
- error_exit "Must be on 'dev' or 'main' branch. Current branch: $CURRENT_BRANCH. Please switch to dev or main branch first."
|
|
|
+if [ "$CURRENT_BRANCH" != "dev" ] && [ "$CURRENT_BRANCH" != "master" ]; then
|
|
|
+ error_exit "Must be on 'dev' or 'master' branch. Current branch: $CURRENT_BRANCH. Please switch to dev or master branch first."
|
|
|
fi
|
|
|
success_message "Currently on $CURRENT_BRANCH branch"
|
|
|
|
|
|
@@ -172,7 +143,7 @@ if [ -z "$CURRENT_VERSION" ]; then
|
|
|
fi
|
|
|
|
|
|
# Split current version into parts for display
|
|
|
-IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
|
|
|
+IFS='.' read -ra VERSION_PARTS <<<"$CURRENT_VERSION"
|
|
|
MAJOR=${VERSION_PARTS[0]}
|
|
|
MINOR=${VERSION_PARTS[1]}
|
|
|
PATCH=${VERSION_PARTS[2]}
|
|
|
@@ -197,13 +168,13 @@ while true; do
|
|
|
read -p "Enter your choice (1-3): " -n 1 -r
|
|
|
echo
|
|
|
case $REPLY in
|
|
|
- [1-3])
|
|
|
- CHOICE=$REPLY
|
|
|
- break
|
|
|
- ;;
|
|
|
- *)
|
|
|
- echo "❌ Invalid choice. Please enter 1, 2, or 3."
|
|
|
- ;;
|
|
|
+ [1-3])
|
|
|
+ CHOICE=$REPLY
|
|
|
+ break
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ echo "❌ Invalid choice. Please enter 1, 2, or 3."
|
|
|
+ ;;
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
@@ -235,18 +206,16 @@ success_message "Tag $VERSION_TAG is available"
|
|
|
|
|
|
section_header "Executing Release"
|
|
|
|
|
|
-# Step 7: Update version files and timestamp
|
|
|
-info_message "Updating version files and build timestamp..."
|
|
|
+# Step 7: Update version in package.json
|
|
|
+info_message "Updating version in package.json..."
|
|
|
update_package_json "$NEW_VERSION"
|
|
|
-update_webconfig_version "$NEW_VERSION"
|
|
|
-success_message "All version files and timestamp updated"
|
|
|
+success_message "Version updated in package.json"
|
|
|
|
|
|
-
|
|
|
-# Step 9: Commit all changes
|
|
|
-info_message "Committing version updates, timestamp changes, and generated config..."
|
|
|
-git add package.json public/webConfigApi.js
|
|
|
-git commit -m "chore: bump version to $NEW_VERSION and update timestamp for release $VERSION_TAG" || error_exit "Failed to commit changes"
|
|
|
-success_message "Version, timestamp, and config changes committed"
|
|
|
+# Step 8: Stage and commit changes
|
|
|
+info_message "Staging and committing version update..."
|
|
|
+git add package.json || error_exit "Failed to stage package.json"
|
|
|
+git commit -m "chore: bump version to $NEW_VERSION for release $VERSION_TAG" || error_exit "Failed to commit changes"
|
|
|
+success_message "Version change committed"
|
|
|
|
|
|
# Step 10: Create the tag at the new commit
|
|
|
info_message "Creating tag $VERSION_TAG..."
|
|
|
@@ -259,21 +228,10 @@ git push origin $CURRENT_BRANCH || error_exit "Failed to push changes to remote"
|
|
|
git push origin "$VERSION_TAG" || error_exit "Failed to push tag to remote"
|
|
|
success_message "Changes and tag pushed to remote"
|
|
|
|
|
|
-# Step 12: Execute package.sh for final build and packaging (if exists)
|
|
|
-if [ -f "bash/package.sh" ]; then
|
|
|
- info_message "Executing package.sh script for final build and packaging..."
|
|
|
- chmod +x bash/package.sh
|
|
|
- bash/package.sh || error_exit "Package script failed"
|
|
|
- success_message "Package script executed successfully"
|
|
|
-else
|
|
|
- info_message "bash/package.sh not found, skipping build packaging"
|
|
|
-fi
|
|
|
-
|
|
|
section_header "🎉 Release Completed Successfully!"
|
|
|
echo "✅ Tag $VERSION_TAG has been created and pushed to remote"
|
|
|
echo "✅ Version updated from $CURRENT_VERSION to $NEW_VERSION"
|
|
|
-echo "✅ Files updated: package.json, public/webConfigApi.js"
|
|
|
echo "✅ Commit: $(git rev-parse HEAD)"
|
|
|
echo ""
|
|
|
-echo "You can now view the release at:"
|
|
|
-echo "🔗 https://sg-git.pwtk.cc/ka-cn/pwtk-admin-web/releases"
|
|
|
+echo "Jenkins will automatically deploy to Cloudflare Pages."
|
|
|
+echo "🔗 Production: https://tg-live-game.pwtk-dev.work"
|