ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat: Add automatic versioning system
Juan Denis8bccfcdcf818
diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.ymlnew file mode 100644index 00000000..cb4d4c61--- /dev/null+++ b/.github/workflows/version-bump.yml@@ -0,0 +1,110 @@+name: Version Bump++on:+ push:+ branches:+ - main+ paths-ignore:+ - 'VERSION'+ - '.github/workflows/version-bump.yml'++jobs:+ bump-version:+ runs-on: ubuntu-latest+ # Skip if commit message contains [skip ci] or [skip version]+ if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip version]') && !startsWith(github.event.head_commit.message, 'chore: bump version')"++ permissions:+ contents: write++ steps:+ - name: Checkout+ uses: actions/checkout@v4+ with:+ fetch-depth: 0+ token: ${{ secrets.GITHUB_TOKEN }}++ - name: Get current version+ id: current+ run: |+ if [ -f VERSION ]; then+ VERSION=$(cat VERSION | tr -d '\n\r ')+ else+ VERSION="0.0.0"+ fi+ echo "version=$VERSION" >> $GITHUB_OUTPUT+ echo "Current version: $VERSION"++ - name: Determine bump type+ id: bump+ run: |+ COMMIT_MSG="${{ github.event.head_commit.message }}"++ # Check for major version bump keywords+ if echo "$COMMIT_MSG" | grep -qiE "^(BREAKING|breaking!|major):"; then+ echo "type=major" >> $GITHUB_OUTPUT+ echo "Bump type: major"+ # Check for minor version bump keywords+ elif echo "$COMMIT_MSG" | grep -qiE "^(feat|feature|minor):"; then+ echo "type=minor" >> $GITHUB_OUTPUT+ echo "Bump type: minor"+ # Default to patch+ else+ echo "type=patch" >> $GITHUB_OUTPUT+ echo "Bump type: patch"+ fi++ - name: Calculate new version+ id: new+ run: |+ VERSION="${{ steps.current.outputs.version }}"+ BUMP_TYPE="${{ steps.bump.outputs.type }}"++ # Parse version components+ MAJOR=$(echo $VERSION | cut -d. -f1)+ MINOR=$(echo $VERSION | cut -d. -f2)+ PATCH=$(echo $VERSION | cut -d. -f3)++ # Bump appropriate component+ case $BUMP_TYPE in+ major)+ MAJOR=$((MAJOR + 1))+ MINOR=0+ PATCH=0+ ;;+ minor)+ MINOR=$((MINOR + 1))+ PATCH=0+ ;;+ patch)+ PATCH=$((PATCH + 1))+ ;;+ esac++ NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"+ echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT+ echo "New version: $NEW_VERSION"++ - name: Update VERSION file+ run: |+ echo "${{ steps.new.outputs.version }}" > VERSION+ cat VERSION++ - name: Commit and push+ run: |+ git config user.name "github-actions[bot]"+ git config user.email "github-actions[bot]@users.noreply.github.com"+ git add VERSION+ git commit -m "chore: bump version to ${{ steps.new.outputs.version }} [skip ci]"+ git push++ - name: Create summary+ run: |+ echo "## Version Bump Summary" >> $GITHUB_STEP_SUMMARY+ echo "" >> $GITHUB_STEP_SUMMARY+ echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY+ echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY+ echo "| Previous Version | ${{ steps.current.outputs.version }} |" >> $GITHUB_STEP_SUMMARY+ echo "| New Version | ${{ steps.new.outputs.version }} |" >> $GITHUB_STEP_SUMMARY+ echo "| Bump Type | ${{ steps.bump.outputs.type }} |" >> $GITHUB_STEP_SUMMARY+ echo "| Trigger Commit | ${{ github.event.head_commit.message }} |" >> $GITHUB_STEP_SUMMARYdiff --git a/VERSION b/VERSIONnew file mode 100644index 00000000..3eefcb9d--- /dev/null+++ b/VERSION@@ -0,0 +1 @@+1.0.0diff --git a/serverkit b/serverkitindex cc13a525..b3d62e31 100644--- a/serverkit+++ b/serverkit@@ -58,6 +58,86 @@ run_cli() {python cli.py "$@"}+# Version management+VERSION_FILE="$INSTALL_DIR/VERSION"+REMOTE_VERSION_URL="https://raw.githubusercontent.com/jhd3197/serverkit/main/VERSION"++get_local_version() {+ if [ -f "$VERSION_FILE" ]; then+ cat "$VERSION_FILE" | tr -d '\n\r '+ else+ echo "unknown"+ fi+}++get_remote_version() {+ curl -sf "$REMOTE_VERSION_URL" 2>/dev/null | tr -d '\n\r ' || echo "unknown"+}++compare_versions() {+ # Returns: 0 if equal, 1 if v1 > v2, 2 if v1 < v2+ local v1="$1"+ local v2="$2"++ if [ "$v1" = "$v2" ]; then+ return 0+ fi++ # Compare version components+ local v1_major=$(echo "$v1" | cut -d. -f1)+ local v1_minor=$(echo "$v1" | cut -d. -f2)+ local v1_patch=$(echo "$v1" | cut -d. -f3)++ local v2_major=$(echo "$v2" | cut -d. -f1)+ local v2_minor=$(echo "$v2" | cut -d. -f2)+ local v2_patch=$(echo "$v2" | cut -d. -f3)++ if [ "$v1_major" -gt "$v2_major" ] 2>/dev/null; then return 1; fi+ if [ "$v1_major" -lt "$v2_major" ] 2>/dev/null; then return 2; fi+ if [ "$v1_minor" -gt "$v2_minor" ] 2>/dev/null; then return 1; fi+ if [ "$v1_minor" -lt "$v2_minor" ] 2>/dev/null; then return 2; fi+ if [ "$v1_patch" -gt "$v2_patch" ] 2>/dev/null; then return 1; fi+ if [ "$v1_patch" -lt "$v2_patch" ] 2>/dev/null; then return 2; fi++ return 0+}++cmd_version() {+ local version=$(get_local_version)+ echo "ServerKit version $version"+}++cmd_check_update() {+ print_info "Checking for updates..."++ local local_version=$(get_local_version)+ local remote_version=$(get_remote_version)++ echo ""+ echo " Installed version: $local_version"+ echo " Latest version: $remote_version"+ echo ""++ if [ "$remote_version" = "unknown" ]; then+ print_warning "Could not check remote version (network error?)"+ return 1+ fi++ compare_versions "$local_version" "$remote_version"+ local result=$?++ if [ $result -eq 2 ]; then+ print_success "Update available! Run 'sudo serverkit update' to upgrade."+ return 0+ elif [ $result -eq 0 ]; then+ print_success "You are running the latest version."+ return 0+ else+ print_info "You are running a newer version than released."+ return 0+ fi+}+# Commandscmd_help() {print_header@@ -100,6 +180,10 @@ cmd_help() {echo " list-sites List all configured sites"echo " remove-site Remove a site"echo ""+ echo "Version Commands:"+ echo " version Show current version"+ echo " check-update Check if updates are available"+ echo ""echo "Utility Commands:"echo " generate-keys Generate secure keys for .env"echo " config Edit configuration"@@ -239,12 +323,33 @@ cmd_update() {check_installedprint_headerecho ""- print_info "Updating ServerKit..."cd "$INSTALL_DIR"- # Store current version- CURRENT_VERSION=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")+ # Get versions+ CURRENT_VERSION=$(get_local_version)+ REMOTE_VERSION=$(get_remote_version)++ echo " Installed version: $CURRENT_VERSION"+ echo " Latest version: $REMOTE_VERSION"+ echo ""++ # Check if update is needed+ if [ "$REMOTE_VERSION" != "unknown" ]; then+ compare_versions "$CURRENT_VERSION" "$REMOTE_VERSION"+ local result=$?+ if [ $result -eq 0 ]; then+ print_success "Already running the latest version."+ echo ""+ read -p "Force update anyway? [y/N] " -n 1 -r+ echo ""+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then+ exit 0+ fi+ fi+ fi++ print_info "Updating ServerKit..."# Stop servicesprint_info "Stopping services..."@@ -260,7 +365,8 @@ cmd_update() {chmod +x "$INSTALL_DIR/serverkit"chmod +x "$INSTALL_DIR/scripts/"*.sh 2>/dev/null || true- NEW_VERSION=$(git rev-parse --short HEAD)+ # Get new version from VERSION file+ NEW_VERSION=$(get_local_version)# Update Python dependenciesprint_info "Updating Python dependencies..."@@ -722,6 +828,12 @@ case "${1:-help}" inupdate)cmd_update;;+ version|--version|-v)+ cmd_version+ ;;+ check-update)+ cmd_check_update+ ;;uninstall)cmd_uninstall;;