From a6005361b53e95445578fecec5885ca70d6e17b6 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Tue, 31 Dec 2024 03:31:20 +0200 Subject: [PATCH] Fix to move CI/CD to dedicated repo --- .github/build/bootstrap.bash | 55 ---- .github/build/build-deb-module.bash | 148 ---------- .github/build/build-deb-package.bash | 197 ------------- .github/build/build-rpm-module.bash | 171 ----------- .github/build/build-rpm-package.bash | 219 -------------- .github/build/environment.bash | 44 --- .github/build/functions.bash | 372 ------------------------ .github/workflows/webmin.dev:webmin.yml | 9 +- 8 files changed, 6 insertions(+), 1209 deletions(-) delete mode 100755 .github/build/bootstrap.bash delete mode 100755 .github/build/build-deb-module.bash delete mode 100755 .github/build/build-deb-package.bash delete mode 100755 .github/build/build-rpm-module.bash delete mode 100755 .github/build/build-rpm-package.bash delete mode 100755 .github/build/environment.bash delete mode 100755 .github/build/functions.bash diff --git a/.github/build/bootstrap.bash b/.github/build/bootstrap.bash deleted file mode 100755 index 2868e731d..000000000 --- a/.github/build/bootstrap.bash +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1091 -# bootstrap.bash -# Copyright Ilia Ross -# Bootstrap the build process - -# Bootstrap URL -BUILD_BOOTSTRAP_URL="https://raw.githubusercontent.com/webmin/webmin/master/.github/build" - -# Bootstrap scripts -BOOTSTRAP_SCRIPTS=( - "environment.bash" - "functions.bash" - "build-deb-module.bash" - "build-deb-package.bash" - "build-rpm-module.bash" - "build-rpm-package.bash" -) - -bootstrap() { - local base_url="$BUILD_BOOTSTRAP_URL/" - local script_dir - script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - download_script() { - local script_url="$1" - local script_path="$2" - for downloader in "curl -fsSL" "wget -qO-"; do - if command -v "${downloader%% *}" >/dev/null 2>&1; then - if eval "$downloader \"$script_url\" > \"$script_path\""; then - chmod +x "$script_path" - return 0 - fi - fi - done - return 1 - } - for script in "${BOOTSTRAP_SCRIPTS[@]}"; do - local script_path="$script_dir/$script" - if [ ! -f "$script_path" ]; then - if ! download_script "${base_url}${script}" "$script_path"; then - echo "Error: Failed to download $script. Cannot continue." - exit 1 - fi - fi - done - - # Source general build functions - source "$script_dir/functions.bash" || exit 1 - - # Source build variables - source "$script_dir/environment.bash" || exit 1 -} - -# Bootstrap build environment -bootstrap || exit 1 diff --git a/.github/build/build-deb-module.bash b/.github/build/build-deb-module.bash deleted file mode 100755 index d3ae689f9..000000000 --- a/.github/build/build-deb-module.bash +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC2034 -# build-deb-module.bash -# Copyright Ilia Ross -# -# Automatically builds DEB Webmin module pulls changes from GitHub, creates -# testing builds from the latest code with English-only support, production -# builds from the latest tag, uploads them to the pre-configured repository, -# updates the repository metadata, and interacts with the environment using -# bootstrap -# -# Usage: -# -# Build testing module with in verbose mode -# ./build-deb-module.bash virtualmin-nginx --testing --verbose -# -# Build specific module with version and release -# ./build-deb-module.bash virtualmin-nginx 2.36 2 -# - -# shellcheck disable=SC1091 -# Bootstrap build environment -source ./bootstrap.bash || exit 1 - -# Build module func -build_module() { - # Always return back to root directory - cd "$ROOT_DIR" || exit 1 - - # Define variables - local last_commit_date - local ver="" - local verorig="" - local module=$1 - local rel - local devel=0 - local root_module="$ROOT_DIR/$module" - - # Print build actual date - date=$(get_current_date) - - # Print opening header - echo "************************************************************************" - echo " build start date: $date " - echo " package format: DEB " - echo " module: $module " - - # Pull or clone module repository - remove_dir "$root_module" - cmd=$(make_module_repo_cmd "$module" "$MODULES_REPO_URL") - eval "$cmd" - rs=$? - - # Git last commit date - last_commit_date=$(get_last_commit_date "$root_module") - - # Handle other params - cd "$root_module" || exit 1 - if [[ "'$2'" != *"--"* ]]; then - ver=$2 - fi - if [[ "'$3'" != *"--"* ]] && [[ -n "$3" ]]; then - rel=$3 - else - rel=1 - fi - if [ -z "$ver" ]; then - ver=$(get_module_version "$root_module") - fi - if [[ "'$*'" == *"--testing"* ]]; then - devel=1 - verorig=$ver - ver=$(echo "$ver" | cut -d. -f1,2) - ver="$ver.$last_commit_date" - fi - - echo " package output version: $ver-$rel" - echo "************************************************************************" - - echo "Pulling latest changes.." - postcmd $rs - echo - - echo "Pre-clean up .." - # Make sure directories exist - make_dir "$root_module/tmp" - make_dir "$ROOT_REPOS" - - # Purge old files - purge_dir "$root_module/tmp" - if [ "$module" != "" ]; then - rm -f "$ROOT_REPOS/$module-latest"* - fi - postcmd $? - echo - - # Download required build dependencies - make_module_build_deps - - # Build DEB package - echo "Building packages .." - ( - # XXXX Update actual module testing version dynamically - cd "$ROOT_DIR" || exit 1 - cmd="$ROOT_DIR/build-deps/makemoduledeb.pl --release $rel --deb-depends \ - --licence 'GPLv3' --email '$BUILDER_MODULE_EMAIL' --allow-overwrite \ - --target-dir $root_module/tmp $module $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? - ) - - echo - echo "Preparing built files for upload .." - # Move DEB to repos - cmd="find $root_module/tmp -name webmin-${module}*$verorig*\.deb -exec mv '{}' \ - $ROOT_REPOS \; $VERBOSITY_LEVEL" - eval "$cmd" - if [ "$devel" -eq 1 ]; then - cmd="mv -f $ROOT_REPOS/*${module}*$verorig*\.deb \ - $ROOT_REPOS/${module}_${ver}-${rel}_all.deb $VERBOSITY_LEVEL" - eval "$cmd" - fi - postcmd $? - echo - - # Adjust module filename - echo "Adjusting module filename .." - adjust_module_filename "$ROOT_REPOS" "deb" - postcmd $? - echo - - echo "Post-clean up .." - remove_dir "$root_module" - postcmd $? -} - -# Main -if [ -n "$1" ] && [[ "'$1'" != *"--"* ]]; then - MODULES_REPO_URL="$VIRTUALMIN_ORG_AUTH_URL" - build_module "$@" - cloud_upload_list_upload=("$ROOT_REPOS/*$1*") - cloud_upload cloud_upload_list_upload - cloud_repo_sign_and_update -else - # Error otherwise - echo "Error: No module specified" - exit 1 -fi diff --git a/.github/build/build-deb-package.bash b/.github/build/build-deb-package.bash deleted file mode 100755 index 3955457a8..000000000 --- a/.github/build/build-deb-package.bash +++ /dev/null @@ -1,197 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC2034 -# build-deb-package.bash -# Copyright Ilia Ross -# -# Automatically builds DEB packages of Webmin and Usermin with the latest -# Authentic Theme, pulls changes from GitHub, creates testing builds from the -# latest code with English-only support, production builds from the latest tag, -# uploads them to the pre-configured repository, updates the repository -# metadata, and interacts with the environment using bootstrap -# -# Usage: -# -# Pull and build production versions of both Webmin and Usermin -# ./build-deb-package.bash -# -# Pull and build testing versions of both Webmin and Usermin -# ./build-deb-package.bash --testing -# -# Pull and build production Webmin version 2.101, forcing -# release version 3, displaying verbose output -# ./build-deb-package.bash webmin 2.101 3 --testing -# -# Pull and build production Usermin version 2.000, -# automatically setting release version -# ./build-deb-package.bash usermin 2.000 -# - -# shellcheck disable=SC1091 -# Bootstrap build environment -source ./bootstrap.bash || exit 1 - -# Build product func -build_prod() { - - # Pack with English only in devel builds - local english_only=0 - if [[ "'$*'" == *"--testing"* ]]; then - english_only=1 - fi - - # Always return back to root directory - cd "$ROOT_DIR" || exit 1 - - # Define root - local prod=$1 - local root_prod="$ROOT_DIR/$prod" - local root_apt="$root_prod/deb" - local ver="" - local devel=0 - - # Print build actual date - date=$(get_current_date) - - # Print opening header - echo "************************************************************************" - echo " build start date: $date " - echo " package format: DEB " - echo " product: $prod " - echo -n " downloading packages: " - - # Download products from repos - make_packages_repos "$root_prod" "$prod" - local rs=$? # Store to print success or failure nicely later - if [ $rs -eq 0 ]; then - echo -e "✔" - else - echo -e "✘" - fi - - # Print package version - echo -n " package version: " - - # Switch to product directory explicitly - cd "$root_prod" || exit 1 - - # Get latest product version (theme vs product) - date_version=$(get_latest_commit_date_version "$root_prod") - - # Handle other params - if [[ "'$2'" != *"--"* ]]; then - ver=$2 - fi - if [[ "'$3'" != *"--"* ]] && [[ -n "$3" ]]; then - rel=$3 - relval="-$3" - else - rel=1 - relval="" - fi - if [ -z "$ver" ]; then - ver=$(get_current_repo_tag "$root_prod") - fi - if [[ "'$*'" == *"--testing"* ]]; then - devel=1 - ver="$ver.$date_version" - # Set actual product version - echo "${ver}" >"version" - fi - printf "%s-%s\n" "$ver" "$rel" - echo "************************************************************************" - - echo "Pulling latest changes.." - # We need to pull first to get the latest tag, - # so here we only report an error if any - postcmd $rs - echo - - echo "Pre-clean up .." - # Make sure directories exist - make_dir "$ROOT_REPOS/" - make_dir "$root_apt/" - make_dir "$root_prod/newkey/deb/" - make_dir "$root_prod/umodules/" - make_dir "$root_prod/minimal/" - make_dir "$root_prod/tarballs/" - - # Re-create legacy link - remove_dir "$ROOT_DIR/webadmin" - ln -s "$ROOT_DIR/webmin" "$ROOT_DIR/webadmin" - - # Purge old files - purge_dir "$root_prod/newkey/deb" - purge_dir "$root_prod/umodules" - purge_dir "$root_prod/minimal" - purge_dir "$root_prod/tarballs" - if [ "$prod" != "" ]; then - rm -f "$ROOT_REPOS/$prod-"* - rm -f "$ROOT_REPOS/${prod}_"* - fi - postcmd $? - echo - - # Descend to project dir - cd "$root_prod" || exit 1 - - if [ "$english_only" = "1" ]; then - echo "Cleaning languages .." - cmd="./bin/language-manager --mode=clean --yes $VERBOSITY_LEVEL_WITH_INPUT" - eval "$cmd" - postcmd $? - echo - else - # Force restore build directory - if [ ! -f "lang/ja" ]; then - echo "Restoring languages .." - cmd="git checkout \"*\" $VERBOSITY_LEVEL && git clean -f -d \ - $VERBOSITY_LEVEL && git pull $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? - echo - fi - fi - - echo "Pre-building package .." - eval "$cmd" - cmd="./makedist.pl \"${ver}${relval}\" $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? - echo - - echo "Building package .." - if [ "$relval" == "" ]; then - cmd="./makedebian.pl \"$ver\" $VERBOSITY_LEVEL" - else - cmd="./makedebian.pl \"$ver\" \"$rel\" $VERBOSITY_LEVEL" - fi - eval "$cmd" - postcmd $? - echo - - cd "$ROOT_DIR" || exit 1 - echo "Preparing built files for upload .." - cmd="cp -f $root_prod/tarballs/${prod}-${ver}*\.tar.gz \ - $ROOT_REPOS/${prod}-$ver.tar.gz $VERBOSITY_LEVEL" - eval "$cmd" - cmd="find $root_apt -name ${prod}_${ver}${relval}*\.deb -exec mv '{}' \ - $ROOT_REPOS \; $VERBOSITY_LEVEL" - eval "$cmd" - cmd="mv -f $ROOT_REPOS/${prod}_${ver}${relval}*\.deb \ - $ROOT_REPOS/${prod}_${ver}-${rel}_all.deb $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? -} - -# Main -if [ -n "$1" ] && [[ "$1" != --* ]]; then - build_prod "$@" - cloud_upload_list_upload=("$ROOT_REPOS/$1*") -else - build_prod webmin "$@" - build_prod usermin "$@" - cloud_upload_list_upload=("$ROOT_REPOS/"*) -fi - -cloud_upload cloud_upload_list_upload -cloud_repo_sign_and_update diff --git a/.github/build/build-rpm-module.bash b/.github/build/build-rpm-module.bash deleted file mode 100755 index 5940098d0..000000000 --- a/.github/build/build-rpm-module.bash +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC2034 -# build-rpm-module.bash -# Copyright Ilia Ross -# -# Automatically builds DEB Webmin module pulls changes from GitHub, creates -# testing builds from the latest code with English-only support, production -# builds from the latest tag, uploads them to the pre-configured repository, -# updates the repository metadata, and interacts with the environment using -# bootstrap -# -# Usage: -# -# Build testing module with in verbose mode -# ./build-rpm-module.bash virtualmin-nginx --testing --verbose -# -# Build specific module with version and release -# ./build-rpm-module.bash virtualmin-nginx 2.36 2 -# - -# shellcheck disable=SC1091 -# Bootstrap build environment -source ./bootstrap.bash || exit 1 - -# Build module func -build_module() { - # Always return back to root directory - cd "$ROOT_DIR" || exit 1 - - # Define variables - local last_commit_date - local ver="" - local verorig="" - local module=$1 - local rel - local epoch - local devel=0 - local root_module="$ROOT_DIR/$module" - - # Print build actual date - date=$(get_current_date) - - # Print opening header - echo "************************************************************************" - echo " build start date: $date " - echo " package format: RPM " - echo " module: $module " - - # Pull or clone module repository - remove_dir "$root_module" - cmd=$(make_module_repo_cmd "$module" "$MODULES_REPO_URL") - eval "$cmd" - rs=$? - - # Git last commit date - last_commit_date=$(get_last_commit_date "$root_module") - - # Handle other params - cd "$root_module" || exit 1 - if [[ "'$2'" != *"--"* ]]; then - ver=$2 - fi - if [[ "'$3'" != *"--"* ]] && [[ -n "$3" ]]; then - rel=$3 - else - rel=1 - fi - if [[ "'$4'" != *"--"* ]] && [[ -n "$4" ]]; then - epoch="--epoch $4" - fi - if [ -z "$ver" ]; then - ver=$(get_module_version "$root_module") - fi - if [[ "'$*'" == *"--testing"* ]]; then - devel=1 - verorig=$ver - ver=$(echo "$ver" | cut -d. -f1,2) - ver="$ver.$last_commit_date" - fi - - echo " package output version: $ver-$rel" - echo "************************************************************************" - - echo "Pulling latest changes.." - postcmd $rs - echo - - echo "Pre-clean up .." - # Make sure directories exist - make_dir "$root_module/tmp" - make_dir "$ROOT_DIR/newkey/rpm/" - make_dir "$ROOT_DIR/umodules/" - make_dir "$ROOT_DIR/minimal/" - make_dir "$ROOT_DIR/tarballs/" - make_dir "$ROOT_BUILD/BUILD/" - make_dir "$ROOT_BUILD/BUILDROOT/" - make_dir "$ROOT_BUILD/RPMS/" - make_dir "$ROOT_RPMS" - make_dir "$ROOT_BUILD/SOURCES/" - make_dir "$ROOT_BUILD/SPECS/" - make_dir "$ROOT_BUILD/SRPMS/" - make_dir "$ROOT_REPOS" - - # Purge old files - purge_dir "$root_module/tmp" - if [ "$module" != "" ]; then - rm -f "$ROOT_REPOS/$module-latest"* - fi - postcmd $? - echo - - # Download required build dependencies - make_module_build_deps - - # Build RPM package - echo "Building packages.." - ( - # XXXX Update actual module testing version dynamically - cd "$ROOT_DIR" || exit 1 - cmd="$ROOT_DIR/build-deps/makemodulerpm.pl $epoch--release \ - $rel --rpm-depends --licence 'GPLv3' --allow-overwrite --rpm-dir \ - $ROOT_BUILD --target-dir $root_module/tmp $module $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? - ) - - echo - echo "Preparing built files for upload .." - # Move RPM to repos - cmd="find $ROOT_RPMS -name wbm-$module*$verorig*\.rpm -exec mv '{}' \ - $ROOT_REPOS \; $VERBOSITY_LEVEL" - eval "$cmd" - if [ "$devel" -eq 1 ]; then - cmd="mv -f $ROOT_REPOS/wbm-$module*$verorig*\.rpm \ - $ROOT_REPOS/${module}-$ver-$rel.noarch.rpm $VERBOSITY_LEVEL" - eval "$cmd" - fi - postcmd $? - echo - - # Adjust module filename - echo "Adjusting module filename .." - adjust_module_filename "$ROOT_REPOS" "rpm" - postcmd $? - echo - - echo "Post-clean up .." - remove_dir "$root_module" - # Purge old files - purge_dir "$ROOT_BUILD/BUILD" - purge_dir "$ROOT_BUILD/BUILDROOT" - purge_dir "$ROOT_BUILD/RPMS" - purge_dir "$ROOT_BUILD/SOURCES" - purge_dir "$ROOT_BUILD/SPECS" - purge_dir "$ROOT_BUILD/SRPMS" - remove_dir "$ROOT_REPOS/repodata" - postcmd $? -} - -# Main -if [ -n "$1" ] && [[ "'$1'" != *"--"* ]]; then - MODULES_REPO_URL="$VIRTUALMIN_ORG_AUTH_URL" - build_module "$@" - cloud_upload_list_upload=("$ROOT_REPOS/*$1*") - cloud_upload cloud_upload_list_upload - cloud_repo_sign_and_update -else - # Error otherwise - echo "Error: No module specified" - exit 1 -fi diff --git a/.github/build/build-rpm-package.bash b/.github/build/build-rpm-package.bash deleted file mode 100755 index 6a43db991..000000000 --- a/.github/build/build-rpm-package.bash +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC2034 -# build-rpm-package.bash -# Copyright Ilia Ross -# -# Automatically builds RPM packages of Webmin and Usermin with the latest -# Authentic Theme, pulls changes from GitHub, creates testing builds from the -# latest code with English-only support, production builds from the latest tag, -# uploads them to the pre-configured repository, updates the repository -# metadata, and interacts with the environment using bootstrap -# -# Usage: -# -# Pull and build production versions of both Webmin and Usermin -# ./build-rpm-package.bash -# -# Pull and build testing versions of both Webmin and Usermin -# ./build-rpm-package.bash --testing -# -# Pull and build production Webmin version 2.101, forcing -# release version 3, displaying verbose output -# ./build-rpm-package.bash webmin 2.101 3 --testing -# -# Pull and build production Usermin version 2.000, -# automatically setting release version -# ./build-rpm-package.bash usermin 2.000 -# - -# shellcheck disable=SC1091 -# Bootstrap build environment -source ./bootstrap.bash || exit 1 - -# Build product func -build_prod() { - - # Pack with English only in devel builds - local english_only=0 - if [[ "'$*'" == *"--testing"* ]]; then - english_only=1 - fi - - # Always return back to root directory - cd "$ROOT_DIR" || exit 1 - - # Define root - local ver="" - local prod=$1 - local devel=0 - local root_prod="$ROOT_DIR/$prod" - - # Print build actual date - date=$(get_current_date) - - # Print opening header - echo "************************************************************************" - echo " build start date: $date " - echo " package format: RPM " - echo " product: $prod " - echo -n " downloading packages: " - - # Download products from repos - make_packages_repos "$root_prod" "$prod" - local rs=$? # Store to print success or failure nicely later - if [ $rs -eq 0 ]; then - echo -e "✔" - else - echo -e "✘" - fi - - # Print package version - echo -n " package version: " - - # Switch to product directory explicitly - cd "$root_prod" || exit 1 - - # Get latest product version (theme vs product) - date_version=$(get_latest_commit_date_version "$root_prod") - - # Handle other params - if [[ "'$2'" != *"--"* ]]; then - ver=$2 - fi - if [[ "'$3'" != *"--"* ]] && [[ -n "$3" ]]; then - rel=$3 - else - rel=1 - fi - if [ -z "$ver" ]; then - ver=$(get_current_repo_tag "$root_prod") - fi - if [[ "'$*'" == *"--testing"* ]]; then - devel=1 - ver="$ver.$date_version" - # Set actual product version - echo "${ver}" >"version" - fi - - printf "%s-%s\n" "$ver" "$rel" - echo "************************************************************************" - - echo "Pulling latest changes.." - # We need to pull first to get the latest tag, - # so here we only report an error if any - postcmd $rs - echo - - echo "Pre-clean up .." - # Make sure directories exist - make_dir "$root_prod/newkey/rpm/" - make_dir "$root_prod/umodules/" - make_dir "$root_prod/minimal/" - make_dir "$root_prod/tarballs/" - make_dir "$ROOT_BUILD/BUILD/" - make_dir "$ROOT_BUILD/BUILDROOT/" - make_dir "$ROOT_BUILD/RPMS/" - make_dir "$ROOT_BUILD/SOURCES/" - make_dir "$ROOT_BUILD/SPECS/" - make_dir "$ROOT_BUILD/SRPMS/" - make_dir "$ROOT_REPOS/" - - # Re-create legacy link - remove_dir "$ROOT_DIR/webadmin" - ln -s "$ROOT_DIR/webmin" "$ROOT_DIR/webadmin" - - # Purge old files - purge_dir "$root_prod/newkey/rpm" - purge_dir "$root_prod/umodules" - purge_dir "$root_prod/minimal" - purge_dir "$root_prod/tarballs" - purge_dir "$ROOT_BUILD/BUILD" - purge_dir "$ROOT_BUILD/BUILDROOT" - purge_dir "$ROOT_BUILD/RPMS" - purge_dir "$ROOT_BUILD/SOURCES" - purge_dir "$ROOT_BUILD/SPECS" - purge_dir "$ROOT_BUILD/SRPMS" - remove_dir "$ROOT_REPOS/repodata" - if [ "$prod" != "" ]; then - rm -f "$ROOT_REPOS/$prod-"* - rm -f "$ROOT_REPOS/${prod}_"* - fi - postcmd $? - make_dir "$ROOT_BUILD/RPMS/noarch" - echo - - # Descend to project dir - cd "$root_prod" || exit 1 - - if [ "$english_only" = "1" ]; then - echo "Cleaning languages .." - cmd="./bin/language-manager --mode=clean --yes \ - $VERBOSITY_LEVEL_WITH_INPUT" - eval "$cmd" - postcmd $? - echo - else - # Force restore build directory - if [ ! -f "lang/ja" ]; then - echo "Restoring languages .." - cmd="git checkout \"*\" $VERBOSITY_LEVEL && git clean -f -d \ - $VERBOSITY_LEVEL && git pull $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? - echo - fi - fi - echo "Pre-building package .." - eval "$cmd" - if [ "$rel" = "1" ]; then - args="$ver" - else - args="$ver-$rel" - fi - - cmd="./makedist.pl \"$args\" $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? - echo - - echo "Building package .." - cmd="./makerpm.pl \"$ver\" \"$rel\" $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? - echo - - cd "$ROOT_DIR" || exit 1 - echo "Preparing built files for upload .." - cmd="cp -f $root_prod/tarballs/$prod-$ver*\.tar.gz \ - $ROOT_REPOS/${prod}-$ver.tar.gz $VERBOSITY_LEVEL" - eval "$cmd" - cmd="find $ROOT_RPMS -name $prod-$ver-$rel*\.rpm -exec mv '{}' \ - $ROOT_REPOS \; $VERBOSITY_LEVEL" - eval "$cmd" - # cmd="mv -f $ROOT_REPOS/$prod-$ver-$rel*\.rpm \ - # $ROOT_REPOS/${prod}-$ver-$rel.noarch.rpm $VERBOSITY_LEVEL" # file name is already always the same - # eval "$cmd" - postcmd $? - echo - - echo "Post-clean up .." - cd "$ROOT_BUILD" || exit 1 - for dir in *; do - cmd="rm -rf \"$dir/*\" $VERBOSITY_LEVEL" - eval "$cmd" - done - postcmd $? -} - -# Main -if [ -n "$1" ] && [[ "$1" != --* ]]; then - build_prod "$@" - cloud_upload_list_upload=("$ROOT_REPOS/$1*") -else - build_prod webmin "$@" - build_prod usermin "$@" - cloud_upload_list_upload=("$ROOT_REPOS/"*) -fi - -cloud_upload cloud_upload_list_upload -cloud_repo_sign_and_update diff --git a/.github/build/environment.bash b/.github/build/environment.bash deleted file mode 100755 index 7020d3bae..000000000 --- a/.github/build/environment.bash +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC2034 -# environment.bash -# Copyright Ilia Ross -# Configures environment variables for the build process - -# Builder email -BUILDER_PACKAGE_EMAIL="${ENV_BUILD__BUILDER_EMAIL:-ilia@webmin.dev}" -BUILDER_MODULE_EMAIL="${ENV_BUILD__BUILDER_EMAIL:-ilia@virtualmin.dev}" - -# Set defaults -ROOT_DIR="${ENV_BUILD__ROOT:-$HOME}" -ROOT_REPOS="${ENV_BUILD__ROOT_REPOS:-$ROOT_DIR/repo}" -ROOT_BUILD="${ENV_BUILD__ROOT_BUILD:-$ROOT_DIR/rpmbuild}" -ROOT_RPMS="${ENV_BUILD__ROOT_RPMS:-$ROOT_BUILD/RPMS/noarch}" - -# Create symlinks for Perl -PERL_SOURCE="/usr/bin/perl" -PERL_TARGET="/usr/local/bin/perl" -ln -fs "$PERL_SOURCE" "$PERL_TARGET" - -# GitHub private repos access token -GITHUB_TOKEN="${ENV_BUILD__GITHUB_TOKEN}" - -# Cloud upload config -CLOUD_UPLOAD_SSH_USER="${ENV_BUILD__CLOUD_UPLOAD_SSH_USER:-webmin.dev}" -CLOUD_UPLOAD_SSH_HOST="${ENV_BUILD__CLOUD_UPLOAD_SSH_HOST:-webmin.dev}" -CLOUD_UPLOAD_SSH_DIR="${ENV_BUILD__CLOUD_UPLOAD_SSH_DIR:-~/domains/download.webmin.dev/public_html}" -CLOUD_UPLOAD_GPG_PASSPHRASE="${WEBMIN_DEV__GPG_PH}" - -# Define verbosity level -VERBOSITY_LEVEL=' >/dev/null 2>&1 -# Build functions for the build process - -# Set up SSH keys on the build machine -setup_ssh() { - local key_path="$HOME/.ssh/id_rsa" - - # If SSH keys are already set up, skip this step - if [ -f "$key_path" ] && [ -f "$key_path.pub" ]; then - return 0 - fi - - # Use SSH command to generate new pair and take care of permissions - cmd="ssh-keygen -t rsa -q -f \"$key_path\" \ - -N \"\" <<< \"y\"$VERBOSITY_LEVEL" - eval "$cmd" - rs=$? - - if [[ -n "${WEBMIN_DEV__SSH_PRV_KEY:-}" ]] && - [[ -n "${WEBMIN_DEV__SSH_PUB_KEY:-}" ]]; then - echo "Setting up development SSH keys .." - postcmd $rs - echo - - # Import SSH keys from secrets to be able to connect to the remote host - echo "$WEBMIN_DEV__SSH_PRV_KEY" > "$key_path" - echo "$WEBMIN_DEV__SSH_PUB_KEY" > "$key_path.pub" - return 0 - elif [[ -n "${WEBMIN_PROD__SSH_PRV_KEY:-}" ]] && - [[ -n "${WEBMIN_PROD__SSH_PUB_KEY:-}" ]]; then - echo "Setting up production SSH keys .." - postcmd $rs - echo - - # Import SSH keys from secrets to be able to connect to the remote host - echo "$WEBMIN_PROD__SSH_PRV_KEY" > "$key_path" - echo "$WEBMIN_PROD__SSH_PUB_KEY" > "$key_path.pub" - return 0 - fi -} - -# Upload to cloud -# Usage: -# cloud_upload_list_delete=("$CLOUD_UPLOAD_SSH_DIR/repodata") -# cloud_upload_list_upload=("$ROOT_REPOS/*" "$ROOT_REPOS/repodata") -# cloud_upload cloud_upload_list_upload cloud_upload_list_delete -cloud_upload() { - # Print new block only if defined - local ssh_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" - if [ -n "$1" ]; then - echo - fi - - # Setup SSH keys on the build machine - setup_ssh - - # Delete files on remote if needed - if [ -n "$2" ]; then - echo "Deleting given files in $CLOUD_UPLOAD_SSH_HOST .." - local -n arr_del=$2 - local err=0 - for d in "${arr_del[@]}"; do - if [ -n "$d" ]; then - local cmd1="ssh $ssh_args $CLOUD_UPLOAD_SSH_USER@" - cmd1+="$CLOUD_UPLOAD_SSH_HOST \"rm -rf $d\" $VERBOSITY_LEVEL" - eval "$cmd1" - # shellcheck disable=SC2181 - if [ "$?" != "0" ]; then - err=1 - fi - fi - done - postcmd $err - echo - fi - - # Upload files to remote - if [ -n "$1" ]; then - echo "Uploading built files to $CLOUD_UPLOAD_SSH_HOST .." - local -n arr_upl=$1 - local err=0 - for u in "${arr_upl[@]}"; do - if [ -n "$u" ]; then - local cmd2="scp $ssh_args -r $u $CLOUD_UPLOAD_SSH_USER@" - cmd2+="$CLOUD_UPLOAD_SSH_HOST:$CLOUD_UPLOAD_SSH_DIR/ $VERBOSITY_LEVEL" - eval "$cmd2" - # shellcheck disable=SC2181 - if [ "$?" != "0" ]; then - err=1 - fi - fi - done - postcmd $err - echo - fi -} - -# Sign and update repos metadata in remote -cloud_repo_sign_and_update() { - # Setup SSH keys on the build machine - setup_ssh - # Sign and update repos metadata in remote - echo "Signing and updating repos metadata in $CLOUD_UPLOAD_SSH_HOST .." - local ssh_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" - local remote_cmd="cd ~/.scripts && ./update-repo-packages-signature.bash \ - $CLOUD_UPLOAD_GPG_PASSPHRASE" - local cmd1="ssh $ssh_args $CLOUD_UPLOAD_SSH_USER@" - cmd1+="$CLOUD_UPLOAD_SSH_HOST \"$remote_cmd\" $VERBOSITY_LEVEL" - eval "$cmd1" - postcmd $? - echo -} - -# Post command func -postcmd() { - if [ "$1" != "0" ]; then - echo ".. failed" - exit 1 - else - echo ".. done" - fi -} - -# Get max number from array -max() { - local max="$1" - shift - for value in "$@"; do - if [[ "$value" -gt "$max" ]]; then - max="$value" - fi - done - echo "$max" -} - -# Mkdir and children dirs -make_dir() { - if [ ! -d "$1" ]; then - mkdir -p "$1" - fi -} - -# Remove all content in dir -purge_dir() { - for file in "$1"/*; do - rm -rf "$file" - done -} - -# Remove dir -remove_dir() { - if [ -d "$1" ]; then - rm -rf "$1" - fi -} - -# Get latest tag version -get_current_repo_tag() { - # shellcheck disable=SC2153 - local root_prod="$1" - ( - cd "$root_prod" || exit 1 - ds=$(git ls-remote --tags --refs --sort="v:refname" origin | tail -n1 | \ - awk '{print $2}' | sed 's|refs/tags/||') - ds="${ds/v/}" - echo "$ds" - ) -} - -get_module_version() { - local module_root="$1" - local version="" - - # Check if module.info exists and extract version - if [ -f "module.info" ]; then - version=$(grep -E '^version=[0-9]+(\.[0-9]+)*' module.info | \ - head -n 1 | cut -d'=' -f2) - version=$(echo "$version" | sed -E 's/^([0-9]+\.[0-9]+(\.[0-9]+)?).*/\1/') - fi - - # Fallback to get_current_repo_tag if no version found - if [ -z "$version" ]; then - version=$(get_current_repo_tag "$module_root") - fi - - # Return version (assumes version is always found) - echo "$version" -} - -# Get latest commit date -get_current_date() { - date +'%Y-%m-%d %H:%M:%S %z' -} - -# Get latest commit date version -get_latest_commit_date_version() { - local theme_version - local prod_version - local max_prod - local highest_version - local root_prod="$1" - local root_theme="$root_prod/authentic-theme" - ( - cd "$root_theme" || exit 1 - theme_version=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d%H%M') - cd "$root_prod" || exit 1 - prod_version=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d%H%M') - max_prod=("$theme_version" "$prod_version") - highest_version=$(max "${max_prod[@]}") - echo "$highest_version" - ) -} - -# Pull project repo and theme -make_packages_repos() { - local root_prod="$1" - local prod="$2" - local cmd - local reqrepo="webmin" - local repo="$reqrepo/$prod.git" - local theme="authentic-theme" - - # Clone repo - if [ ! -d "$root_prod" ]; then - cmd="git clone --depth 1 $GIT_BASE_URL/$repo $VERBOSITY_LEVEL" - eval "$cmd" - if [ "$?" != "0" ]; then - return 1 - fi - fi - - # Clone required repo - if [ ! -d "$reqrepo" ]; then - cmd="git clone --depth 1 $WEBMIN_REPO $VERBOSITY_LEVEL" - eval "$cmd" - if [ "$?" != "0" ]; then - return 1 - fi - fi - - # Clone theme - if [ ! -d "$root_prod/$theme" ]; then - cd "$root_prod" || exit 1 - repo="$reqrepo/$theme.git" - cmd="git clone --depth 1 $GIT_BASE_URL/$repo $VERBOSITY_LEVEL" - eval "$cmd" - if [ "$?" != "0" ]; then - return 1 - fi - fi -return 0 -} - -# Make module repo -make_module_repo_cmd() { - local module="$1" - local target="$2" - printf "git clone --depth 1 $target/%s.git %s" \ - "$module" "$VERBOSITY_LEVEL" -} - -# Get last commit date from repo -get_last_commit_date() { - local repo_dir="$1" - ( - cd "$repo_dir" || return 1 - git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d%H%M' - ) -} - -# Get required build scripts from Webmin repo -make_module_build_deps() { - # Create directory for build dependencies if it doesn't exist - if [ ! -d "$ROOT_DIR/build-deps" ]; then - mkdir -p "$ROOT_DIR/build-deps" - fi - - # Download required scripts from Webmin repo if they don't exist - if [ ! -f "$ROOT_DIR/build-deps/makemoduledeb.pl" ] || \ - [ ! -f "$ROOT_DIR/build-deps/makemodulerpm.pl" ] || \ - [ ! -f "$ROOT_DIR/build-deps/create-module.pl" ]; then - echo "Downloading build dependencies .." - - # Create temporary directory - local temp_dir - temp_dir=$(mktemp -d) - cd "$temp_dir" || exit 1 - - # Clone Webmin repository (minimal depth) - cmd="git clone --depth 1 --filter=blob:none --sparse \ - $WEBMIN_REPO.git $VERBOSITY_LEVEL" - eval "$cmd" - postcmd $? - echo - - cd webmin || exit 1 - - # Copy required files to build-deps directory - cp makemoduledeb.pl makemodulerpm.pl create-module.pl \ - "$ROOT_DIR/build-deps/" - - # Make scripts executable - chmod +x "$ROOT_DIR/build-deps/"*.pl - - # Clean up - cd "$ROOT_DIR" || exit 1 - remove_dir "$temp_dir" - fi -} - -# Adjust module filename depending on package type -adjust_module_filename() { - local repo_dir="$1" - local package_type="$2" - local failed=0 - local temp_file - - # Create a secure temporary file - temp_file=$(mktemp) || { echo "Failed to create temporary file"; return 1; } - - # Find and adjust files based on the package type - case "$package_type" in - rpm) - find "$repo_dir" -type f -name "*.rpm" > "$temp_file" - ;; - deb) - find "$repo_dir" -type f -name "*.deb" > "$temp_file" - ;; - esac - - while read -r file; do - base_name=$(basename "$file") - dir_name=$(dirname "$file") - local new_name - - case "$package_type" in - rpm) - # Handle RPM logic - if [[ "$base_name" == webmin-* ]]; then - new_name="${base_name/webmin-/wbm-}" - elif [[ "$base_name" != wbm-* ]]; then - new_name="wbm-$base_name" - else - continue - fi - ;; - deb) - # Handle DEB logic - if [[ "$base_name" != webmin-* ]]; then - new_name="webmin-$base_name" - else - continue - fi - ;; - esac - - # Perform rename and check for failure - if ! eval "mv \"$file\" \"$dir_name/$new_name\" \ - $VERBOSITY_LEVEL_WITH_INPUT"; then - failed=1 - fi - done < "$temp_file" - - # Clean up the temporary file - rm -f "$temp_file" - - # Return success or failure - return $failed -} - diff --git a/.github/workflows/webmin.dev:webmin.yml b/.github/workflows/webmin.dev:webmin.yml index cf6a445cb..cf5a88180 100644 --- a/.github/workflows/webmin.dev:webmin.yml +++ b/.github/workflows/webmin.dev:webmin.yml @@ -18,13 +18,16 @@ jobs: - uses: szenius/set-timezone@v1.2 with: timezoneLinux: "Europe/Nicosia" + - name: Fetch dependencies + run: |- + curl -O https://raw.githubusercontent.com/webmin/webmin-ci-cd/main/build/bootstrap.bash - name: Build and upload packages env: WEBMIN_DEV__SSH_PRV_KEY: ${{ secrets.WEBMIN_DEV__SSH_PRV_KEY }} WEBMIN_DEV__SSH_PUB_KEY: ${{ secrets.WEBMIN_DEV__SSH_PUB_KEY }} WEBMIN_DEV__GPG_PH: ${{ secrets.WEBMIN_DEV__GPG_PH }} ENV_BUILD__CLOUD_UPLOAD_SSH_HOST: ${{ secrets.WEBMIN_DEV__IP_ADDR }} - working-directory: ./.github/build run: |- - ./build-deb-package.bash webmin --testing - ./build-rpm-package.bash webmin --testing + bash bootstrap.bash + bash build-deb-package.bash webmin --testing + bash build-rpm-package.bash webmin --testing