From ffd0b39daf663c630b05e01303e4558f3eb6e727 Mon Sep 17 00:00:00 2001 From: Khosrow Moossavi Date: Sat, 14 Dec 2024 17:33:59 -0500 Subject: [PATCH] feat: refactor build scripts to publish to new server --- .github/scripts/ext-arch.sh | 10 +- .github/scripts/ext-debian.sh | 213 +++++++----- .github/scripts/ext-git.sh | 19 +- .github/scripts/ext-rpm.sh | 10 + .github/scripts/ext-template.sh | 10 +- .github/scripts/ext-tester.sh | 12 +- .github/scripts/main.sh | 199 +++++++++-- .github/workflows/build-arch.yml | 55 +-- .github/workflows/build-deb-v4.yml | 515 +++++++++++++++++++---------- .github/workflows/build-rpm.yml | 72 ++-- .github/workflows/test-builder.yml | 65 ++-- docs/testing.md | 30 +- 12 files changed, 809 insertions(+), 401 deletions(-) mode change 100644 => 100755 .github/scripts/ext-git.sh diff --git a/.github/scripts/ext-arch.sh b/.github/scripts/ext-arch.sh index 90318451..84a2a98f 100755 --- a/.github/scripts/ext-arch.sh +++ b/.github/scripts/ext-arch.sh @@ -57,9 +57,12 @@ publish() { echo "CHLOG:Published arch package of $PACKAGE_NAME in $STAGE $DISTRO $CODENAME $ARCH (dry-run)" } -# Create repo dist file - for new repository -generate_reprepro_dist() { - echo "function called: ${FUNCNAME[0]}" +archive_setup_scripts() { + echo "function called: ${FUNCNAME[0]}" +} + +archive_cleanup_scripts() { + echo "function called: ${FUNCNAME[0]}" } # Setup repo layout @@ -67,4 +70,5 @@ setup() { echo "function called: ${FUNCNAME[0]}" source_setup_scripts + archive_setup_scripts } diff --git a/.github/scripts/ext-debian.sh b/.github/scripts/ext-debian.sh index 1f94d3a9..25333d69 100755 --- a/.github/scripts/ext-debian.sh +++ b/.github/scripts/ext-debian.sh @@ -9,7 +9,7 @@ set -o errexit # Update the changelog to specify the target distribution codename update_changelog() { set -x - cd "${PKG_BUILD_DIR:?}/$PACKAGE_NAME" + cd "${PKG_BUILD_PATH:?}/$PACKAGE_NAME" version=$(dpkg-parsechangelog --show-field Version) dch --force-distribution --distribution "$CODENAME" --newversion "${version}-1regolith-$CODENAME" "Automated Voulage release" @@ -18,12 +18,13 @@ update_changelog() { # Determine if the changelog has the correct distribution codename dist_valid() { - cd "${PKG_BUILD_DIR:?}/$PACKAGE_NAME" + cd "${PKG_BUILD_PATH:?}/$PACKAGE_NAME" TOP_CHANGELOG_LINE=$(head -n 1 debian/changelog) CHANGELOG_DIST=$(echo "$TOP_CHANGELOG_LINE" | cut -d' ' -f3) cd - >/dev/null 2>&1 + # echo "Checking $CODENAME and $CHANGELOG_DIST" if [[ "$CHANGELOG_DIST" == *"$CODENAME"* ]]; then return 0 @@ -36,14 +37,42 @@ stage_source() { pushd . echo "Preparing source for $PACKAGE_NAME" - cd "$PKG_BUILD_DIR/$PACKAGE_NAME" || exit + cd "$PKG_BUILD_PATH/$PACKAGE_NAME" || exit debian_package_name=$(dpkg-parsechangelog --show-field Source) full_version=$(dpkg-parsechangelog --show-field Version) debian_version="${full_version%-*}" - cd "$PKG_BUILD_DIR" || exit + cd "$PKG_BUILD_PATH" || exit echo "Generating source tarball from git repo." - tar --force-local -c -z -v -f "${debian_package_name}_${debian_version}.orig.tar.gz" --exclude .git\* --exclude /debian "$PACKAGE_NAME" + tar --force-local -c -z -v -f "${debian_package_name}_${debian_version}.orig.tar.gz" --exclude .git\* --exclude debian "$PACKAGE_NAME" + + if [ "$LOCAL_BUILD" == "false" ]; then + debian_package_name_indicator="${debian_package_name:0:1}" + if [ "${debian_package_name:0:3}" == "lib" ]; then + debian_package_name_indicator="${debian_package_name:0:4}" + fi + + # try to download the .orig.tar.gz from existing archive, and check if they are identical or not + wget -O "${debian_package_name}_${debian_version}-existing.orig.tar.gz" "http://archive.regolith-desktop.com/$DISTRO/$SUITE/pool/main/${debian_package_name_indicator}/${debian_package_name}/${debian_package_name}_${debian_version}.orig.tar.gz" || true + + if [ -s "${debian_package_name}_${debian_version}-existing.orig.tar.gz" ]; then + if ! diff <(tar -tvzf "${debian_package_name}_${debian_version}.orig.tar.gz" | awk '{printf "%10s %s\n",$3,$6}' | sort -k 2 | sed 's|\./||') <(tar -tvzf "${debian_package_name}_${debian_version}-existing.orig.tar.gz" | awk '{printf "%10s %s\n",$3,$6}' | sort -k 2 | sed 's|\./||') ; then + # existing .orig.tar.gz file is different that the one we just built + # keep the one we just built and override push it to the repository. + rm -f "${debian_package_name}_${debian_version}-existing.orig.tar.gz" || true + + echo "SRCLOG:$DISTRO=$CODENAME=$SUITE=${debian_package_name:0:1}=${debian_package_name}=${debian_package_name}_${debian_version}=${debian_package_name}_${debian_version}.orig.tar.gz" + else + # both .orig.tar.gz files are identical! + # remove the one we just built and reuse the existign one. + rm -f "${debian_package_name}_${debian_version}.orig.tar.gz" || true + mv "${debian_package_name}_${debian_version}-existing.orig.tar.gz" "${debian_package_name}_${debian_version}.orig.tar.gz" + fi + else + # there's no existing .orig.tar.gz file! Clean up the empty downloaded file. + rm -f "${debian_package_name}_${debian_version}-existing.orig.tar.gz" || true + fi + fi popd } @@ -53,10 +82,11 @@ build_src_package() { pushd . echo "Building source package $PACKAGE_NAME" - cd "$PKG_BUILD_DIR/$PACKAGE_NAME" || exit + cd "$PKG_BUILD_PATH/$PACKAGE_NAME" || exit sanitize_git - sudo apt update + + sudo apt update sudo apt build-dep -y . debuild -S -sa @@ -68,108 +98,123 @@ build_bin_package() { pushd . echo "Building binary package $PACKAGE_NAME" - cd "$PKG_BUILD_DIR/$PACKAGE_NAME" || exit + cd "$PKG_BUILD_PATH/$PACKAGE_NAME" || exit debuild -sa -b popd } -# Internal (private) function -source_pkg_exists() { - SRC_PKG_VERSION=$(reprepro --basedir "$PKG_REPO_PATH" list "$CODENAME" "$1" | cut -d' ' -f3) - - SRC_PKG_BUILD_VERSION=$(echo $2 | cut -d'-' -f1) - SRC_PKG_REPO_VERSION=$(echo $SRC_PKG_VERSION | cut -d'-' -f1) - - if [ "$SRC_PKG_REPO_VERSION" == "$SRC_PKG_BUILD_VERSION" ]; then - return 0 - else - return 1 - fi -} - publish() { - cd "${PKG_BUILD_DIR:?}/$PACKAGE_NAME" + cd "${PKG_BUILD_PATH:?}/$PACKAGE_NAME" version=$(dpkg-parsechangelog --show-field Version) debian_package_name=$(dpkg-parsechangelog --show-field Source) - cd "$PKG_BUILD_DIR" + cd "$PKG_BUILD_PATH" - DEB_SRC_PKG_PATH="$PKG_BUILD_DIR/${debian_package_name}_${version}_source.changes" + DEB_SRC_PKG_PATH="$(pwd)/${debian_package_name}_${version}_source.changes" if [ ! -f "$DEB_SRC_PKG_PATH" ]; then echo "Failed to find changes file." - fi - - if source_pkg_exists "$debian_package_name" "$version"; then - echo "Ignoring source package, already exists in target repository" - allow_failing_bin_package="true" else - echo "Ingesting source package $debian_package_name into $PKG_REPO_PATH" - reprepro --basedir "$PKG_REPO_PATH" include "$CODENAME" "$DEB_SRC_PKG_PATH" - allow_failing_bin_package="false" + short_version="${version%-*}" + + mkdir -p $PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$SUITE + + cp "$(pwd)/${debian_package_name}_${version}.dsc" "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$SUITE" + cp "$(pwd)/${debian_package_name}_${short_version}.orig.tar.gz" "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$SUITE" + + if [ -f "$(pwd)/${debian_package_name}_${version}.debian.tar.xz" ]; then + cp "$(pwd)/${debian_package_name}_${version}.debian.tar.xz" "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$SUITE" + fi + if [ -f "$(pwd)/${debian_package_name}_${version}.diff.gz" ]; then + cp "$(pwd)/${debian_package_name}_${version}.diff.gz" "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$SUITE" + fi + + if [ "$LOCAL_BUILD" == "false" ] && [ "$SUITE" == "stable" ]; then + mkdir -p "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$COMPONENT" + cd "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$COMPONENT" >/dev/null 2>&1 + + ln "../$SUITE/${debian_package_name}_${version}.dsc" . + ln "../$SUITE/${debian_package_name}_${short_version}.orig.tar.gz" . + + if [ -f "../$SUITE/${debian_package_name}_${version}.debian.tar.xz" ]; then + ln "../$SUITE/${debian_package_name}_${version}.debian.tar.xz" . + fi + if [ -f "../$SUITE/${debian_package_name}_${version}.diff.gz" ]; then + ln "../$SUITE/${debian_package_name}_${version}.diff.gz" . + fi + + cd - >/dev/null 2>&1 + fi + + echo "Publishing source package $debian_package_name into $PKG_PUBLISH_PATH" fi - DEB_CONTROL_FILE="$PKG_BUILD_DIR/$PACKAGE_NAME/debian/control" + DEB_CONTROL_FILE="$PKG_BUILD_PATH/$PACKAGE_NAME/debian/control" ALL_ARCH="$ARCH,all" for target_arch in $(echo $ALL_ARCH | sed "s/,/ /g"); do - cat "$DEB_CONTROL_FILE" | grep ^Package: | cut -d' ' -f2 | while read -r bin_pkg; do - DEB_BIN_PKG_PATH="$(pwd)/${bin_pkg}_${version}_${target_arch}.deb" - if [ -f "$DEB_BIN_PKG_PATH" ]; then - if [ "$allow_failing_bin_package" == "true" ]; then - # If the source package/version already exists, allow the bin package build to fail (already exists) - reprepro --basedir "$PKG_REPO_PATH" includedeb "$CODENAME" "$DEB_BIN_PKG_PATH" || true - echo "Ingested binary package $DEB_BIN_PKG_PATH into $PKG_REPO_PATH" - else - reprepro --basedir "$PKG_REPO_PATH" includedeb "$CODENAME" "$DEB_BIN_PKG_PATH" - echo "Ingested binary package $DEB_BIN_PKG_PATH into $PKG_REPO_PATH" - fi - echo "CHLOG:Published ${bin_pkg}_${version}_${target_arch}.deb in $STAGE $DISTRO $CODENAME $ARCH from $PKG_LINE" - else - echo "Package $bin_pkg does not exist for $target_arch" - fi - done + cat "$DEB_CONTROL_FILE" | grep ^Package: | cut -d' ' -f2 | while read -r bin_pkg; do + DEB_BIN_PKG_PATH="$(pwd)/${bin_pkg}_${version}_${target_arch}.deb" + + if [ -f "$DEB_BIN_PKG_PATH" ]; then + mkdir -p $PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$SUITE + cp "$DEB_BIN_PKG_PATH" "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$SUITE" + + if [ "$LOCAL_BUILD" == "false" ] && [ "$SUITE" == "stable" ]; then + mkdir -p "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$COMPONENT" + cd "$PKG_PUBLISH_PATH/$DISTRO/$CODENAME/$COMPONENT" >/dev/null 2>&1 + ln "../$SUITE/${bin_pkg}_${version}_${target_arch}.deb" . + cd - >/dev/null 2>&1 + fi + + echo "Publishing deb package(s) $bin_pkg into $PKG_PUBLISH_PATH" + echo "CHLOG:Published ${bin_pkg}_${version}_${target_arch}.deb in $DISTRO/$CODENAME/$STAGE from $PKG_LINE" + else + echo "Package $bin_pkg does not exist for $target_arch" + fi + done done +} + +archive_setup_scripts() { + # Following allows for internal dependencies + rm /tmp/Release || true + wget -P /tmp "http://archive.regolith-desktop.com/$DISTRO/$SUITE/dists/$CODENAME/Release" || true + + if [ -f /tmp/Release ]; then + rm /tmp/Release - # Preliminary launchpad.net integration. Ideally gated from action rather than distro/stage - # Only packages for Ubuntu distro should go to launchpad - # Arch is set to amd64 because launchpad handles cross arch builds internally - # Remove STAGE check once testing and release PPAs are ready - # if [[ "$DISTRO" == "ubuntu" && "$ARCH" == "amd64" && "$STAGE" == "unstable" ]]; then - # LAUNCHPAD_REPO="ppa:regolith-desktop/$CODENAME-$STAGE" - # - # dput -f $LAUNCHPAD_REPO $DEB_SRC_PKG_PATH || true - # - # echo "CHLOG: Published $PACKAGE_NAME to $LAUNCHPAD_REPO" - # fi + local repo_line="" + if [ "$LOCAL_BUILD" == "false" ] && [ "$SUITE" == "stable" ]; then + # fixed version component + repo_line="http://archive.regolith-desktop.com/$DISTRO/$SUITE $CODENAME v$COMPONENT" + else + # main component + repo_line="http://archive.regolith-desktop.com/$DISTRO/$SUITE $CODENAME $COMPONENT" + fi + + echo "Adding repo to apt: $repo_line" + wget -qO - http://archive.regolith-desktop.com/regolith.key | sudo apt-key add - + echo "deb [arch=$ARCH] $repo_line" | sudo tee /etc/apt/sources.list.d/regolith.list + + sudo apt update + fi + + if [ -f "/etc/apt/sources.list.d/regolith-local.list" ]; then + sudo rm /etc/apt/sources.list.d/regolith-local.list + echo "Cleaned up temp apt repo" + fi } -# Create repo dist file -generate_reprepro_dist() { - echo "Origin: $PACKAGE_REPO_URL" > "$PKG_REPO_PATH/conf/distributions" - echo "Label: $PACKAGE_REPO_URL" >> "$PKG_REPO_PATH/conf/distributions" - echo "Codename: $CODENAME" >> "$PKG_REPO_PATH/conf/distributions" - echo "Architectures: $ARCH source" >> "$PKG_REPO_PATH/conf/distributions" - echo "Components: main" >> "$PKG_REPO_PATH/conf/distributions" - echo "Description: $STAGE $DISTRO $CODENAME $ARCH" >> "$PKG_REPO_PATH/conf/distributions" - echo "SignWith: $APT_KEY" >> "$PKG_REPO_PATH/conf/distributions" +archive_cleanup_scripts() { + # Remove regolith repo from build system apt config + if [ -f /etc/apt/sources.list.d/regolith.list ]; then + sudo rm -f /etc/apt/sources.list.d/regolith.list + fi } # Setup debian repo setup() { - if [ ! -d "$PKG_REPO_PATH/conf" ]; then - echo "Creating conf dir" - mkdir -p "$PKG_REPO_PATH/conf" - fi - - if [ ! -f "$PKG_REPO_PATH/conf/distributions" ]; then - echo "Package metadata not found, creating conf dir" - generate_reprepro_dist - cat "$PKG_REPO_PATH/conf/distributions" - else - echo "Existing metadata:" - cat "$PKG_REPO_PATH/conf/distributions" - fi - source_setup_scripts + archive_setup_scripts } diff --git a/.github/scripts/ext-git.sh b/.github/scripts/ext-git.sh old mode 100644 new mode 100755 index 5865a472..ecda993c --- a/.github/scripts/ext-git.sh +++ b/.github/scripts/ext-git.sh @@ -4,24 +4,25 @@ checkout() { set -e if [ -z "$PACKAGE_URL" ]; then - echo "Package model is invalid. Model field 'source' undefined, aborting." + echo "Error: package model is invalid. Model field 'source' undefined, aborting." exit 1 fi - if [ -d "$PKG_BUILD_DIR/$PACKAGE_NAME" ]; then + if [ -d "$PKG_BUILD_PATH/$PACKAGE_NAME" ]; then echo "Deleting existing repo, $PACKAGE_NAME" - rm -Rfv "${PKG_BUILD_DIR:?}/$PACKAGE_NAME" + rm -Rfv "${PKG_BUILD_PATH:?}/$PACKAGE_NAME" fi - if [ ! -d "$PKG_BUILD_DIR" ]; then - echo "Creating build directory $PKG_BUILD_DIR" - mkdir -p "$PKG_BUILD_DIR" || { - echo "Failed to create build dir $PKG_BUILD_DIR, aborting." + if [ ! -d "$PKG_BUILD_PATH" ]; then + echo "Creating build directory $PKG_BUILD_PATH" + + mkdir -p "$PKG_BUILD_PATH" || { + echo "Error: failed to create build dir $PKG_BUILD_PATH, aborting." exit 1 } fi - cd "$PKG_BUILD_DIR" || exit + cd "$PKG_BUILD_PATH" || exit git clone --recursive "$PACKAGE_URL" -b "$PACKAGE_REF" "$PACKAGE_NAME" cd - >/dev/null 2>&1 || exit @@ -36,4 +37,4 @@ sanitize_git() { rm -Rf .git echo "Removed $(pwd).git directory before building to appease debuild." fi -} \ No newline at end of file +} diff --git a/.github/scripts/ext-rpm.sh b/.github/scripts/ext-rpm.sh index e03a5ff5..fafe0360 100755 --- a/.github/scripts/ext-rpm.sh +++ b/.github/scripts/ext-rpm.sh @@ -41,6 +41,16 @@ publish() { : } +archive_setup_scripts() { + # Setting up local archive repo for internal dependencies + : +} + +archive_cleanup_scripts() { + # Cleaning up local archive repo definition + : +} + # Setup debian repo setup() { : diff --git a/.github/scripts/ext-template.sh b/.github/scripts/ext-template.sh index 890d1ee5..d77939d4 100755 --- a/.github/scripts/ext-template.sh +++ b/.github/scripts/ext-template.sh @@ -37,9 +37,12 @@ publish() { echo todo } -# Create repo dist file - for new repository -generate_reprepro_dist() { - echo todo +archive_setup_scripts() { + echo todo +} + +archive_cleanup_scripts() { + echo todo } # Setup repo layout @@ -47,4 +50,5 @@ setup() { echo todo source_setup_scripts + archive_setup_scripts } diff --git a/.github/scripts/ext-tester.sh b/.github/scripts/ext-tester.sh index 4b3484ba..9015e3ca 100755 --- a/.github/scripts/ext-tester.sh +++ b/.github/scripts/ext-tester.sh @@ -37,16 +37,18 @@ publish() { echo "Publishing $PACKAGE_NAME to repo" } -# Create repo dist file - for new repository -generate_reprepro_dist() { - echo "Generating config files for new repository" +archive_setup_scripts() { + echo "Setting up local archive repo for internal dependencies" +} + +archive_cleanup_scripts() { + echo "Cleaning up local archive repo definition" } # Setup repo layout setup() { echo "Setting up $PKG_REPO_PATH" - generate_reprepro_dist - source_setup_scripts + archive_setup_scripts } diff --git a/.github/scripts/main.sh b/.github/scripts/main.sh index 8a1167f7..00ed6041 100755 --- a/.github/scripts/main.sh +++ b/.github/scripts/main.sh @@ -46,7 +46,7 @@ merge_models() { cp "$ROOT_MODEL_PATH" "$WORKING_ROOT_MODEL" # Optionally merge stage package model - STAGE_PACKAGE_MODEL="$REPO_ROOT/stage/$STAGE/package-model.json" + STAGE_PACKAGE_MODEL="$GIT_REPO_PATH/stage/$STAGE/package-model.json" WORKING_STAGE_MODEL="$MANIFEST_PATH/$STAGE-model.json" if [ -f "$STAGE_PACKAGE_MODEL" ]; then jq -s '.[0] * .[1]' "$WORKING_ROOT_MODEL" "$STAGE_PACKAGE_MODEL" > "$WORKING_STAGE_MODEL" @@ -55,7 +55,7 @@ merge_models() { fi # Optionally merge distro package model - DISTRO_PACKAGE_MODEL="$REPO_ROOT/stage/$STAGE/$DISTRO/package-model.json" + DISTRO_PACKAGE_MODEL="$GIT_REPO_PATH/stage/$STAGE/$DISTRO/package-model.json" WORKING_DISTRO_MODEL="$MANIFEST_PATH/$STAGE-$DISTRO-model.json" if [ -f "$DISTRO_PACKAGE_MODEL" ]; then jq -s '.[0] * .[1]' "$WORKING_STAGE_MODEL" "$DISTRO_PACKAGE_MODEL" > "$WORKING_DISTRO_MODEL" @@ -64,7 +64,7 @@ merge_models() { fi # Optionally merge codename package model - CODENAME_PACKAGE_MODEL="$REPO_ROOT/stage/$STAGE/$DISTRO/$CODENAME/package-model.json" + CODENAME_PACKAGE_MODEL="$GIT_REPO_PATH/stage/$STAGE/$DISTRO/$CODENAME/package-model.json" WORKING_CODENAME_MODEL="$MANIFEST_PATH/$STAGE-$DISTRO-$CODENAME-model.json" if [ -f "$CODENAME_PACKAGE_MODEL" ]; then jq -s '.[0] * .[1]' "$WORKING_DISTRO_MODEL" "$CODENAME_PACKAGE_MODEL" > "$WORKING_CODENAME_MODEL" @@ -73,7 +73,7 @@ merge_models() { fi # Optionally merge arch package model - ARCH_PACKAGE_MODEL="$REPO_ROOT/stage/$STAGE/$DISTRO/$CODENAME/$ARCH/package-model.json" + ARCH_PACKAGE_MODEL="$GIT_REPO_PATH/stage/$STAGE/$DISTRO/$CODENAME/$ARCH/package-model.json" WORKING_ARCH_MODEL="$MANIFEST_PATH/$STAGE-$DISTRO-$CODENAME-$ARCH-model.json" if [ -f "$ARCH_PACKAGE_MODEL" ]; then jq -s '.[0] * .[1]' "$WORKING_CODENAME_MODEL" "$ARCH_PACKAGE_MODEL" > "$WORKING_ARCH_MODEL" @@ -90,11 +90,11 @@ merge_models() { # Traverse the stage tree and execute any found setup.sh scripts source_setup_scripts() { local setup_script_locations=( - "$REPO_ROOT/stage/setup.sh" - "$REPO_ROOT/stage/$STAGE/setup.sh" - "$REPO_ROOT/stage/$STAGE/$DISTRO/setup.sh" - "$REPO_ROOT/stage/$STAGE/$DISTRO/$CODENAME/setup.sh" - "$REPO_ROOT/stage/$STAGE/$DISTRO/$CODENAME/$ARCH/setup.sh" + "$GIT_REPO_PATH/stage/setup.sh" + "$GIT_REPO_PATH/stage/$STAGE/setup.sh" + "$GIT_REPO_PATH/stage/$STAGE/$DISTRO/setup.sh" + "$GIT_REPO_PATH/stage/$STAGE/$DISTRO/$CODENAME/setup.sh" + "$GIT_REPO_PATH/stage/$STAGE/$DISTRO/$CODENAME/$ARCH/setup.sh" ) for setup_file in "${setup_script_locations[@]}" @@ -135,30 +135,154 @@ build_packages() { #### Init input params -REPO_ROOT=$(realpath "$1") -EXTENSION=$2 -STAGE=$3 -DISTRO=$4 -CODENAME=$5 -ARCH=$6 -PACKAGE_REPO_URL=$7 -APT_KEY=$8 -MODE=$9 -MANIFEST_PATH=${10} -PKG_REPO_PATH=${11} -PKG_BUILD_DIR=${12} - - -GIT_EXT="$REPO_ROOT/.github/scripts/ext-git.sh" +usage() { +cat << EOF +Build debian and source packages for given combination of: distro, codename, stage and arch + +Usage: $0 [options...] COMMAND + +Commands: + build Build the requested debian and source packages + check Check the manifests if anything needs to be built + +Options: + --extension Path to extenstion file (e.g. /path/to/ext-debian.sh) + + --git-repo-path Path to repo folder (e.g. /path/to/git/repo/voulage) + --manifests-path Path to manifests folder (e.g. /path/to/manifests) + --pkg-build-path Path to folder to build packages in (e.g. /path/to/packages) + --pkg-publish-path Path to folder to publish packages in (e.g. /path/to/publish) + + --distro The distro to check or build (e.g. ubuntu, debian) + --codename The codename to check or build (e.g. jammy, noble, bookworm, etc.) + --stage The stage to check or build (e.g. experimental, unstable, testing, release-x_Y) # different release stages from github action point-of-view + --suite The suite to check or build (e.g. experimental, unstable, testing, stable) # corresponding value from published arcvhies point-of-view + --component The component to check or build (e.g. main, 3_2, 3_1, etc.) + --arch The arch to check or build (e.g. amd64, arm64) + + --help Show this message + +Note: all the options are required when using $0 +EOF +} + +parse_flag() { + declare -n argument=$3 + + if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then + argument=$2 + return + fi + + echo "Error: argument for $1 is missing" >&2 + exit 1 +} + +MODE="" # build, check +EXTENSION="" # e.g. /path/to/ext-debian.sh + +GIT_REPO_PATH="" # e.g. /path/to/git/repo/voulage +MANIFEST_PATH="" # e.g. /path/to/manifests +PKG_BUILD_PATH="" # e.g. /path/to/packages +PKG_PUBLISH_PATH="" # e.g. /path/to/publish + +DISTRO="" # ubuntu, debian +CODENAME="" # e.g. jammy, noble, bookworm, etc +STAGE="" # experimental, unstable, testing, release-x_y (different release stages from github action point-of-view) +SUITE="" # experimental, unstable, testing, stable (corresponding value from published arcvhies point-of-view) +COMPONENT="" # e.g. main, 3.2, 3.1, etc. +ARCH="" # amd64, arm64 + +LOCAL_BUILD="false" + +while [[ $# -gt 0 ]]; do + case $1 in + build|check) MODE="$1"; shift; ;; + --extension) parse_flag "$1" "$2" EXTENSION; shift 2 ;; + + --git-repo-path) parse_flag "$1" "$2" GIT_REPO_PATH; shift 2 ;; + --manifest-path) parse_flag "$1" "$2" MANIFEST_PATH; shift 2 ;; + --pkg-build-path) parse_flag "$1" "$2" PKG_BUILD_PATH; shift 2 ;; + --pkg-publish-path) parse_flag "$1" "$2" PKG_PUBLISH_PATH; shift 2 ;; + + --distro) parse_flag "$1" "$2" DISTRO; shift 2 ;; + --codename) parse_flag "$1" "$2" CODENAME; shift 2 ;; + --stage) parse_flag "$1" "$2" STAGE; shift 2 ;; + --suite) parse_flag "$1" "$2" SUITE; shift 2 ;; + --component) parse_flag "$1" "$2" COMPONENT; shift 2 ;; + --arch) parse_flag "$1" "$2" ARCH; shift 2 ;; + + -h|--help) usage; exit 0; ;; + -*|--*) echo "Unknown option $1"; exit 1; ;; + *) echo "Unknown command $1"; exit 1; ;; + esac +done + +if [ -z "$MODE" ]; then + echo "Error: command is missing" + exit 1 +fi +if [ -z "$EXTENSION" ]; then + echo "Error: required value for --extension is missing" + exit 1 +fi + +if [ -z "$GIT_REPO_PATH" ]; then + echo "Error: required value for --git-repo-path is missing" + exit 1 +else + GIT_REPO_PATH=$(realpath "$GIT_REPO_PATH") +fi +if [ -z "$MANIFEST_PATH" ]; then + echo "Error: required value for --manifest-path is missing" + exit 1 +fi +if [ -z "$PKG_BUILD_PATH" ]; then + echo "Error: required value for --pkg-build-path is missing" + exit 1 +fi +if [ -z "$PKG_PUBLISH_PATH" ]; then + echo "Error: required value for --pkg-publish-path is missing" + exit 1 +fi + +if [ -z "$DISTRO" ]; then + echo "Error: required value for --distro is missing" + exit 1 +fi +if [ -z "$CODENAME" ]; then + echo "Error: required value for --codename is missing" + exit 1 +fi +if [ -z "$STAGE" ]; then + echo "Error: required value for --stage is missing" + exit 1 +fi +if [ -z "$SUITE" ]; then + echo "Error: required value for --suite is missing" + exit 1 +fi +if [ -z "$COMPONENT" ]; then + echo "Error: required value for --component is missing" + exit 1 +fi +if [ -z "$ARCH" ]; then + echo "Error: required value for --arch is missing" + exit 1 +fi + +#### Get extensions + +GIT_EXT="$GIT_REPO_PATH/.github/scripts/ext-git.sh" if [ ! -f "$GIT_EXT" ]; then - echo "Extension $GIT_EXT doesn't exist, aborting." + echo "Error: extension $GIT_EXT doesn't exist, aborting." exit 1 else source $GIT_EXT fi if [ ! -f "$EXTENSION" ]; then - echo "Extension $EXTENSION doesn't exist, aborting." + echo "Error: extension $EXTENSION doesn't exist, aborting." exit 1 else source $EXTENSION @@ -166,31 +290,31 @@ fi #### Init globals -ROOT_MODEL_PATH="$REPO_ROOT/stage/package-model.json" +ROOT_MODEL_PATH="$GIT_REPO_PATH/stage/package-model.json" #### Setup files -if [ -d "$MANIFEST_PATH" ]; then - echo "Deleting pre-existing manifest dir $MANIFEST_PATH" - rm -Rf "$MANIFEST_PATH" +if [ -d "$PKG_BUILD_PATH" ]; then + echo "Deleting pre-existing package build dir $PKG_BUILD_PATH" + rm -Rf "$PKG_BUILD_PATH" fi -if [ -d "$PKG_BUILD_DIR" ]; then - echo "Deleting pre-existing package build dir $PKG_BUILD_DIR" - rm -Rf "$PKG_BUILD_DIR" +if [ -d "$PKG_PUBLISH_PATH" ]; then + echo "Deleting pre-existing package publish dir $PKG_PUBLISH_PATH" + rm -Rf "$PKG_PUBLISH_PATH" fi if [ ! -d "$MANIFEST_PATH" ]; then mkdir -p $MANIFEST_PATH fi -if [ ! -d "$PKG_REPO_PATH" ]; then - mkdir -p $PKG_REPO_PATH +if [ ! -d "$PKG_PUBLISH_PATH" ]; then + mkdir -p $PKG_PUBLISH_PATH fi #### Generate Manifest from package model tree and git repo state -PREV_MANIFEST_FILE="$PKG_REPO_PATH/manifest.txt" +PREV_MANIFEST_FILE="$MANIFEST_PATH/manifest.txt" NEXT_MANIFEST_FILE="$MANIFEST_PATH/next-manifest.txt" # Create prev manifest if doesn't exist (first run) @@ -206,6 +330,7 @@ fi # Merge models across stage, distro, codename, arch merge_models + # Iterate over each package in the model and call handle_package traverse_package_model @@ -227,6 +352,8 @@ if [ "$MODE" == "build" ]; then #### Cleanup + archive_cleanup_scripts + rm "$PREV_MANIFEST_FILE" mv "$NEXT_MANIFEST_FILE" "$PREV_MANIFEST_FILE" else diff --git a/.github/workflows/build-arch.yml b/.github/workflows/build-arch.yml index 03b37e18..59e6f44f 100644 --- a/.github/workflows/build-arch.yml +++ b/.github/workflows/build-arch.yml @@ -1,4 +1,4 @@ -name: Arch Package Builder Prototype +name: Package Builder Arch (Prototype) on: workflow_dispatch: @@ -20,6 +20,13 @@ jobs: arch: amd64 distro: arch codename: testing + + - stage: experimental + suite: experimental + component: main + - stage: unstable + suite: unstable + component: main steps: - uses: actions/checkout@v4 - name: Set Job Parameters @@ -34,6 +41,8 @@ jobs: echo "codename=${{ matrix.codename }}" >> $GITHUB_OUTPUT echo "arch=${{ matrix.arch }}" >> $GITHUB_OUTPUT echo "target=${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT + echo "suite=${{ matrix.suite }}" >> $GITHUB_OUTPUT + echo "component=${{ matrix.component }}" >> $GITHUB_OUTPUT echo "repo_url=https://regolith-desktop.org/${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT - name: Env setup run: | @@ -51,18 +60,18 @@ jobs: run: | set -e CHANGE_OUTPUT=$(${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/main.sh \ - ${{ steps.init.outputs.GH_REPO_ROOT }} \ - ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-arch.sh \ - "${{ steps.init.outputs.stage }}" \ - "${{ steps.init.outputs.distro }}" \ - "${{ steps.init.outputs.codename }}" \ - "${{ steps.init.outputs.arch }}" \ - "unneeded to check change" \ - "unneeded to check change" \ check \ - ${{ steps.init.outputs.MANIFEST_PATH }} \ - ${{ steps.init.outputs.PKG_REPO_PATH }} \ - ${{ steps.init.outputs.PKG_BUILD_DIR }} | tail -n1) + --extension ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-arch.sh \ + --git-repo-path ${{ steps.init.outputs.GH_REPO_ROOT }} \ + --manifest-path ${{ steps.init.outputs.MANIFEST_PATH }} \ + --pkg-build-path ${{ steps.init.outputs.PKG_BUILD_DIR }} \ + --pkg-publish-path ${{ steps.init.outputs.PKG_REPO_PATH }} \ + --distro "${{ steps.init.outputs.distro }}" \ + --codename "${{ steps.init.outputs.codename }}" \ + --arch "${{ steps.init.outputs.arch }}" \ + --stage "${{ steps.init.outputs.stage }}" \ + --suite "${{ steps.init.outputs.suite }}" \ + --component "${{ steps.init.outputs.component }}" | tail -n1) if [ "$CHANGE_OUTPUT" == "No package changes found, exiting." ]; then echo "changed=0" >> $GITHUB_OUTPUT echo "No package changes to build" @@ -93,18 +102,18 @@ jobs: printf "${{ secrets.PACKAGE_PRIVATE_KEY2 }}" | base64 --decode > ~/.gnupg/private.key gpg --batch --import ~/.gnupg/private.key ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/main.sh \ - ${{ steps.init.outputs.GH_REPO_ROOT }} \ - ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-arch.sh \ - "${{ steps.init.outputs.stage }}" \ - "${{ steps.init.outputs.distro }}" \ - "${{ steps.init.outputs.codename }}" \ - "${{ steps.init.outputs.arch }}" \ - "${{ steps.init.outputs.repo_url }}" \ - Default \ build \ - ${{ steps.init.outputs.MANIFEST_PATH }} \ - ${{ steps.init.outputs.PKG_REPO_PATH }} \ - ${{ steps.init.outputs.PKG_BUILD_DIR }} | tee -a ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt + --extension ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-arch.sh \ + --git-repo-path ${{ steps.init.outputs.GH_REPO_ROOT }} \ + --manifest-path ${{ steps.init.outputs.MANIFEST_PATH }} \ + --pkg-build-path ${{ steps.init.outputs.PKG_BUILD_DIR }} \ + --pkg-publish-path ${{ steps.init.outputs.PKG_REPO_PATH }} \ + --distro "${{ steps.init.outputs.distro }}" \ + --codename "${{ steps.init.outputs.codename }}" \ + --arch "${{ steps.init.outputs.arch }}" \ + --stage "${{ steps.init.outputs.stage }}" \ + --suite "${{ steps.init.outputs.suite }}" \ + --component "${{ steps.init.outputs.component }}" | tee -a ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt if [ -f ${{ steps.init.outputs.MANIFEST_PATH }}/next-manifest.txt ]; then echo "Temp manifest not deleted by main.sh, build aborted/failed." echo "changed=0" >> $GITHUB_OUTPUT diff --git a/.github/workflows/build-deb-v4.yml b/.github/workflows/build-deb-v4.yml index 25d7e76c..318ef132 100644 --- a/.github/workflows/build-deb-v4.yml +++ b/.github/workflows/build-deb-v4.yml @@ -1,260 +1,417 @@ -name: Debian Package Builder v4 +name: Package Builder Debian v4 +run-name: Build ${{ inputs.stage }} Packages ${{ inputs.distro }} ${{ inputs.codename }} ${{ inputs.arch }} on: workflow_dispatch: + inputs: + stage: + description: "Stage to build" + type: choice + options: + - all + - experimental + - unstable + - testing + - release-3_0 + - release-3_1 + - release-3_2 + required: true + default: "unstable" + distro: + description: "Distro to build (debian, ubuntu)" + type: choice + options: + - "" + - debian + - ubuntu + required: false + default: "" + codename: + description: "Codename to build (e.g. noble, bookworm)" + type: string + required: false + default: "" + arch: + description: "Architecture to build (amd64, arm64)" + type: choice + options: + - "" + - amd64 + - arm64 + required: false + default: "" + workflow_call: + inputs: + stage: + description: "Stage to build" + type: string + required: true + default: "unstable" + distro: + description: "Distro to build (debian, ubuntu)" + type: string + required: false + codename: + description: "Codename to build (e.g. noble, bookworm)" + type: string + required: false + arch: + description: "Architecture to build (amd64, arm64)" + type: string + required: false concurrency: group: debian_builder_v4 cancel-in-progress: true jobs: + matrix-builder: + runs-on: ubuntu-24.04 + outputs: + stages: ${{ steps.calc-matrix.outputs.stages }} + distros: ${{ steps.calc-matrix.outputs.distros }} + codenames: ${{ steps.calc-matrix.outputs.codenames }} + arches: ${{ steps.calc-matrix.outputs.arches }} + suites: ${{ steps.calc-matrix.outputs.suites }} + runners: ${{ steps.calc-matrix.outputs.runners }} + includes: ${{ steps.calc-matrix.outputs.includes }} + excludes: ${{ steps.calc-matrix.outputs.excludes }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Calculate Matrix + id: calc-matrix + run: | + if [ -n "${{ inputs.stage }}" ] && [ "${{ inputs.stage }}" != "all" ]; then + STAGES=(${{ inputs.stage }}) + else + STAGES=(experimental testing unstable) + fi + DISTROS=() + CODENAMES=() + if [ -n "${{ inputs.arch }}" ]; then + ARCHES=(${{ inputs.arch }}) + else + ARCHES=(amd64 arm64) + fi + INCLUDES=() + EXCLUDES=() + + valid_distro_codenames=() + + for stage in "${STAGES[@]}"; do + if [ ! -d "stage/${stage}" ]; then + echo "Package model for stage ${stage} not found!" + continue + fi + + for dir in $(find stage/${stage}/ -mindepth 2 -maxdepth 2 -type d | sort); do + for arch in "${ARCHES[@]}"; do + distro=$(echo $dir | cut -d/ -f3) + if [ -n "${{ inputs.distro }}" ] && [ "${{ inputs.distro }}" != "$distro" ]; then + continue + fi + + codename=$(echo $dir | cut -d/ -f4) + if [ -n "${{ inputs.codename }}" ] && [ "${{ inputs.codename }}" != "$codename" ]; then + continue + fi + + if [[ ! " ${DISTROS[*]} " =~ [[:space:]]${distro}[[:space:]] ]]; then + DISTROS+=("${distro}") + fi + if [[ ! " ${CODENAMES[*]} " =~ [[:space:]]${codename}[[:space:]] ]]; then + CODENAMES+=("${codename}") + fi + if [[ ! " ${valid_distro_codenames[*]} " =~ [[:space:]]${distro}-${codename}[[:space:]] ]]; then + valid_distro_codenames+=("${distro}-${codename}") + fi + done + done + done + + for distro in "${DISTROS[@]}"; do + for codename in "${CODENAMES[@]}"; do + if [[ ! " ${valid_distro_codenames[*]} " =~ [[:space:]]${distro}-${codename}[[:space:]] ]]; then + EXCLUDES+=($(jq -n -c --arg distro "$distro" --arg codename "$codename" '$ARGS.named')) + fi + done + done + + if [[ "${{ inputs.stage }}" == "release-"* ]]; then + EXCLUDES+=($(jq -n -c --arg distro "debian" --arg codename "testing" '$ARGS.named')) + fi + + SUITES=$(jq -n "$(jq -n -c \ + --argjson experimental "$(jq -n -c --arg suite "experimental" --arg component "main" '$ARGS.named')" \ + --argjson unstable "$(jq -n -c --arg suite "unstable" --arg component "main" '$ARGS.named')" \ + --argjson testing "$(jq -n -c --arg suite "testing" --arg component "main" '$ARGS.named')" \ + --argjson stable "$(jq -n -c --arg suite "stable" --arg component "main" '$ARGS.named')" \ + --argjson release-3_0 "$(jq -n -c --arg suite "stable" --arg component "v3.0" '$ARGS.named')" \ + --argjson release-3_1 "$(jq -n -c --arg suite "stable" --arg component "v3.1" '$ARGS.named')" \ + --argjson release-3_2 "$(jq -n -c --arg suite "stable" --arg component "v3.2" '$ARGS.named')" \ + '$ARGS.named'\ + )" '$ARGS.named') + + echo "stages=$(jq -n -c '$ARGS.positional' --args -- "${STAGES[@]}")" >> $GITHUB_OUTPUT + echo "distros=$(jq -n -c '$ARGS.positional' --args -- "${DISTROS[@]}")" >> $GITHUB_OUTPUT + echo "codenames=$(jq -n -c '$ARGS.positional' --args -- "${CODENAMES[@]}")" >> $GITHUB_OUTPUT + echo "arches=$(jq -n -c '$ARGS.positional' --args -- "${ARCHES[@]}")" >> $GITHUB_OUTPUT + echo "suites=$(jq -n -c "${SUITES}" '$ARGS.named')" >> $GITHUB_OUTPUT + echo "runners=$(jq -n -c "$(jq -n -c --arg amd64 "X64" --arg arm64 "arm64" '$ARGS.named')" '$ARGS.named')" >> $GITHUB_OUTPUT + echo "includes=$(jq -n -c "[$(printf '%s\n' "${INCLUDES[@]}" | paste -sd,)]" '$ARGS.named')" >> $GITHUB_OUTPUT + echo "excludes=$(jq -n -c "[$(printf '%s\n' "${EXCLUDES[@]}" | paste -sd,)]" '$ARGS.named')" >> $GITHUB_OUTPUT + + # build packages and sources build: - runs-on: ${{ matrix.host-os }} + runs-on: [self-hosted, Linux, "${{ fromJSON(needs.matrix-builder.outputs.runners)[matrix.arch] }}", "${{ matrix.codename }}"] + needs: matrix-builder strategy: matrix: - stage: [ experimental, unstable, testing, release-3_2 ] #, release-3_1, release-3_0, release-2_2, release-2_1] - distro-codename: [ - ubuntu-jammy-amd64, - ubuntu-jammy-arm64, - ubuntu-noble-amd64, - ubuntu-noble-arm64, - ubuntu-oracular-amd64, - ubuntu-oracular-arm64, - debian-bookworm-amd64, - debian-bookworm-arm64, - debian-testing-amd64, - debian-testing-arm64 - ] - exclude: - - stage: release-3_2 - distro-codename: debian-testing-amd64 # debian testing is never released - - stage: release-3_2 - distro-codename: debian-testing-arm64 # debian testing is never released - - stage: release-3_2 - distro-codename: ubuntu-oracular-amd64 # 3.2 released before oracular - - stage: release-3_2 - distro-codename: ubuntu-oracular-arm64 - include: - - distro-codename: ubuntu-jammy-amd64 - host-os: ubuntu-22.04 - arch: amd64 - distro: ubuntu - codename: jammy - - distro-codename: ubuntu-jammy-arm64 - host-os: [self-hosted, Linux, arm64, jammy] - arch: arm64 - distro: ubuntu - codename: jammy - - distro-codename: ubuntu-noble-amd64 - host-os: [self-hosted, Linux, X64, noble] - arch: amd64 - distro: ubuntu - codename: noble - - distro-codename: ubuntu-noble-arm64 - host-os: [self-hosted, Linux, arm64, noble] - arch: arm64 - distro: ubuntu - codename: noble - - distro-codename: ubuntu-oracular-amd64 - host-os: [self-hosted, Linux, X64, oracular] - arch: amd64 - distro: ubuntu - codename: oracular - - distro-codename: ubuntu-oracular-arm64 - host-os: [self-hosted, Linux, arm64, oracular] - arch: arm64 - distro: ubuntu - codename: oracular - - distro-codename: debian-bookworm-amd64 - host-os: [self-hosted, Linux, X64, bookworm] - arch: amd64 - distro: debian - codename: bookworm - - distro-codename: debian-bookworm-arm64 - host-os: [self-hosted, Linux, arm64, bookworm] - arch: arm64 - distro: debian - codename: bookworm - - distro-codename: debian-testing-amd64 - host-os: [self-hosted, Linux, X64, testing] - arch: amd64 - distro: debian - codename: testing - - distro-codename: debian-testing-arm64 - host-os: [self-hosted, Linux, arm64, testing] - arch: arm64 - distro: debian - codename: testing + stage: ${{ fromJSON(needs.matrix-builder.outputs.stages) }} + distro: ${{ fromJSON(needs.matrix-builder.outputs.distros) }} + codename: ${{ fromJSON(needs.matrix-builder.outputs.codenames) }} + arch: ${{ fromJSON(needs.matrix-builder.outputs.arches) }} + + include: ${{ fromJSON(needs.matrix-builder.outputs.includes) }} + exclude: ${{ fromJSON(needs.matrix-builder.outputs.excludes) }} steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 + - name: Set Job Parameters id: init run: | - echo "SIGNING_KEY_ID=C91ECAB862037F9474087DBC7107DED133505B88" >> $GITHUB_OUTPUT - echo "MANIFEST_PATH=${{ github.workspace }}/manifests" >> $GITHUB_OUTPUT - echo "PKG_REPO_PATH=${{ github.workspace }}/repo" >> $GITHUB_OUTPUT - echo "PKG_BUILD_DIR=${{ github.workspace }}/packages" >> $GITHUB_OUTPUT - echo "GH_REPO_ROOT=${{ github.workspace }}" >> $GITHUB_OUTPUT + echo "gh-repo-path=${{ github.workspace }}" >> $GITHUB_OUTPUT + echo "changelogs-path=${{ github.workspace }}/changelogs" >> $GITHUB_OUTPUT + echo "manifest-path=${{ github.workspace }}/manifests" >> $GITHUB_OUTPUT + echo "package-build-path=${{ github.workspace }}/packages" >> $GITHUB_OUTPUT + echo "package-publish-path=${{ github.workspace }}/publish" >> $GITHUB_OUTPUT echo "stage=${{ matrix.stage }}" >> $GITHUB_OUTPUT echo "distro=${{ matrix.distro }}" >> $GITHUB_OUTPUT echo "codename=${{ matrix.codename }}" >> $GITHUB_OUTPUT echo "arch=${{ matrix.arch }}" >> $GITHUB_OUTPUT + echo "suite=${{ fromJSON(needs.matrix-builder.outputs.suites)[matrix.stage]['suite'] }}" >> $GITHUB_OUTPUT + echo "component=${{ fromJSON(needs.matrix-builder.outputs.suites)[matrix.stage]['component'] }}" >> $GITHUB_OUTPUT echo "target=${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT - echo "repo_url=https://regolith-desktop.org/${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT - - name: Env setup + + - name: Environment Setup run: | set -e - mkdir ${{ steps.init.outputs.MANIFEST_PATH }} || true - mkdir ${{ steps.init.outputs.PKG_BUILD_DIR }} || true - - # Following allows for internal dependencies - # FIXME(kgilmer): extract following logic to distro specific script - rm /tmp/manifest.txt || true - wget -P /tmp "https://regolith-desktop.org/${{ steps.init.outputs.target }}/manifest.txt" || true - - if [ -f /tmp/manifest.txt ]; then - echo "Adding repo to apt: ${{ steps.init.outputs.target }}" - rm /tmp/manifest.txt - wget -qO - https://regolith-desktop.org/regolith3.key | sudo apt-key add - - echo deb "[arch=${{ steps.init.outputs.arch }}] ${{ steps.init.outputs.repo_url }} ${{ steps.init.outputs.codename }} main" | sudo tee /etc/apt/sources.list.d/regolith.list - fi + mkdir -p ${{ steps.init.outputs.changelogs-path }} || true + mkdir -p ${{ steps.init.outputs.manifest-path }} || true - if [ -f "/etc/apt/sources.list.d/regolith-local.list" ]; then - sudo rm /etc/apt/sources.list.d/regolith-local.list - echo "Cleaned up temp apt repo" - fi - + sudo rm -rf /etc/apt/sources.list.d/regolith.list sudo apt update - DEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends jq git devscripts reprepro wget dput + DEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends jq git devscripts wget dput diffutils + - name: Pull Manifest run: | set -e - wget -P "${{ steps.init.outputs.PKG_REPO_PATH }}" "https://regolith-desktop.org/${{ steps.init.outputs.target }}/manifest.txt" || true - echo "Previous manifest:" - cat ${{ steps.init.outputs.PKG_REPO_PATH }}/manifest.txt || true + wget -P "${{ steps.init.outputs.manifest-path }}" "http://archive.regolith-desktop.com/manifests/${{ steps.init.outputs.distro }}/${{ steps.init.outputs.codename }}/${{ steps.init.outputs.suite }}-${{ steps.init.outputs.component }}/${{ steps.init.outputs.arch }}/manifest.txt" || true + echo "Current manifest:" + cat ${{ steps.init.outputs.manifest-path }}/manifest.txt || true + - name: Check for changes id: changes run: | set -e set -x - CHANGE_OUTPUT=$(${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/main.sh \ - ${{ steps.init.outputs.GH_REPO_ROOT }} \ - ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-debian.sh \ - "${{ steps.init.outputs.stage }}" \ - "${{ steps.init.outputs.distro }}" \ - "${{ steps.init.outputs.codename }}" \ - "${{ steps.init.outputs.arch }}" \ - "unneeded to check change" \ - "unneeded to check change" \ + + CHANGE_OUTPUT=$(${{ steps.init.outputs.gh-repo-path }}/.github/scripts/main.sh \ check \ - ${{ steps.init.outputs.MANIFEST_PATH }} \ - ${{ steps.init.outputs.PKG_REPO_PATH }} \ - ${{ steps.init.outputs.PKG_BUILD_DIR }} | tail -n1) + --extension ${{ steps.init.outputs.gh-repo-path }}/.github/scripts/ext-debian.sh \ + --git-repo-path ${{ steps.init.outputs.gh-repo-path }} \ + --manifest-path ${{ steps.init.outputs.manifest-path }} \ + --pkg-build-path ${{ steps.init.outputs.package-build-path }} \ + --pkg-publish-path ${{ steps.init.outputs.package-publish-path }} \ + --distro "${{ steps.init.outputs.distro }}" \ + --codename "${{ steps.init.outputs.codename }}" \ + --arch "${{ steps.init.outputs.arch }}" \ + --stage "${{ steps.init.outputs.stage }}" \ + --suite "${{ steps.init.outputs.suite }}" \ + --component "${{ steps.init.outputs.component }}" | tail -n1) + if [ "$CHANGE_OUTPUT" == "No package changes found, exiting." ]; then echo "changed=0" >> $GITHUB_OUTPUT echo "No package changes to build" else echo "changed=1" >> $GITHUB_OUTPUT echo "New Manifest: " - cat ${{ steps.init.outputs.MANIFEST_PATH }}/next-manifest.txt + cat ${{ steps.init.outputs.manifest-path }}/next-manifest.txt fi - - uses: webfactory/ssh-agent@v0.9.0 + + - name: Setup SSH agent + uses: webfactory/ssh-agent@v0.9.0 if: steps.changes.outputs.changed == 1 with: ssh-private-key: ${{ secrets.KAMATERA_SSH_KEY }} - - name: Pull repo - if: steps.changes.outputs.changed == 1 - run: | - set -e - set -x - ssh-keyscan -H ${{ secrets.KAMATERA_HOSTNAME }} >> ~/.ssh/known_hosts - scp -r root@${{ secrets.KAMATERA_HOSTNAME }}:/var/www/html/${{ steps.init.outputs.target }}/* "${{ steps.init.outputs.PKG_REPO_PATH }}" || true - if [ ! -d ${{ steps.init.outputs.PKG_REPO_PATH }} ]; then - mkdir -p "${{ steps.init.outputs.PKG_REPO_PATH }}" - fi - - name: Build + + - name: Build Packages if: steps.changes.outputs.changed == 1 run: | set -e + export DEBEMAIL="regolith.linux@gmail.com" export DEBFULLNAME="Regolith Linux" export DEBIAN_FRONTEND=noninteractive + mkdir -p ~/.gnupg/ printf "${{ secrets.PACKAGE_PRIVATE_KEY2 }}" | base64 --decode > ~/.gnupg/private.key gpg --batch --import ~/.gnupg/private.key - ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/main.sh \ - ${{ steps.init.outputs.GH_REPO_ROOT }} \ - ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-debian.sh \ - "${{ steps.init.outputs.stage }}" \ - "${{ steps.init.outputs.distro }}" \ - "${{ steps.init.outputs.codename }}" \ - "${{ steps.init.outputs.arch }}" \ - "${{ steps.init.outputs.repo_url }}" \ - "${{ steps.init.outputs.SIGNING_KEY_ID }}" \ + + ${{ steps.init.outputs.gh-repo-path }}/.github/scripts/main.sh \ build \ - ${{ steps.init.outputs.MANIFEST_PATH }} \ - ${{ steps.init.outputs.PKG_REPO_PATH }} \ - ${{ steps.init.outputs.PKG_BUILD_DIR }} | tee -a ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt - if [ -f ${{ steps.init.outputs.MANIFEST_PATH }}/next-manifest.txt ]; then + --extension ${{ steps.init.outputs.gh-repo-path }}/.github/scripts/ext-debian.sh \ + --git-repo-path ${{ steps.init.outputs.gh-repo-path }} \ + --manifest-path ${{ steps.init.outputs.manifest-path }} \ + --pkg-build-path ${{ steps.init.outputs.package-build-path }} \ + --pkg-publish-path ${{ steps.init.outputs.package-publish-path }} \ + --distro "${{ steps.init.outputs.distro }}" \ + --codename "${{ steps.init.outputs.codename }}" \ + --arch "${{ steps.init.outputs.arch }}" \ + --stage "${{ steps.init.outputs.stage }}" \ + --suite "${{ steps.init.outputs.suite }}" \ + --component "${{ steps.init.outputs.component }}" | tee -a ${{ steps.init.outputs.changelogs-path }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt + + if [ -f ${{ steps.init.outputs.manifest-path }}/next-manifest.txt ]; then echo "Temp manifest not deleted by main.sh, build aborted/failed." - echo "changed=0" >> $GITHUB_OUTPUT exit 1 - else - cat ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt | grep ^CHLOG: | cut -c 7- > ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.txt fi + + cat ${{ steps.init.outputs.changelogs-path }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt | grep ^CHLOG: | cut -c 7- > ${{ steps.init.outputs.changelogs-path }}/CHANGELOG_${{ steps.init.outputs.target }}.txt + cat ${{ steps.init.outputs.changelogs-path }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt | grep ^SRCLOG: | cut -c 8- > ${{ steps.init.outputs.changelogs-path }}/SOURCELOG_${{ steps.init.outputs.target }}.txt + + if [ ! -s ${{ steps.init.outputs.changelogs-path }}/CHANGELOG_${{ steps.init.outputs.target }}.txt ] ; then + rm ${{ steps.init.outputs.changelogs-path }}/CHANGELOG_${{ steps.init.outputs.target }}.txt + fi + + if [ ! -s ${{ steps.init.outputs.changelogs-path }}/SOURCELOG_${{ steps.init.outputs.target }}.txt ] ; then + rm ${{ steps.init.outputs.changelogs-path }}/SOURCELOG_${{ steps.init.outputs.target }}.txt + fi + - name: Deploy via rsync if: steps.changes.outputs.changed == 1 run: | set -e set -x - for i in 1 2 3 4 5; do echo "Attempt $i" && rsync -avzh ${{ steps.init.outputs.PKG_REPO_PATH }}/* root@${{ secrets.KAMATERA_HOSTNAME }}:/var/www/html/${{ steps.init.outputs.target }} && break || sleep 5; done + + ssh-keyscan -H ${{ secrets.KAMATERA_HOSTNAME2 }} >> ~/.ssh/known_hosts + + for i in 1 2 3 4 5; do + echo "Attempt $i" + rsync \ + -avzhH \ + ${{ steps.init.outputs.package-publish-path }}/* \ + root@${{ secrets.KAMATERA_HOSTNAME2 }}:/opt/archives/packages/ && break || sleep 5 + done + + rsync --ignore-missing-args ${{ steps.init.outputs.changelogs-path }}/SOURCELOG_${{ steps.init.outputs.target }}.txt root@${{ secrets.KAMATERA_HOSTNAME2 }}:/opt/archives/workspace/ + rsync --mkpath ${{ steps.init.outputs.manifest-path }}/manifest.txt root@${{ secrets.KAMATERA_HOSTNAME2 }}:/opt/archives/manifests/${{ steps.init.outputs.distro }}/${{ steps.init.outputs.codename }}/${{ steps.init.outputs.suite }}-${{ steps.init.outputs.component }}/${{ steps.init.outputs.arch }}/ + - name: Log Build Output if: steps.changes.outputs.changed == 1 run: | - cat ${{ steps.init.outputs.PKG_REPO_PATH }}/manifest.txt || true - echo "PKG_BUILD_DIR:" - find ${{ steps.init.outputs.PKG_BUILD_DIR }} - - name: Cleanup - run: | - # FIXME(kgilmer) extract following logic to distro-specific script - # Remove regolith repo from build system apt config - if [ -f /etc/apt/sources.list.d/regolith.list ]; then - sudo rm -f /etc/apt/sources.list.d/regolith.list - fi - - uses: actions/upload-artifact@v4 + cat ${{ steps.init.outputs.manifest-path }}/manifest.txt || true + echo "package-publish-path:" + find ${{ steps.init.outputs.package-publish-path }} + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 if: steps.changes.outputs.changed == 1 with: name: CHANGELOG_${{ steps.init.outputs.target }} - path: | - ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.txt + path: ${{ steps.init.outputs.changelogs-path }}/*${{ steps.init.outputs.target }}.txt - test: + # calculate changelogs + changelogs: + runs-on: ubuntu-24.04 needs: build - uses: ./.github/workflows/test-desktop-installable2.yml - - generate-release: - needs: build - runs-on: ubuntu-20.04 + outputs: + package-changed: ${{ steps.check.outputs.package-changed }} + source-changed: ${{ steps.check.outputs.source-changed }} steps: - - uses: actions/download-artifact@v4 - - name: Concat Release Notes - id: release-setup + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + path: changelogs + pattern: CHANGELOG_* + merge-multiple: true + + - name: Check Changelogs + id: check run: | set -e - echo "TIMESTAMP=$(date +%Y%m%d_%H%M%S)" >> $GITHUB_OUTPUT - FILES=$(find . -name CHANGELOG\*) - if [ -n "$FILES" ]; then - cat CHANGELOG_*/CHANGELOG_*.txt >> CHANGELOG.txt - echo "changed=1" >> $GITHUB_OUTPUT + + if [ ! -d changelogs ]; then + echo "No package file found to publish!" + echo "No source file found to rebuild!" + + echo "package-changed=0" >> $GITHUB_OUTPUT + echo "source-changed=0" >> $GITHUB_OUTPUT else - echo "changed=0" >> $GITHUB_OUTPUT + ls -R changelogs/ + + echo "package-changed=$(find changelogs -name CHANGELOG_\*.txt | wc -l)" >> $GITHUB_OUTPUT + echo "source-changed=$(find changelogs -name SOURCELOG_\*.txt | wc -l)" >> $GITHUB_OUTPUT fi + + # rebuild sources + source: + needs: changelogs + if: ${{ !failure() && !cancelled() && needs.changelogs.outputs.source-changed != 0 }} + uses: ./.github/workflows/rebuild-sources.yml + with: + pull-from: /opt/archives/workspace/ + push-to: /opt/archives/packages/ + secrets: inherit + + # publish archives + publish: + needs: [changelogs, source] + if: ${{ !failure() && !cancelled() && needs.changelogs.outputs.package-changed != 0 }} + uses: ./.github/workflows/publish-packages.yml + with: + packages-path: /opt/archives/packages/ + secrets: inherit + + # create a release with changlogs + release: + runs-on: ubuntu-24.04 + needs: [changelogs, publish] + if: ${{ !failure() && !cancelled() && needs.changelogs.outputs.package-changed != 0 }} + steps: + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + path: changelogs + pattern: CHANGELOG_* + merge-multiple: true + + - name: Prepare Release + id: prepare + run: | + echo "TIMESTAMP=$(date +%Y%m%d_%H%M%S)" >> $GITHUB_OUTPUT + find changelogs/ -name CHANGELOG_\*.txt -exec sh -c 'cat "$1" >> CHANGELOG.txt' -- {} \; + cat CHANGELOG.txt + - uses: softprops/action-gh-release@v2 - if: steps.release-setup.outputs.changed == 1 with: body: See CHANGELOG.txt for updates and manifests for current state of repos. - name: Package Build ${{ steps.release-setup.outputs.TIMESTAMP }} - tag_name: pkgbuild-${{ steps.release-setup.outputs.TIMESTAMP }} + name: Package Build ${{ steps.prepare.outputs.TIMESTAMP }} + tag_name: pkgbuild-${{ steps.prepare.outputs.TIMESTAMP }} files: | *.txt + + # run the tests + test: + needs: [changelogs, release] + if: ${{ !failure() && !cancelled() }} + uses: ./.github/workflows/test-desktop-installable2.yml + with: + stage: ${{ inputs.stage }} + distro: ${{ inputs.distro }} + codename: ${{ inputs.codename }} + arch: ${{ inputs.arch }} diff --git a/.github/workflows/build-rpm.yml b/.github/workflows/build-rpm.yml index 2fc18862..5029a8b2 100644 --- a/.github/workflows/build-rpm.yml +++ b/.github/workflows/build-rpm.yml @@ -1,4 +1,4 @@ -name: RPM Package Builder +name: Package Builder RPM on: workflow_dispatch: @@ -21,21 +21,27 @@ jobs: distro: fedora codename: 36 container: fedora:36 + + - stage: experimental + suite: experimental + component: main steps: - uses: actions/checkout@v4 - name: Set Job Parameters id: init run: | - echo ::set-output name=MANIFEST_PATH::"${{ github.workspace }}/manifests" - echo ::set-output name=PKG_REPO_PATH::"${{ github.workspace }}/repo" - echo ::set-output name=PKG_BUILD_DIR::"${{ github.workspace }}/packages" - echo ::set-output name=GH_REPO_ROOT::"${{ github.workspace }}" - echo ::set-output name=stage::${{ matrix.stage }} - echo ::set-output name=distro::${{ matrix.distro }} - echo ::set-output name=codename::${{ matrix.codename }} - echo ::set-output name=arch::${{ matrix.arch }} - echo ::set-output name=target::${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }} - echo ::set-output name=repo_url::https://regolith-desktop.org/${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }} + echo "MANIFEST_PATH=${{ github.workspace }}/manifests" >> $GITHUB_OUTPUT + echo "PKG_REPO_PATH=${{ github.workspace }}/repo" >> $GITHUB_OUTPUT + echo "PKG_BUILD_DIR=${{ github.workspace }}/packages" >> $GITHUB_OUTPUT + echo "GH_REPO_ROOT=${{ github.workspace }}" >> $GITHUB_OUTPUT + echo "stage=${{ matrix.stage }}" >> $GITHUB_OUTPUT + echo "distro=${{ matrix.distro }}" >> $GITHUB_OUTPUT + echo "codename=${{ matrix.codename }}" >> $GITHUB_OUTPUT + echo "arch=${{ matrix.arch }}" >> $GITHUB_OUTPUT + echo "suite=${{ matrix.suite }}" >> $GITHUB_OUTPUT + echo "component=${{ matrix.component }}" >> $GITHUB_OUTPUT + echo "target=${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT + echo "repo_url=https://regolith-desktop.org/${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT - name: Env setup run: | set -e @@ -54,18 +60,18 @@ jobs: set -e set -x CHANGE_OUTPUT=$(${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/main.sh \ - ${{ steps.init.outputs.GH_REPO_ROOT }} \ - ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-rpm.sh \ - "${{ steps.init.outputs.stage }}" \ - "${{ steps.init.outputs.distro }}" \ - "${{ steps.init.outputs.codename }}" \ - "${{ steps.init.outputs.arch }}" \ - "unneeded to check change" \ - "unneeded to check change" \ check \ - ${{ steps.init.outputs.MANIFEST_PATH }} \ - ${{ steps.init.outputs.PKG_REPO_PATH }} \ - ${{ steps.init.outputs.PKG_BUILD_DIR }} | tail -n1) + --extension ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-rpm.sh \ + --git-repo-path ${{ steps.init.outputs.GH_REPO_ROOT }} \ + --manifest-path ${{ steps.init.outputs.MANIFEST_PATH }} \ + --pkg-build-path ${{ steps.init.outputs.PKG_BUILD_DIR }} \ + --pkg-publish-path ${{ steps.init.outputs.PKG_REPO_PATH }} \ + --distro "${{ steps.init.outputs.distro }}" \ + --codename "${{ steps.init.outputs.codename }}" \ + --arch "${{ steps.init.outputs.arch }}" \ + --stage "${{ steps.init.outputs.stage }}" \ + --suite "${{ steps.init.outputs.suite }}" \ + --component "${{ steps.init.outputs.component }}" | tail -n1) if [ "$CHANGE_OUTPUT" == "No package changes found, exiting." ]; then echo ::set-output name=changed::0 echo "No package changes to build" @@ -98,18 +104,18 @@ jobs: printf "${{ secrets.PACKAGE_PRIVATE_KEY2 }}" | base64 --decode > ~/.gnupg/private.key gpg --batch --import ~/.gnupg/private.key ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/main.sh \ - ${{ steps.init.outputs.GH_REPO_ROOT }} \ - ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-rpm.sh \ - "${{ steps.init.outputs.stage }}" \ - "${{ steps.init.outputs.distro }}" \ - "${{ steps.init.outputs.codename }}" \ - "${{ steps.init.outputs.arch }}" \ - "${{ steps.init.outputs.repo_url }}" \ - Default \ build \ - ${{ steps.init.outputs.MANIFEST_PATH }} \ - ${{ steps.init.outputs.PKG_REPO_PATH }} \ - ${{ steps.init.outputs.PKG_BUILD_DIR }} | tee -a ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt + --extension ${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-rpm.sh \ + --git-repo-path ${{ steps.init.outputs.GH_REPO_ROOT }} \ + --manifest-path ${{ steps.init.outputs.MANIFEST_PATH }} \ + --pkg-build-path ${{ steps.init.outputs.PKG_BUILD_DIR }} \ + --pkg-publish-path ${{ steps.init.outputs.PKG_REPO_PATH }} \ + --distro "${{ steps.init.outputs.distro }}" \ + --codename "${{ steps.init.outputs.codename }}" \ + --arch "${{ steps.init.outputs.arch }}" \ + --stage "${{ steps.init.outputs.stage }}" \ + --suite "${{ steps.init.outputs.suite }}" \ + --component "${{ steps.init.outputs.component }}" | tee -a ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt if [ -s "${{ steps.init.outputs.PKG_REPO_PATH }}/manifest.txt" ]; then cat ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt | grep ^CHLOG: | cut -c 7- > ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.txt else diff --git a/.github/workflows/test-builder.yml b/.github/workflows/test-builder.yml index f8f36a62..3d0351ab 100644 --- a/.github/workflows/test-builder.yml +++ b/.github/workflows/test-builder.yml @@ -1,4 +1,4 @@ -name: Test builder script +name: Test Builder Scripts on: workflow_dispatch: @@ -28,42 +28,61 @@ jobs: - distro-codename: debian-bullseye distro: debian codename: bullseye + + - stage: unstable + suite: unstable + component: main + - stage: testing + suite: testing + component: main + - stage: release + suite: stable + component: main + steps: - uses: actions/checkout@v4 + - name: Set Job Parameters id: init run: | - echo "MANIFEST_PATH=${{ github.workspace }}/manifests" >> $GITHUB_OUTPUT - echo "PKG_REPO_PATH=${{ github.workspace }}/repo" >> $GITHUB_OUTPUT - echo "PKG_BUILD_DIR=${{ github.workspace }}/packages" >> $GITHUB_OUTPUT - echo "GH_REPO_ROOT=${{ github.workspace }}" >> $GITHUB_OUTPUT + echo "gh-repo-path=${{ github.workspace }}" >> $GITHUB_OUTPUT + echo "manifest-path=${{ github.workspace }}/manifests" >> $GITHUB_OUTPUT + echo "package-build-path=${{ github.workspace }}/packages" >> $GITHUB_OUTPUT + echo "package-publish-path=${{ github.workspace }}/publish" >> $GITHUB_OUTPUT echo "stage=${{ matrix.stage }}" >> $GITHUB_OUTPUT echo "distro=${{ matrix.distro }}" >> $GITHUB_OUTPUT echo "codename=${{ matrix.codename }}" >> $GITHUB_OUTPUT echo "arch=${{ matrix.arch }}" >> $GITHUB_OUTPUT - echo "target=${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT + echo "suite=${{ matrix.suite }}" >> $GITHUB_OUTPUT + echo "component=${{ matrix.component }}" >> $GITHUB_OUTPUT + - name: Clean tmp run: | set -x - rm -Rf ${{ steps.init.outputs.PKG_REPO_PATH }} || true - mkdir ${{ steps.init.outputs.PKG_REPO_PATH }} - rm -Rf ${{ steps.init.outputs.MANIFEST_PATH }} || true - mkdir ${{ steps.init.outputs.MANIFEST_PATH }} - rm -Rf ${{ steps.init.outputs.PKG_BUILD_DIR }} || true - mkdir ${{ steps.init.outputs.PKG_BUILD_DIR }} + + rm -Rf ${{ steps.init.outputs.manifest-path }} || true + mkdir -p ${{ steps.init.outputs.manifest-path }} + + rm -Rf ${{ steps.init.outputs.package-build-path }} || true + mkdir -p ${{ steps.init.outputs.package-build-path }} + + rm -Rf ${{ steps.init.outputs.package-publish-path }} || true + mkdir -p ${{ steps.init.outputs.package-publish-path }} + - name: Test Build run: | set -x + ${{ github.workspace }}/.github/scripts/main.sh \ - "${{ github.workspace }}" \ - "${{ github.workspace }}/.github/scripts/ext-tester.sh" \ - "${{ steps.init.outputs.stage }}" \ - "${{ steps.init.outputs.distro }}" \ - "${{ steps.init.outputs.codename }}" \ - "${{ steps.init.outputs.arch }}" \ - test_repo_url \ - Default \ check \ - ${{ steps.init.outputs.MANIFEST_PATH }} \ - ${{ steps.init.outputs.PKG_REPO_PATH }} \ - ${{ steps.init.outputs.PKG_BUILD_DIR }} + --extension "${{ github.workspace }}/.github/scripts/ext-tester.sh" \ + --git-repo-path "${{ steps.init.outputs.gh-repo-path }}" \ + --manifest-path ${{ steps.init.outputs.manifest-path }} \ + --pkg-build-path ${{ steps.init.outputs.package-build-path }} \ + --pkg-publish-path ${{ steps.init.outputs.package-publish-path }} \ + --distro "${{ steps.init.outputs.distro }}" \ + --codename "${{ steps.init.outputs.codename }}" \ + --arch "${{ steps.init.outputs.arch }}" \ + --stage "${{ steps.init.outputs.stage }}" \ + --suite "${{ steps.init.outputs.suite }}" \ + --component "${{ steps.init.outputs.component }}" diff --git a/docs/testing.md b/docs/testing.md index 0e1afd1e..668f5845 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -5,11 +5,35 @@ To test the debian package checking and building, run the script: Check Example: ```console -.github/scripts/main.sh . unstable ubuntu focal amd64 someurl Default check +$ .github/scripts/main.sh \ + check \ + --git-repo-path . \ + --extension .github/scripts/ext-debian.sh \ + --manifest-path /path/to/dir/manifests \ + --pkg-build-path /path/to/dir/packages \ + --pkg-publish-path /path/to/dir/publish \ + --distro ubuntu \ + --codename focal \ + --arch amd64 \ + --stage unstable \ + --suite unstable \ + --component main ``` Build Example: ```console -.github/scripts/main.sh . unstable ubuntu focal amd64 someurl Default build -``` \ No newline at end of file +$ .github/scripts/main.sh \ + build \ + --git-repo-path . \ + --extension .github/scripts/ext-debian.sh \ + --manifest-path /path/to/dir/manifests \ + --pkg-build-path /path/to/dir/packages \ + --pkg-publish-path /path/to/dir/publish \ + --distro ubuntu \ + --codename focal \ + --arch amd64 \ + --stage unstable \ + --suite unstable \ + --component main +```