diff --git a/.github/actions/delivery/action.yml b/.github/actions/delivery/action.yml index 66ed19e6db8..016cecced2a 100644 --- a/.github/actions/delivery/action.yml +++ b/.github/actions/delivery/action.yml @@ -19,6 +19,12 @@ inputs: stability: description: "The package stability (stable, testing, unstable)" required: true + release_type: + description: "Type of release (hotfix, release)" + required: true + release_cloud: + description: "Release context (cloud or not cloud)" + required: true runs: using: "composite" @@ -49,6 +55,8 @@ runs: - if: ${{ env.extfile == 'rpm' }} name: Publish RPMs run: | + set -eux + FILES="*.${{ env.extfile }}" echo "[DEBUG] - Version: ${{ inputs.version }}" @@ -64,8 +72,17 @@ runs: 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 }}" + + # Create ARCH dirs mkdir noarch x86_64 + # Get ARCH target for files to deliver and regroupe them by ARCH for FILE in $FILES; do echo "[DEBUG] - File: $FILE" @@ -76,13 +93,27 @@ runs: mv "$FILE" "$ARCH" 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 [[ ${{ inputs.release_cloud }} -eq 1 && ${{ inputs.release_type }} == "hotfix" ]] || [[ ${{ inputs.release_cloud }} -eq 1 && ${{ inputs.release_type }} == "release" ]]; then + ROOT_REPO_PATH="rpm-standard-internal" + UPLOAD_REPO_PATH="${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}-${{ inputs.release_type }}/$ARCH/RPMS/${{ inputs.module_name }}/" + elif [[ ${{ inputs.release_cloud }} -eq 0 ]]; then + ROOT_REPO_PATH="rpm-standard" + UPLOAD_REPO_PATH="${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" + else + echo "Invalid combination of release_type and release_cloud" + fi + + # Deliver based on inputs for ROOT_REPO_PATH in "rpm-standard" "rpm-standard-internal"; do for ARCH in "noarch" "x86_64"; do if [ "$(ls -A $ARCH)" ]; then if [ "${{ inputs.stability }}" == "stable" ]; then - jf rt upload "$ARCH/*.rpm" "$ROOT_REPO_PATH/${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" --flat + echo "[DEBUG] - Stability is ${{ inputs.stability }}, not delivering." 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 + jf rt upload "$ARCH/*.rpm" "$ROOT_REPO_PATH/$UPLOAD_REPO_PATH" --flat fi fi done diff --git a/.github/actions/promote-to-stable/action.yml b/.github/actions/promote-to-stable/action.yml index dfb7f6af133..4e0b8e3e804 100644 --- a/.github/actions/promote-to-stable/action.yml +++ b/.github/actions/promote-to-stable/action.yml @@ -25,6 +25,12 @@ inputs: github_base_ref: description: "Release base ref" required: true + release_type: + description: "Type of release (hotfix, release)" + required: true + release_cloud: + description: "Release context (cloud or not cloud)" + required: true runs: using: "composite" @@ -37,10 +43,14 @@ runs: - name: Promote RPM packages to stable if: ${{ startsWith(inputs.distrib, 'el') }} run: | - set -x + set -eux + + # DEBUG echo "[DEBUG] - Major version: ${{ inputs.major_version }}" echo "[DEBUG] - Minor version: ${{ inputs.minor_version }}" echo "[DEBUG] - Distrib: ${{ inputs.distrib }}" + echo "[DEBUG] - release_cloud: ${{ inputs.release_cloud }}" + echo "[DEBUG] - release_type: ${{ inputs.release_type }}" # Cloud specific promote # delivery by default to onprem, override to internal if base branch is master @@ -50,9 +60,21 @@ runs: ROOT_REPO_PATH="rpm-standard" fi + # Build search path based on release_cloud and release_type values + # if cloud, search in testing- path + # if non-cloud, search in the testing usual path + if [[ ${{ inputs.release_cloud }} -eq 1 && ${{ inputs.release_type }} == "hotfix" ]] || [[ ${{ inputs.release_cloud }} -eq 1 && ${{ inputs.release_type }} == "release" ]];then + SEARCH_REPO_PATH="${{ inputs.major_version }}/${{ inputs.distrib }}/testing-${{ inputs.release_type }}/$ARCH/${{ inputs.module_name }}" + elif [[ ${{ inputs.release_cloud }} -eq 0 ]];then + SEARCH_REPO_PATH="${{ inputs.major_version }}/${{ inputs.distrib }}/testing/$ARCH/${{ inputs.module_name }}" + else + echo "Invalid combination of release_type and release_cloud" + fi + + # Search for testing packages candidate for promote for ARCH in "noarch" "x86_64"; do echo "[DEBUG] - Get artifactory path of $ARCH testing artifacts to promote to stable." - SRC_PATHS=$(jf rt s --include-dirs $ROOT_REPO_PATH/${{ inputs.major_version }}/${{ inputs.distrib }}/testing/$ARCH/${{ inputs.module_name }}/*.rpm | jq -r '.[].path') + SRC_PATHS=$(jf rt search --include-dirs $ROOT_REPO_PATH/$SEARCH_REPO_PATH/*.rpm | jq -r '.[].path') if [[ ${SRC_PATHS[@]} ]]; then for SRC_PATH in ${SRC_PATHS[@]}; do echo "[DEBUG] - Source path found: $SRC_PATH" @@ -61,18 +83,26 @@ runs: echo "[DEBUG] - No source path found." continue fi + + # Build target path based on ARCH echo "[DEBUG] - Build $ARCH artifactory target path." TARGET_PATH="$ROOT_REPO_PATH/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" echo "[DEBUG] - Target path: $TARGET_PATH" + + # Download candidates for promote echo "[DEBUG] - Promoting $ARCH testing artifacts to stable." for ARTIFACT in ${SRC_PATHS[@]}; do echo "[DEBUG] - Downloading $ARTIFACT from TESTING." jf rt download $ARTIFACT --flat done + + # Upload previously downloaded candidates to TARGET_PATH for ARTIFACT_DL in $(dir|grep -E "*.rpm"); do echo "[DEBUG] - Promoting (upload) $ARTIFACT_DL to stable $TARGET_PATH." jf rt upload "$ARTIFACT_DL" "$TARGET_PATH" --flat done + + # Cleanup before next round of candidates rm -f *.rpm done shell: bash @@ -85,7 +115,7 @@ runs: echo "[DEBUG] - Distrib: ${{ inputs.distrib }}" echo "[DEBUG] - Get path of testing DEB packages to promote to stable." - SRC_PATHS=$(jf rt s --include-dirs apt-standard-${{ inputs.major_version }}-testing/pool/${{ inputs.module_name }}/*.deb | jq -r '.[].path') + SRC_PATHS=$(jf rt s --include-dirs apt-standard-${{ inputs.major_version }}-testing/pool/${{ inputs.module_name }}/${{ inputs.release_type }}/*.deb | jq -r '.[].path') if [[ ${SRC_PATHS[@]} ]]; then for SRC_PATH in ${SRC_PATHS[@]}; do diff --git a/.github/workflows/centreon-collect.yml b/.github/workflows/centreon-collect.yml index 613f32897ff..20592f7c82d 100644 --- a/.github/workflows/centreon-collect.yml +++ b/.github/workflows/centreon-collect.yml @@ -145,6 +145,8 @@ jobs: artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} cache_key: ${{ github.run_id }}-${{ github.sha }}-rpm-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }} stability: ${{ needs.get-version.outputs.stability }} + release_type: ${{ needs.get-version.outputs.release_type }} + release_cloud: ${{ needs.get-version.outputs.release_cloud }} deliver-deb: if: ${{ contains(fromJson('["testing", "stable"]'), needs.get-version.outputs.stability) }} @@ -178,6 +180,8 @@ jobs: artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} cache_key: ${{ github.run_id }}-${{ github.sha }}-deb-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }} stability: ${{ needs.get-version.outputs.stability }} + release_type: ${{ needs.get-version.outputs.release_type }} + release_cloud: ${{ needs.get-version.outputs.release_cloud }} promote: needs: [get-version] @@ -202,3 +206,5 @@ jobs: stability: ${{ needs.get-version.outputs.stability }} repository_name: standard github_base_ref: ${{ github.base_ref }} + release_type: ${{ needs.get-version.outputs.release_type }} + release_cloud: ${{ needs.get-version.outputs.release_cloud }} diff --git a/.github/workflows/get-version.yml b/.github/workflows/get-version.yml index 1a84a666158..cc0a0f06a63 100644 --- a/.github/workflows/get-version.yml +++ b/.github/workflows/get-version.yml @@ -22,6 +22,12 @@ on: environment: description: "branch stability (stable, testing, unstable, canary)" value: ${{ jobs.get-version.outputs.environment }} + release_type: + description: "type of release (hotfix, release)" + value: ${{ jobs.get-version.outputs.release_type }} + release_cloud: + description: "context of release (cloud or not cloud)" + value: ${{ jobs.get-version.outputs.release_cloud }} jobs: get-version: @@ -34,6 +40,8 @@ jobs: release: ${{ steps.get_version.outputs.release }} stability: ${{ steps.get_version.outputs.stability }} environment: ${{ steps.get_version.outputs.env }} + release_type: ${{ steps.get_version.outputs.release_type }} + release_cloud: ${{ steps.get_version.outputs.release_cloud}} steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -55,6 +63,7 @@ jobs: - id: get_version run: | + set -x IMG_VERSION=$( cat `ls .github/docker/Dockerfile.centreon-collect-* | grep -v test` vcpkg.json | md5sum | awk '{print substr($1, 0, 8)}') TEST_IMG_VERSION=$(cat .github/docker/Dockerfile.centreon-collect-*-test .github/scripts/collect-prepare-test-robot.sh resources/*.sql | md5sum | cut -c1-8) VERSION=$(awk '$1 ~ "COLLECT_MAJOR" {maj=substr($2, 1, length($2)-1)} $1 ~ "COLLECT_MINOR" {min=substr($2, 1, length($2)-1) ; print maj "." min}' CMakeLists.txt) @@ -70,21 +79,41 @@ jobs: BRANCHNAME="$GITHUB_HEAD_REF" fi + echo "BRANCHNAME is: $BRANCHNAME" + + # Set default release values + GITHUB_RELEASE_CLOUD=0 + GITHUB_RELEASE_TYPE=$(echo $BRANCHNAME |cut -d '-' -f 1) + case "$BRANCHNAME" in master | [2-9][0-9].[0-9][0-9].x) echo "release=1" >> $GITHUB_OUTPUT ;; release* | hotfix*) - # Handle workflow_dispatch run triggers + # Handle workflow_dispatch run triggers and run a dispatch ONLY for cloud release GITHUB_RELEASE_BRANCH_BASE_REF_NAME="$(gh pr view $BRANCHNAME -q .baseRefName --json headRefName,baseRefName,state)" echo "GITHUB_RELEASE_BRANCH_BASE_REF_NAME is: $GITHUB_RELEASE_BRANCH_BASE_REF_NAME" GITHUB_RELEASE_BRANCH_PR_STATE="$(gh pr view $BRANCHNAME -q .state --json headRefName,baseRefName,state)" echo "GITHUB_RELEASE_BRANCH_PR_STATE is: $GITHUB_RELEASE_BRANCH_PR_STATE" + + # Check if the release context (cloud and hotfix or cloud and release) if [[ "$GITHUB_RELEASE_BRANCH_BASE_REF_NAME" == "master" ]] && [[ "$GITHUB_RELEASE_BRANCH_PR_STATE" == "OPEN" ]]; then - # This case is specific to cloud release - echo "release=`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT + # Get release pull request ID + GITHUB_RELEASE_BRANCH_PR_NUMBER="$(gh pr view $BRANCHNAME -q .[] --json number)" + # Set release cloud to 1 (0=not-cloud, 1=cloud) + GITHUB_RELEASE_CLOUD=1 + # Debug + echo "GITHUB_RELEASE_TYPE is: $GITHUB_RELEASE_TYPE" + echo "GITHUB_RELEASE_BRANCH_PR_NUMBER is: $GITHUB_RELEASE_BRANCH_PR_NUMBER" + echo "GITHUB_RELEASE_CLOUD is: $GITHUB_RELEASE_CLOUD" + # Github ouputs + echo "release=`echo $GITHUB_RELEASE_BRANCH_PR_NUMBER`.`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT + echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT + echo "release_cloud=$GITHUB_RELEASE_CLOUD" >> $GITHUB_OUTPUT else echo "release=1" >> $GITHUB_OUTPUT + echo "release_cloud=$GITHUB_RELEASE_CLOUD" >> $GITHUB_OUTPUT + echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT fi ;; *) diff --git a/.github/workflows/libzmq.yml b/.github/workflows/libzmq.yml index 4fa4309a73d..23d9157bdf5 100644 --- a/.github/workflows/libzmq.yml +++ b/.github/workflows/libzmq.yml @@ -164,6 +164,8 @@ jobs: artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} cache_key: ${{ github.run_id }}-${{ github.sha }}-rpm-libzmq-${{ matrix.distrib }}-${{ matrix.arch }} stability: ${{ needs.get-version.outputs.stability }} + release_type: ${{ needs.get-version.outputs.release_type }} + release_cloud: ${{ needs.get-version.outputs.release_cloud }} deliver-deb: if: ${{ contains(fromJson('["testing", "unstable"]'), needs.get-version.outputs.stability) }} @@ -197,6 +199,8 @@ jobs: artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} cache_key: ${{ github.run_id }}-${{ github.sha }}-deb-libzmq-${{ matrix.distrib }}-${{ matrix.arch }} stability: ${{ needs.get-version.outputs.stability }} + release_type: ${{ needs.get-version.outputs.release_type }} + release_cloud: ${{ needs.get-version.outputs.release_cloud }} promote: needs: [get-version] @@ -221,3 +225,5 @@ jobs: stability: ${{ needs.get-version.outputs.stability }} repository_name: standard github_base_ref: ${{ github.base_ref }} + release_type: ${{ needs.get-version.outputs.release_type }} + release_cloud: ${{ needs.get-version.outputs.release_cloud }} diff --git a/.github/workflows/robot-nightly.yml b/.github/workflows/robot-nightly.yml index d9346367c9e..9d5a35ef117 100644 --- a/.github/workflows/robot-nightly.yml +++ b/.github/workflows/robot-nightly.yml @@ -140,6 +140,8 @@ jobs: artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} cache_key: ${{ github.run_id }}-${{ github.sha }}-rpm-centreon-collect-${{ matrix.distrib }}-amd64-${{ github.head_ref || github.ref_name }} stability: ${{ needs.get-version.outputs.stability }} + release_type: ${{ needs.get-version.outputs.release_type }} + release_cloud: ${{ needs.get-version.outputs.release_cloud }} deliver-deb: if: ${{ contains(fromJson('["unstable"]'), needs.get-version.outputs.stability) }} @@ -171,3 +173,5 @@ jobs: artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} cache_key: ${{ github.run_id }}-${{ github.sha }}-deb-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }} stability: ${{ needs.get-version.outputs.stability }} + release_type: ${{ needs.get-version.outputs.release_type }} + release_cloud: ${{ needs.get-version.outputs.release_cloud }}