Initial commit
Build and Push Multi-Arch Docker Image / build (push) Has been cancelled

This commit is contained in:
dido committed 2026-09-03 11:19:41 +03:00
commit 8ce01cb00a
34 files changed
+8346

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
#!/bin/bash
# Build and Push Script for WebSSH
# Builds Docker image and pushes to Docker Hub
set -e
# Configuration
IMAGE_NAME="danaildr/webssh"
VERSION="0.3.1"
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}🐳 Docker Hub Build & Push Script${NC}"
echo -e "${BLUE}=================================${NC}"
ensure_buildx_builder() {
if ! docker buildx inspect >/dev/null 2>&1; then
docker buildx create --use --name webssh-builder >/dev/null
fi
docker buildx inspect --bootstrap >/dev/null
}
# Function to build and push to Docker Hub
build_and_push() {
# Check if user is logged in to Docker Hub
if ! docker info | grep -q "Username"; then
echo -e "${YELLOW}⚠️ You're not logged in to Docker Hub${NC}"
echo -e "${BLUE}ℹ️ Please run: docker login${NC}"
return 1
fi
ensure_buildx_builder
echo -e "${GREEN}🏗 Building & pushing multi-arch image ${IMAGE_NAME}:${VERSION} (${PLATFORMS})...${NC}"
docker buildx build \
--platform "${PLATFORMS}" \
--tag "${IMAGE_NAME}:${VERSION}" \
--tag "${IMAGE_NAME}:latest" \
--push \
--file deployment/Dockerfile \
.
echo -e "${GREEN}✅ Docker build & push successful${NC}"
echo ""
echo -e "${YELLOW}⚠️ Don't forget to create a GitHub release!${NC}"
}
# Function to show usage
show_usage() {
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " -v, --version Show configured version tag"
echo " -b, --build Build and push to Docker Hub"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 --version # Show version tag"
echo " $0 --build # Build and push multi-arch image"
}
# Parse command line arguments
case "${1:-}" in
-v|--version)
echo "${VERSION}"
;;
-b|--build)
build_and_push
;;
-h|--help|"")
show_usage
;;
*)
echo -e "${RED}❌ Unknown option: $1${NC}"
show_usage
exit 1
;;
esac
+212
View File
@@ -0,0 +1,212 @@
#!/bin/bash
# Version Management Script for WebSSH
# Automatically updates version numbers in help.html and build scripts
set -e
# Configuration
ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
VERSION_FILE="$ROOT_DIR/src/help.html"
BUILD_SCRIPT="$ROOT_DIR/deployment/scripts/docker-build-and-push.sh"
GITHUB_WORKFLOW="$ROOT_DIR/.github/workflows/build-and-publish.yml"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}🔧 WebSSH Version Management${NC}"
echo -e "${BLUE}=================================${NC}"
# Function to get current version
get_current_version() {
if [[ -f "$VERSION_FILE" ]]; then
grep -o 'WebSSH Multi-Connection Terminal v' "$VERSION_FILE" | sed 's/.*v\([0-9.]\+\).*/\1/'
else
echo "0.0.0"
fi
}
# Function to update version in help.html
update_help_version() {
local new_version=$1
echo -e "${GREEN}📝 Updating $VERSION_FILE to v$new_version${NC}"
# Update version in help.html
sed -i "s/WebSSH Multi-Connection Terminal v[0-9.]\+\.[0-9]\+/WebSSH Multi-Connection Terminal v$new_version/" "$VERSION_FILE"
echo -e "${GREEN}✅ $VERSION_FILE updated to v$new_version${NC}"
}
# Function to update version in build script
update_build_version() {
local new_version=$1
echo -e "${GREEN}🔨 Updating $BUILD_SCRIPT to v$new_version${NC}"
# Update version in build script
sed -i "s/VERSION=\"[0-9.]\+\.[0-9]\+\"/VERSION=\"$new_version\"/" "$BUILD_SCRIPT"
echo -e "${GREEN}✅ $BUILD_SCRIPT updated to v$new_version${NC}"
}
# Function to update version in GitHub workflow
update_github_workflow() {
local new_version=$1
echo -e "${GREEN}🐙 Updating $GITHUB_WORKFLOW to v$new_version${NC}"
# Update version in GitHub workflow
sed -i "s/WebSSH Multi-Connection Terminal v[0-9.]\+\.[0-9]\+/WebSSH Multi-Connection Terminal v$new_version/" "$GITHUB_WORKFLOW"
echo -e "${GREEN}✅ $GITHUB_WORKFLOW updated to v$new_version${NC}"
}
# Function to update version in Dockerfile (if needed)
update_dockerfile_version() {
local new_version=$1
echo -e "${GREEN}🐳 Checking if Dockerfile needs version update...${NC}"
# Check if Dockerfile has version comment
if [[ -f "Dockerfile" ]] && grep -q "# Production-ready Dockerfile for WebSSH" "Dockerfile"; then
echo -e "${YELLOW}ℹ️ Dockerfile already has version comment${NC}"
else
echo -e "${YELLOW}⚠️ Dockerfile missing version comment${NC}"
echo -e "${BLUE}ℹ️ Consider adding version comment to Dockerfile${NC}"
fi
}
# Function to validate version format
validate_version() {
local version=$1
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo -e "${RED}❌ Invalid version format: $version. Use format: X.Y.Z${NC}"
return 1
fi
return 0
}
# Main menu
show_menu() {
echo -e "${YELLOW}Current version: $(get_current_version)${NC}"
echo ""
echo -e "${BLUE}Choose an option:${NC}"
echo "1) Set new version"
echo "2) Patch version (increment last digit)"
echo "3) Minor version (increment middle digit)"
echo "4) Major version (increment first digit)"
echo "5) Show current files"
echo "6) Exit"
echo ""
read -p "Enter choice [1-6]: " choice
}
# Function to show current files
show_current_files() {
echo -e "${BLUE}📁 Current version information:${NC}"
echo -e "${GREEN} help.html: v$(get_current_version)${NC}"
echo -e "${GREEN} ${BUILD_SCRIPT}: v$(grep -o 'VERSION="[0-9.]\\+"' "${BUILD_SCRIPT}" | head -1 | sed 's/VERSION="\([0-9.]\+\)"/\1/')${NC}"
echo -e "${GREEN} ${GITHUB_WORKFLOW}: v$(grep -o 'WebSSH Multi-Connection Terminal v[0-9.]\\+' "${GITHUB_WORKFLOW}" | sed 's/.*v\([0-9.]\+\)/\1/')${NC}"
echo ""
}
# Main logic
main() {
while true; do
show_menu
case $choice in
1)
read -p "Enter new version (X.Y.Z): " new_version
if validate_version "$new_version"; then
update_help_version "$new_version"
update_build_version "$new_version"
update_github_workflow "$new_version"
update_dockerfile_version "$new_version"
echo -e "${GREEN}🎉 All files updated to v$new_version${NC}"
fi
;;
2)
current=$(get_current_version)
if [[ "$current" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
patch=$((${BASH_REMATCH[3]} + 1))
new_version="${major}.${minor}.${patch}"
update_help_version "$new_version"
update_build_version "$new_version"
update_github_workflow "$new_version"
update_dockerfile_version "$new_version"
echo -e "${GREEN}🎉 Patch version updated to v$new_version${NC}"
else
echo -e "${RED}❌ Could not parse current version${NC}"
fi
;;
3)
current=$(get_current_version)
if [[ "$current" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
major=${BASH_REMATCH[1]}
minor=$((${BASH_REMATCH[2]} + 1))
patch=0
new_version="${major}.${minor}.${patch}"
update_help_version "$new_version"
update_build_version "$new_version"
update_github_workflow "$new_version"
update_dockerfile_version "$new_version"
echo -e "${GREEN}🎉 Minor version updated to v$new_version${NC}"
else
echo -e "${RED}❌ Could not parse current version${NC}"
fi
;;
4)
current=$(get_current_version)
if [[ "$current" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
major=$((${BASH_REMATCH[1]} + 1))
minor=0
patch=0
new_version="${major}.${minor}.${patch}"
update_help_version "$new_version"
update_build_version "$new_version"
update_github_workflow "$new_version"
update_dockerfile_version "$new_version"
echo -e "${GREEN}🎉 Major version updated to v$new_version${NC}"
else
echo -e "${RED}❌ Could not parse current version${NC}"
fi
;;
5)
show_current_files
;;
6)
echo -e "${GREEN}👋 Goodbye!${NC}"
exit 0
;;
*)
echo -e "${RED}❌ Invalid choice. Please try again.${NC}"
;;
esac
echo ""
read -p "Press Enter to continue..." -r
done
}
# Check if files exist
if [[ ! -f "$VERSION_FILE" ]]; then
echo -e "${RED}❌ $VERSION_FILE not found${NC}"
exit 1
fi
if [[ ! -f "$BUILD_SCRIPT" ]]; then
echo -e "${RED}❌ $BUILD_SCRIPT not found${NC}"
exit 1
fi
if [[ ! -f "$GITHUB_WORKFLOW" ]]; then
echo -e "${RED}❌ $GITHUB_WORKFLOW not found${NC}"
exit 1
fi
# Run main function
main