diff --git a/.github/actions/delivery/action.yml b/.github/actions/delivery/action.yml index ae50e008a75..d76a3c937e8 100644 --- a/.github/actions/delivery/action.yml +++ b/.github/actions/delivery/action.yml @@ -8,7 +8,7 @@ inputs: description: "The distribution used for packaging" required: true version: - description: "Centreon packaged version" + description: "Centreon packaged major version" required: true cache_key: description: "The cached package key" @@ -37,7 +37,7 @@ runs: - name: Build name for DEB shell: bash - if: ${{ inputs.distrib == 'bullseye' }} + if: ${{ contains(fromJSON('["bullseye", "bookworm", "jammy"]'), inputs.distrib) }} run: | echo "extfile=deb" >> $GITHUB_ENV @@ -59,25 +59,19 @@ runs: FILES="*.${{ env.extfile }}" - echo "[DEBUG] - Version: ${{ inputs.version }}" - echo "[DEBUG] - Distrib: ${{ inputs.distrib }}" - - if [ -z "${{ inputs.module_name }}" ]; then - echo "module name is required" - exit 1 - fi - - if [ -z "${{ inputs.distrib }}" ]; then - echo "distrib is required" - exit 1 - fi - # DEBUG echo "[DEBUG] - Version: ${{ inputs.version }}" echo "[DEBUG] - Distrib: ${{ inputs.distrib }}" echo "[DEBUG] - module_name: ${{ inputs.module_name }}" echo "[DEBUG] - release_cloud: ${{ inputs.release_cloud }}" echo "[DEBUG] - release_type: ${{ inputs.release_type }}" + echo "[DEBUG] - stability: ${{ inputs.stability }}" + + # Make sure all required inputs are NOT empty + if [[ -z "${{ inputs.module_name }}" || -z "${{ inputs.distrib }}" || -z ${{ inputs.stability }} || -z ${{ inputs.version }} || -z ${{ inputs.release_cloud }} || -z ${{ inputs.release_type }} ]]; then + echo "Some mandatory inputs are empty, please check the logs." + exit 1 + fi # Create ARCH dirs mkdir noarch x86_64 @@ -94,18 +88,31 @@ runs: done # Build upload target path based on release_cloud and release_type values - # if cloud, deliver to testing- - # if non-cloud, delivery to testing as usual + # if cloud + hotfix or cloud + release, deliver to internal testing- + # if cloud + develop, delivery to internal unstable + # if non-cloud, delivery to onprem testing or unstable + # CLOUD + HOTFIX + REPO STANDARD INTERNAL OR CLOUD + RELEASE + REPO STANDARD INTERNAL - if [[ ${{ inputs.release_cloud }} -eq 1 && ${{ inputs.release_type }} == "hotfix" ]] || [[ ${{ inputs.release_cloud }} -eq 1 && ${{ inputs.release_type }} == "release" ]]; then + if [[ ${{ inputs.release_cloud }} -eq 1 && ( ${{ inputs.release_type }} == "hotfix" || ${{ inputs.release_type }} == "release" ) ]]; then + echo "[DEBUG] : Release cloud + ${{ inputs.release_type }}, using rpm-standard-internal." + ROOT_REPO_PATHS="rpm-standard-internal" + UPLOAD_REPO_PATH="${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}-${{ inputs.release_type }}/$ARCH/${{ inputs.module_name }}/" + + # CLOUD + NOT HOTFIX OR CLOUD + NOT RELEASE + REPO STANDARD INTERNAL + elif [[ ${{ inputs.release_cloud }} -eq 1 && ( ${{ inputs.release_type }} != "hotfix" && ${{ inputs.release_type }} != "release" ) ]]; then + echo "[DEBUG] : Release cloud + NOT ${{ inputs.release_type }}, using rpm-standard-internal." ROOT_REPO_PATHS="rpm-standard-internal" - UPLOAD_REPO_PATH="${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}-${{ inputs.release_type }}/$ARCH/RPMS/${{ inputs.module_name }}/" + UPLOAD_REPO_PATH="${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}-${{ inputs.release_type }}/$ARCH/${{ inputs.module_name }}/" + # NON-CLOUD + (HOTFIX OR RELEASE) + REPO STANDARD elif [[ ${{ inputs.release_cloud }} -eq 0 ]]; then + echo "[DEBUG] : NOT Release cloud + ${{ inputs.release_type }}, using rpm-standard." ROOT_REPO_PATHS="rpm-standard" UPLOAD_REPO_PATH="${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" + + # NOT VALID, DO NOT DELIVER else - echo "Invalid combination of release_type and release_cloud" + echo "::error:: Invalid combination of release_type [${{ inputs.release_type }}] and release_cloud [${{ inputs.release_cloud }}]" exit 1 fi @@ -115,8 +122,10 @@ runs: if [ "$(ls -A $ARCH)" ]; then if [ "${{ inputs.stability }}" == "stable" ]; then echo "[DEBUG] - Stability is ${{ inputs.stability }}, not delivering." - else + elif [ "${{ inputs.stability }}" == "testing" ]; then jf rt upload "$ARCH/*.rpm" "$ROOT_REPO_PATH/$UPLOAD_REPO_PATH" --sync-deletes="$ROOT_REPO_PATH/$UPLOAD_REPO_PATH" --flat + else + jf rt upload "$ARCH/*.rpm" "$ROOT_REPO_PATH/${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --sync-deletes="$ROOT_REPO_PATH/${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --flat fi fi done @@ -128,13 +137,17 @@ runs: run: | FILES="*.${{ env.extfile }}" - if [ -z "${{ inputs.module_name }}" ]; then - echo "module name is required" - exit 1 - fi + # DEBUG + echo "[DEBUG] - Version: ${{ inputs.version }}" + echo "[DEBUG] - Distrib: ${{ inputs.distrib }}" + echo "[DEBUG] - module_name: ${{ inputs.module_name }}" + echo "[DEBUG] - release_cloud: ${{ inputs.release_cloud }}" + echo "[DEBUG] - release_type: ${{ inputs.release_type }}" + echo "[DEBUG] - stability: ${{ inputs.stability }}" - if [ -z "${{ inputs.distrib }}" ]; then - echo "distrib is required" + # Make sure all required inputs are NOT empty + if [[ -z "${{ inputs.module_name }}" || -z "${{ inputs.distrib }}" || -z ${{ inputs.stability }} || -z ${{ inputs.version }} || -z ${{ inputs.release_cloud }} || -z ${{ inputs.release_type }} ]]; then + echo "Some mandatory inputs are empty, please check the logs." exit 1 fi @@ -147,6 +160,12 @@ runs: echo "[DEBUG] - Version: $VERSION" - jf rt upload "$FILE" "apt-standard-${{ inputs.version }}-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH" + if [[ "${{ inputs.distrib }}" == "jammy" ]]; then + ROOT_REPO_PATH="ubuntu-standard-${{ inputs.version }}-${{ inputs.stability }}" + else + ROOT_REPO_PATH="apt-standard-${{ inputs.version }}-${{ inputs.stability }}" + fi + + jf rt upload "$FILE" "$ROOT_REPO_PATH/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH" done shell: bash diff --git a/.github/actions/promote-to-stable/action.yml b/.github/actions/promote-to-stable/action.yml index 21faf196312..0b7ce45c45b 100644 --- a/.github/actions/promote-to-stable/action.yml +++ b/.github/actions/promote-to-stable/action.yml @@ -19,9 +19,6 @@ inputs: stability: description: "The package stability (stable, testing, unstable)" required: true - repository_name: - description: "The repository name" - required: true github_ref_name: description: "Release base ref name for push event" required: true @@ -54,7 +51,7 @@ runs: # Cloud specific promote # delivery by default to onprem, override to internal if base branch is master - if [[ ${{ inputs.github_base_ref }} == "master" ]]; then + if [[ ${{ inputs.github_ref_name }} == "master" ]]; then ROOT_REPO_PATH="rpm-standard-internal" else ROOT_REPO_PATH="rpm-standard" @@ -94,8 +91,6 @@ runs: # Download candidates for promote echo "[DEBUG] - Promoting $ARCH testing artifacts to stable." for ARTIFACT in ${SRC_PATHS[@]}; do - echo "[DEBUG] - Promoting $ARTIFACT to stable on artifactory." - jf rt cp $ARTIFACT $TARGET_PATH --flat=true echo "[DEBUG] - Downloading $ARTIFACT from TESTING." jf rt download $ARTIFACT --flat done @@ -113,7 +108,7 @@ runs: shell: bash - name: Promote DEB packages to stable - if: ${{ contains(fromJSON('["bullseye", "bookworm"]') , inputs.distrib) }} + if: ${{ contains(fromJSON('["bullseye", "bookworm"]'), inputs.distrib) }} run: | set -eux @@ -121,8 +116,13 @@ runs: echo "[DEBUG] - Minor version: ${{ inputs.minor_version }}" echo "[DEBUG] - Distrib: ${{ inputs.distrib }}" + # Define ROOT_REPO_PATH for debian + # There is no cloud ROOT_REPO_PATH for debian, only onprem + # Should there be a need to deploy debian to cloud repositories, please use the same condition as RPM promotion + ROOT_REPO_PATH="apt-standard-${{ inputs.major_version }}" + echo "[DEBUG] - Get path of testing DEB packages to promote to stable." - SRC_PATHS=$(jf rt search --include-dirs apt-standard-${{ inputs.major_version }}-testing/pool/${{ inputs.module_name }}/*${{ inputs.major_version }}.${{ inputs.minor_version }}*${{ inputs.distrib }}*.deb | jq -r '.[].path') + SRC_PATHS=$(jf rt search --include-dirs "$ROOT_REPO_PATH-testing/pool/${{ inputs.module_name }}/*${{ inputs.distrib }}*.deb | jq -r '.[].path') if [[ ${SRC_PATHS[@]} ]]; then for SRC_PATH in ${SRC_PATHS[@]}; do @@ -134,7 +134,7 @@ runs: fi echo "[DEBUG] - Build target path." - TARGET_PATH="apt-standard-${{ inputs.major_version }}-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" + TARGET_PATH="$ROOT_REPO_PATH-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" echo "[DEBUG] - Target path: $TARGET_PATH" echo "[DEBUG] - Promoting DEB testing artifacts to stable." @@ -143,13 +143,8 @@ runs: jf rt download $ARTIFACT --flat done - for ARTIFACT_DL in $(dir|grep -E "*.deb"); do + for ARTIFACT_DL in $(dir -1|grep -E ".+${{ inputs.distrib }}.+\.deb"); do ARCH=$(echo $ARTIFACT_DL | cut -d '_' -f3 | cut -d '.' -f1) - DISTRIB=$(echo $ARTIFACT_DL | cut -d '_' -f2 | cut -d '-' -f2) - if [[ "${{ inputs.distrib }}" != "$DISTRIB" ]]; then - echo "::error::Distrib [$DISTRIB] from package does not match distrib [${{ inputs.distrib }}] from input, abort promotion." - exit 1 - fi echo "[DEBUG] - Promoting (upload) $ARTIFACT_DL to stable $TARGET_PATH." jf rt upload "$ARTIFACT_DL" "$TARGET_PATH" --deb "${{ inputs.distrib }}/main/$ARCH" --flat done diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml index 3b1f84a66cf..f527522462f 100644 --- a/.github/actions/release/action.yml +++ b/.github/actions/release/action.yml @@ -38,14 +38,17 @@ runs: declare -a PREVIOUS_STABLE_TAGS=() SCOPE_VERSION="COLLECT" MINOR_VERSION_FILE_PATH=".version" + RELEASE_CLOUD=0 # Get current stable branch name # If MASTER, use root .version # Else use branch name if [[ "${{ inputs.github_ref_name }}" == "master" ]]; then CURRENT_STABLE_BRANCH_MAJOR_VERSION=$(grep -E "MAJOR" .version | cut -d '=' -f2) + RELEASE_CLOUD=1 else CURRENT_STABLE_BRANCH_MAJOR_VERSION=$(echo ${{ inputs.github_ref_name }} | cut -d '.' -f1,2) + RELEASE_CLOUD=0 fi echo "Current stable branch major version: $CURRENT_STABLE_BRANCH_MAJOR_VERSION" @@ -54,10 +57,15 @@ runs: MAJOR_VERSION=$(grep -E "MAJOR" .version | cut -d '=' -f2) MINOR_VERSION=$(grep -E "MINOR" .version | cut -d '=' -f2) # Previous stable tags array - PREVIOUS_STABLE_TAGS+=($(git tag -l --sort=-version:refname "$component-$CURRENT_STABLE_BRANCH_MAJOR_VERSION*" | head -n 1)) + if [[ $RELEASE_CLOUD -eq 1 ]]; then + PREVIOUS_STABLE_TAGS+=($(git tag -l --sort=-version:refname "$component-$CURRENT_STABLE_BRANCH_MAJOR_VERSION.*-*" | head -n 1)) + else + PREVIOUS_STABLE_TAGS+=($(git tag -l --sort=-version:refname "$component-$CURRENT_STABLE_BRANCH_MAJOR_VERSION.*" | grep -E "$component-$CURRENT_STABLE_BRANCH_MAJOR_VERSION.[0-9]+$" | head -n 1)) + fi # New stable tags array TMP_STABLE_TAGS+=("$component-$MAJOR_VERSION.$MINOR_VERSION") done + echo "Previous releases were: ${PREVIOUS_STABLE_TAGS[*]}" echo "Temporary new releases are: ${TMP_STABLE_TAGS[*]}" # Building final NEW_STABLE_TAGS with the new version tags only @@ -96,11 +104,6 @@ runs: git config --global user.email "release@centreon.com" git config --global user.name "Centreon" - # Rebuild NEW_STABLE_TAGS as an array - for i in ${NEW_RELEASE_TAGS[@]}; do - NEW_RELEASE_TAGS+=("$i") - done - # Create release tags on git for each release components # Abort if no tags or existing tag echo "Creating release tags." @@ -149,6 +152,7 @@ runs: else echo "::error::Release tag $TAG was empty, exiting." exit 1 + fi done shell: bash env: diff --git a/.github/workflows/centreon-collect.yml b/.github/workflows/centreon-collect.yml index 35eefe4a388..bf2009f5ac2 100644 --- a/.github/workflows/centreon-collect.yml +++ b/.github/workflows/centreon-collect.yml @@ -182,7 +182,6 @@ jobs: major_version: ${{ needs.get-version.outputs.version }} minor_version: ${{ needs.get-version.outputs.patch }} stability: ${{ needs.get-version.outputs.stability }} - repository_name: standard github_ref_name: ${{ github.ref_name }} release_type: ${{ needs.get-version.outputs.release_type }} release_cloud: ${{ needs.get-version.outputs.release_cloud }} diff --git a/.github/workflows/libzmq.yml b/.github/workflows/libzmq.yml index bbaded08f75..34a651e66c8 100644 --- a/.github/workflows/libzmq.yml +++ b/.github/workflows/libzmq.yml @@ -209,7 +209,6 @@ jobs: major_version: ${{ needs.get-version.outputs.version }} minor_version: ${{ needs.get-version.outputs.patch }} stability: ${{ needs.get-version.outputs.stability }} - repository_name: standard github_ref_name: ${{ github.ref_name }} release_type: ${{ needs.get-version.outputs.release_type }} release_cloud: ${{ needs.get-version.outputs.release_cloud }}