From 87d6e6e6be3ddf6846e872d538cc83ad4fb32f84 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Wed, 10 Sep 2025 23:30:24 +0330 Subject: [PATCH 1/5] ci: add build step to release workflow --- .github/workflows/release.yml | 67 ++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bfdfad..1f70caf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,33 +6,84 @@ on: - 'VERSION' jobs: - create-release: + build-and-release: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + cache-dependency-path: core/scripts/auth/go.sum + - name: Read version from VERSION file - run: | - version=$(cat VERSION) - echo "version=${version}" >> $GITHUB_OUTPUT id: get_version + run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT + + - name: Initialize Go module + working-directory: ./core/scripts/auth + run: | + go mod init hysteria_auth + go mod tidy + + - name: Build and Package for linux-amd64 + id: package_amd64 + run: | + (cd core/scripts/auth && GOOS=linux GOARCH=amd64 go build -o user_auth .) + zip_name="Blitz-amd64.zip" + zip -r "$zip_name" . \ + -x ".git/*" \ + ".github/*" \ + ".gitignore" \ + "CONTRIBUTING.md" \ + "LICENSE" \ + "README*.md" \ + "SECURITY.md" \ + "changelog" \ + "core/scripts/auth/go.*" \ + "core/scripts/auth/user_auth.go" + rm core/scripts/auth/user_auth + echo "zip_name=$zip_name" >> $GITHUB_OUTPUT + + + - name: Build and Package for linux-arm64 + id: package_arm64 + run: | + (cd core/scripts/auth && GOOS=linux GOARCH=arm64 go build -o user_auth .) + zip_name="Blitz-arm64.zip" + zip -r "$zip_name" . \ + -x ".git/*" \ + ".github/*" \ + ".gitignore" \ + "CONTRIBUTING.md" \ + "LICENSE" \ + "README*.md" \ + "SECURITY.md" \ + "changelog" \ + "core/scripts/auth/go.*" \ + "core/scripts/auth/user_auth.go" + rm core/scripts/auth/user_auth + echo "zip_name=$zip_name" >> $GITHUB_OUTPUT + - name: Read changelog for release description + id: get_changelog run: | changelog=$(cat changelog) echo "changelog<> $GITHUB_OUTPUT echo "$changelog" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - id: get_changelog - name: Create GitHub Release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.get_version.outputs.version }} name: "${{ steps.get_version.outputs.version }}" body: ${{ steps.get_changelog.outputs.changelog }} + files: | + ${{ steps.package_amd64.outputs.zip_name }} + ${{ steps.package_arm64.outputs.zip_name }} draft: false prerelease: false From 66447ae8982e63c78b686a9aedf454cd05e8abbd Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Thu, 11 Sep 2025 23:18:49 +0330 Subject: [PATCH 2/5] refactor(install): switch to release artifacts instead of git clone --- install.sh | 60 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index e48f7f3..bdb4d71 100644 --- a/install.sh +++ b/install.sh @@ -119,7 +119,7 @@ install_mongodb() { } install_packages() { - local REQUIRED_PACKAGES=("jq" "curl" "pwgen" "python3" "python3-pip" "python3-venv" "git" "bc" "zip" "cron" "lsof" "golang-go" "gnupg" "lsb-release") + local REQUIRED_PACKAGES=("jq" "curl" "pwgen" "python3" "python3-pip" "python3-venv" "bc" "zip" "lsof" "gnupg" "lsb-release") local MISSING_PACKAGES=() log_info "Checking required packages..." @@ -153,27 +153,63 @@ install_packages() { install_mongodb } -clone_repository() { - log_info "Cloning Blitz repository..." - +download_and_extract_release() { + log_info "Downloading and extracting Blitz panel..." + if [ -d "/etc/hysteria" ]; then log_warning "Directory /etc/hysteria already exists." - read -p "Do you want to remove it and clone again? (y/n): " -n 1 -r + read -p "Do you want to remove it and install again? (y/n): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then rm -rf /etc/hysteria else - log_info "Using existing directory." + log_info "Skipping download. Using existing directory." return 0 fi fi - - if git clone https://github.com/ReturnFI/Blitz /etc/hysteria &> /dev/null; then - log_success "Repository cloned successfully" + + local arch + case $(uname -m) in + x86_64) arch="amd64" ;; + aarch64) arch="arm64" ;; + *) + log_error "Unsupported architecture: $(uname -m)" + exit 1 + ;; + esac + log_info "Detected architecture: $arch" + + local zip_name="Blitz-${arch}.zip" + local download_url="https://github.com/ReturnFI/Blitz/releases/latest/download/${zip_name}" + local temp_zip="/tmp/${zip_name}" + + log_info "Downloading from ${download_url}..." + if curl -sL -o "$temp_zip" "$download_url"; then + log_success "Download complete." else - log_error "Failed to clone repository" + log_error "Failed to download the release asset. Please check the URL and your connection." exit 1 fi + + log_info "Extracting to /etc/hysteria..." + mkdir -p /etc/hysteria + if unzip -q "$temp_zip" -d /etc/hysteria; then + log_success "Extracted successfully." + else + log_error "Failed to extract the archive." + exit 1 + fi + + rm "$temp_zip" + log_info "Cleaned up temporary file." + + local auth_binary="/etc/hysteria/core/scripts/auth/user_auth" + if [ -f "$auth_binary" ]; then + chmod +x "$auth_binary" + log_success "Set execute permission for auth binary." + else + log_warning "Auth binary not found at $auth_binary. The installation might be incomplete." + fi } setup_python_env() { @@ -227,7 +263,7 @@ main() { check_root check_os_version install_packages - clone_repository + download_and_extract_release setup_python_env add_alias @@ -239,4 +275,4 @@ main() { run_menu } -main +main \ No newline at end of file From d8f6d4cf9a27a96db8212017450e70308a8e65cc Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Thu, 11 Sep 2025 23:22:41 +0330 Subject: [PATCH 3/5] refactor(upgrade): use release artifacts instead of git clone --- upgrade.sh | 97 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/upgrade.sh b/upgrade.sh index 7d0e9b9..e441cbe 100644 --- a/upgrade.sh +++ b/upgrade.sh @@ -6,9 +6,6 @@ trap 'echo -e "\nโŒ An error occurred. Aborting."; exit 1' ERR # ========== Variables ========== HYSTERIA_INSTALL_DIR="/etc/hysteria" HYSTERIA_VENV_DIR="$HYSTERIA_INSTALL_DIR/hysteria2_venv" -AUTH_BINARY_DIR="$HYSTERIA_INSTALL_DIR/core/scripts/auth" -REPO_URL="https://github.com/ReturnFI/Blitz" -REPO_BRANCH="main" GEOSITE_URL="https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/release/geosite.dat" GEOIP_URL="https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/release/geoip.dat" MIGRATE_SCRIPT_PATH="$HYSTERIA_INSTALL_DIR/core/scripts/db/migrate_users.py" @@ -81,6 +78,44 @@ migrate_json_to_mongo() { fi } +download_and_extract_latest_release() { + local arch + case $(uname -m) in + x86_64) arch="amd64" ;; + aarch64) arch="arm64" ;; + *) + error "Unsupported architecture: $(uname -m)" + exit 1 + ;; + esac + info "Detected architecture: $arch" + + local zip_name="Blitz-${arch}.zip" + local download_url="https://github.com/ReturnFI/Blitz/releases/latest/download/${zip_name}" + local temp_zip="/tmp/${zip_name}" + + info "Downloading latest release from ${download_url}..." + if ! curl -sL -o "$temp_zip" "$download_url"; then + error "Failed to download the release asset. Please check the URL and your connection." + exit 1 + fi + success "Download complete." + + info "Removing old installation directory..." + rm -rf "$HYSTERIA_INSTALL_DIR" + mkdir -p "$HYSTERIA_INSTALL_DIR" + + info "Extracting to ${HYSTERIA_INSTALL_DIR}..." + if ! unzip -q "$temp_zip" -d "$HYSTERIA_INSTALL_DIR"; then + error "Failed to extract the archive." + exit 1 + fi + success "Extracted successfully." + + rm "$temp_zip" + info "Cleaned up temporary file." +} + # ========== Capture Active Services ========== declare -a ACTIVE_SERVICES_BEFORE_UPGRADE=() ALL_SERVICES=( @@ -106,36 +141,6 @@ done # ========== Install MongoDB Prerequisite ========== install_mongodb -# ========== Install Go and Compile Auth Binary ========== -install_go_and_compile_auth() { - info "Checking for Go and compiling authentication binary..." - if ! command -v go &>/dev/null; then - warn "Go is not installed. Attempting to install..." - apt-get install -y golang-go - success "Go installed successfully." - else - success "Go is already installed." - fi - - if [[ -f "$AUTH_BINARY_DIR/user_auth.go" ]]; then - info "Found auth binary source. Compiling..." - ( - cd "$AUTH_BINARY_DIR" - go mod init hysteria_auth >/dev/null 2>&1 - go mod tidy >/dev/null 2>&1 - if go build -o user_auth .; then - chmod +x user_auth - success "Authentication binary compiled successfully." - else - error "Failed to compile the authentication binary." - exit 1 - fi - ) - else - warn "Authentication binary source not found. Skipping compilation." - fi -} - # ========== Backup Files ========== cd /root TEMP_DIR=$(mktemp -d) @@ -165,12 +170,8 @@ for FILE in "${FILES[@]}"; do fi done -# ========== Replace Installation ========== -info "Removing old hysteria directory..." -rm -rf "$HYSTERIA_INSTALL_DIR" - -info "Cloning Blitz repository (branch: $REPO_BRANCH)..." -git clone -q -b "$REPO_BRANCH" "$REPO_URL" "$HYSTERIA_INSTALL_DIR" +# ========== Download and Replace Installation ========== +download_and_extract_latest_release # ========== Download Geo Data ========== info "Downloading geosite.dat and geoip.dat..." @@ -202,10 +203,14 @@ fi # ========== Permissions ========== info "Setting ownership and permissions..." -chown hysteria:hysteria "$HYSTERIA_INSTALL_DIR/ca.key" "$HYSTERIA_INSTALL_DIR/ca.crt" -chmod 640 "$HYSTERIA_INSTALL_DIR/ca.key" "$HYSTERIA_INSTALL_DIR/ca.crt" -chown -R hysteria:hysteria "$HYSTERIA_INSTALL_DIR/core/scripts/telegrambot" +if id -u hysteria >/dev/null 2>&1; then + chown hysteria:hysteria "$HYSTERIA_INSTALL_DIR/ca.key" "$HYSTERIA_INSTALL_DIR/ca.crt" 2>/dev/null || true + chmod 640 "$HYSTERIA_INSTALL_DIR/ca.key" "$HYSTERIA_INSTALL_DIR/ca.crt" 2>/dev/null || true + chown -R hysteria:hysteria "$HYSTERIA_INSTALL_DIR/core/scripts/telegrambot" 2>/dev/null || true +fi chmod +x "$HYSTERIA_INSTALL_DIR/core/scripts/hysteria2/kick.py" +chmod +x "$HYSTERIA_INSTALL_DIR/core/scripts/auth/user_auth" +success "Permissions updated." # ========== Virtual Environment ========== info "Setting up virtual environment and installing dependencies..." @@ -219,9 +224,6 @@ success "Python environment ready." # ========== Data Migration ========== migrate_json_to_mongo -# ========== Compile Go Binary ========== -install_go_and_compile_auth - # ========== Systemd Services ========== info "Ensuring systemd services are configured..." if source "$HYSTERIA_INSTALL_DIR/core/scripts/scheduler.sh"; then @@ -261,6 +263,7 @@ else fi # ========== Launch Menu ========== -sleep 10 +info "Upgrade process finished. Launching menu..." +cd "$HYSTERIA_INSTALL_DIR" chmod +x menu.sh -./menu.sh +./menu.sh \ No newline at end of file From cab42fb2499568e1b122b187083465c6136bb64c Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Thu, 11 Sep 2025 23:24:50 +0330 Subject: [PATCH 4/5] ci: remove auth binary compilation from core install script --- core/scripts/hysteria2/install.sh | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/core/scripts/hysteria2/install.sh b/core/scripts/hysteria2/install.sh index e90b07c..2fdd92e 100644 --- a/core/scripts/hysteria2/install.sh +++ b/core/scripts/hysteria2/install.sh @@ -5,28 +5,6 @@ source /etc/hysteria/core/scripts/utils.sh source /etc/hysteria/core/scripts/scheduler.sh define_colors -compile_auth_binary() { - echo "Compiling authentication binary..." - local auth_dir="/etc/hysteria/core/scripts/auth" - - if [ -f "$auth_dir/user_auth.go" ]; then - ( - cd "$auth_dir" || exit 1 - go mod init hysteria-auth >/dev/null 2>&1 - go mod tidy >/dev/null 2>&1 - if go build -o user_auth .; then - chmod +x user_auth - echo "Authentication binary compiled successfully." - else - echo -e "${red}Error:${NC} Failed to compile the authentication binary." - exit 1 - fi - ) - else - echo -e "${red}Error:${NC} Go source file not found at $auth_dir/user_auth.go" - exit 1 - fi -} install_hysteria() { local port=$1 @@ -36,8 +14,6 @@ install_hysteria() { mkdir -p /etc/hysteria && cd /etc/hysteria/ - compile_auth_binary - echo "Generating CA key and certificate..." openssl ecparam -genkey -name prime256v1 -out ca.key >/dev/null 2>&1 openssl req -new -x509 -days 36500 -key ca.key -out ca.crt -subj "/CN=$sni" >/dev/null 2>&1 From a69fa8cdc17f0e96a0538362148a086c841e3f4f Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Thu, 11 Sep 2025 23:30:00 +0330 Subject: [PATCH 5/5] Update changelog --- changelog | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/changelog b/changelog index 15d2ae0..e2964c2 100644 --- a/changelog +++ b/changelog @@ -1,12 +1,13 @@ -### ๐Ÿš€ **\[2.0.0] โ€“ Major Release: MongoDB Migration** +### ๐Ÿš€ **\[2.1.0] โ€“ Streamlined Installation & CI Improvements** -*Released: 2025-09-10* +*Released: 2025-09-11* -#### ๐Ÿ’พ Core Update +#### โš™๏ธ CI/CD -* ๐Ÿ“ฆ **User management migrated from `users.json` โ†’ MongoDB** -* โšก Improved **scalability, performance, and reliability** for large deployments +* ๐Ÿ› ๏ธ Added **build step** to release workflow +* ๐Ÿงน Removed unnecessary **auth binary compilation** from core install script -#### โš ๏ธ Breaking Change +#### ๐Ÿ“ฆ Installation & Upgrade -* Previous JSON-based `users.json` file is no longer used +* ๐Ÿ”„ **Refactored install script** to use release artifacts instead of `git clone` +* โฌ†๏ธ **Refactored upgrade script** to pull release artifacts for faster, more reliable updates