Skip to content

Commit

Permalink
MON-52713 Centreon next 24.04 (Jira release #19809#) (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkippes authored Apr 30, 2024
2 parents fca9a28 + 3991899 commit 20cd46d
Show file tree
Hide file tree
Showing 111 changed files with 9,701 additions and 8,837 deletions.
54 changes: 34 additions & 20 deletions .github/actions/delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -59,16 +59,17 @@ runs:
FILES="*.${{ env.extfile }}"
# 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.module_name }}" ]; then
echo "module name is required"
exit 1
fi
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
Expand Down Expand Up @@ -99,13 +100,20 @@ runs:
# 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
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 }}/"
# 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/${{ inputs.module_name }}/"
# NON-CLOUD + (HOTFIX OR RELEASE) + REPO STANDARD
elif [[ ${{ inputs.release_cloud }} -eq 0 ]]; then
ROOT_REPO_PATHS="rpm-standard"
UPLOAD_REPO_PATH="${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/"
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
Expand All @@ -115,8 +123,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
Expand All @@ -128,13 +138,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
Expand All @@ -148,11 +162,11 @@ runs:
echo "[DEBUG] - Version: $VERSION"
if [[ "${{ inputs.distrib }}" == "jammy" ]]; then
REPO_PREFIX="ubuntu"
ROOT_REPO_PATH="ubuntu-standard-${{ inputs.version }}-${{ inputs.stability }}"
else
REPO_PREFIX="apt"
ROOT_REPO_PATH="apt-standard-${{ inputs.version }}-${{ inputs.stability }}"
fi
jf rt upload "$FILE" "${REPO_PREFIX}-standard-${{ inputs.version }}-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH"
jf rt upload "$FILE" "$ROOT_REPO_PATH/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH"
done
shell: bash
11 changes: 5 additions & 6 deletions .github/actions/promote-to-stable/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -113,12 +110,14 @@ runs:
- name: Promote DEB packages to stable
if: ${{ contains(fromJSON('["bullseye", "bookworm"]'), inputs.distrib) }}
run: |
set -eux
echo "[DEBUG] - Major version: ${{ inputs.major_version }}"
echo "[DEBUG] - Minor version: ${{ inputs.minor_version }}"
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 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')
if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
Expand All @@ -139,7 +138,7 @@ 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)
echo "[DEBUG] - Promoting (upload) $ARTIFACT_DL to stable $TARGET_PATH."
jf rt upload "$ARTIFACT_DL" "$TARGET_PATH" --deb "${{ inputs.distrib }}/main/$ARCH" --flat
Expand Down
131 changes: 87 additions & 44 deletions .github/actions/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
jira_webhook_url:
description: "Jira release webhook"
required: true
jira_base_url:
description: "Jira base url"
required: true

runs:
using: "composite"
Expand All @@ -25,40 +28,59 @@ runs:

- name: Get released versions for components
run: |
set -eu
set -eux
# Variables
COMPONENTS_COLLECT=("centreon-collect")
CURRENT_STABLE_BRANCH_MAJOR_VERSION=""
declare -a TMP_STABLE_TAGS=()
declare -a NEW_STABLE_TAGS=()
declare -a PREVIOUS_STABLE_TAGS=()
SCOPE_VERSION="COLLECT"
MINOR_VERSION_FILE_PATH=".version"
# Get current stable branch name
CURRENT_STABLE_BRANCH_MAJOR_VERSION=$(echo ${{ inputs.github_ref_name }} | cut -d '.' -f1,2)
# 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)
else
CURRENT_STABLE_BRANCH_MAJOR_VERSION=$(echo ${{ inputs.github_ref_name }} | cut -d '.' -f1,2)
fi
echo "Current stable branch major version: $CURRENT_STABLE_BRANCH_MAJOR_VERSION"
# Get previous and new version tags for components
for component in ${COMPONENTS_COLLECT[@]}; do
if [[ $component == "centreon-web" ]]; then
COMPONENT_DIR="centreon"
else
COMPONENT_DIR=$component
fi
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))
# New stable tags array
NEW_STABLE_TAGS+=("$component-$MAJOR_VERSION.$MINOR_VERSION")
TMP_STABLE_TAGS+=("$component-$MAJOR_VERSION.$MINOR_VERSION")
done
echo "Previous releases were: ${PREVIOUS_STABLE_TAGS[*]}"
echo "New releases are: ${NEW_STABLE_TAGS[*]}"
echo "Temporary new releases are: ${TMP_STABLE_TAGS[*]}"
# Building final NEW_STABLE_TAGS with the new version tags only
# Iterate over elements of TMP_STABLE_TAGS
for new_tag in "${TMP_STABLE_TAGS[@]}"; do
found=false
# Iterate over elements of PREVIOUS_STABLE_TAGS
for old_tag in "${PREVIOUS_STABLE_TAGS[@]}"; do
# Compare elements
if [ "$new_tag" == "$old_tag" ]; then
found=true
break
fi
done
# If element not found in PREVIOUS_STABLE_TAGS, add it to NEW_STABLE_TAGS
if ! $found; then
NEW_STABLE_TAGS+=("$new_tag")
fi
done
# TODO: Check that NEW_STABLE_TAGS are fully different from PREVIOUS_STABLE_TAGS
# re use the part from check version ??
# or use the check-version action after turning this release action into a real workflow ?
echo "New tags to be published from new release that were not in previous releases:"
printf '%s\n' "${NEW_STABLE_TAGS[@]}"
# Make NEW_STABLE_TAGS available for other steps
echo "NEW_STABLE_TAGS=${NEW_STABLE_TAGS[*]}" >> "$GITHUB_ENV"
Expand All @@ -68,20 +90,18 @@ runs:

- name: Add new release tags to stable branch
run: |
set -eux
# Add new stable tags to stable branch
echo "Configuring git."
git config --global user.email "[email protected]"
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."
for TAG in ${NEW_RELEASE_TAGS[@]}; do
if [ -z $(git tag --list "$TAG" | head -n 1) ]; then
for TAG in ${NEW_STABLE_TAGS[@]}; do
if [ -z $(git tag --list "$TAG" | head -n 1) ] && [ -n $TAG ]; then
git tag -a "$TAG" -m "$TAG"
git push --follow-tags
echo "::notice::Tagging stable branch with $TAG."
Expand All @@ -94,6 +114,8 @@ runs:

- name: Create GITHUB releases from new release tags
run: |
set -eux
# Install gh cli
echo "Installing GH CLI."
if ! command -v gh &> /dev/null; then
Expand All @@ -114,18 +136,28 @@ runs:
done
# Create GITHUB release for each release components
# Abort if no tags
echo "Creating GITHUB releases."
for TAG in ${NEW_RELEASE_TAGS[@]}; do
echo "Creating GITHUB release with title $TAG for tag $TAG."
gh release create $TAG --target "${{ inputs.github_ref_name }}" --title "$TAG" --verify-tag
for TAG in ${NEW_STABLE_TAGS[@]}; do
if [ -n $TAG ]; then
echo "Creating GITHUB release with title $TAG for tag $TAG."
gh release create $TAG --target "${{ inputs.github_ref_name }}" --title "$TAG" --verify-tag
else
echo "::error::Release tag $TAG was empty, exiting."
exit 1
fi
done
shell: bash
env:
GH_TOKEN: ${{ github.token }}

- name: Create stable JIRA versions from new release tags
run: |
set -eu
set -eux
# Call JIRA to provide new jira versions to create
# Webhook url
JIRA_INCOMING_WEBHOOK="${{ inputs.jira_webhook_url }}"
# Call JIRA to provide new jira versions to create
# Webhook url
Expand All @@ -151,38 +183,49 @@ runs:
# Create JIRA version for each released component
echo "Creating JIRA releases."
for TAG in ${NEW_RELEASE_TAGS[@]}; do
echo "::notice::Creating JIRA release $TAG based on git release tag $TAG."
# Build JSON with release information for JIRA API
JIRA_RELEASE_DATA=$(jq -nc \
--arg archived "$JIRA_RELEASE_ARCHIVED" \
--arg description "$TAG" \
--arg releaseDate "$JIRA_RELEASE_DATE" \
--arg name "$TAG" \
--arg projectId "$JIRA_PROJECT_ID" \
--arg released "$JIRA_RELEASE_RELEASED" \
'$ARGS.named' )
# Send to JIRA API release
echo "Sending to JIRA API release: $JIRA_RELEASE_DATA"
curl --fail --request POST \
--url 'https://centreon.atlassian.net/rest/api/3/version' \
--user '${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data "$JIRA_RELEASE_DATA"
if [ -n $TAG ]; then
echo "::notice::Creating JIRA release $TAG based on git release tag $TAG."
# Build JSON with release information for JIRA API
JIRA_RELEASE_DATA=$(jq -nc \
--arg archived "$JIRA_RELEASE_ARCHIVED" \
--arg description "$TAG" \
--arg releaseDate "$JIRA_RELEASE_DATE" \
--arg name "$TAG" \
--arg projectId "$JIRA_PROJECT_ID" \
--arg released "$JIRA_RELEASE_RELEASED" \
'$ARGS.named' )
# Send to JIRA API release
echo "Sending to JIRA API release: $JIRA_RELEASE_DATA"
curl --fail --request POST \
--url 'https://${{ inputs.jira_base_url }}/rest/api/3/version' \
--user '${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data "$JIRA_RELEASE_DATA"
else
echo "::error::Release tag $TAG was empty, exiting."
exit 1
fi
done
shell: bash

- name: Trigger release communication for new releases
run: |
set -eu
set -eux
MAJOR_VERSION=$CURRENT_STABLE_BRANCH_MAJOR_VERSION
# Webhook url
JIRA_INCOMING_WEBHOOK="${{ inputs.jira_webhook_url }}"
# Rebuild NEW_STABLE_TAGS as an array
# Rebuild NEW_STABLE_TAGS as an array (required to build a proper json)
for i in ${NEW_STABLE_TAGS[@]}; do
NEW_RELEASE_TAGS+=("$i")
if [ -n "$i" ]; then
NEW_RELEASE_TAGS+=("$i")
else
echo "::error::Release tag $i was empty, exiting."
exit 1
fi
done
# Build JSON structure with released versions
Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-alma8
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dnf install -y cmake \
rrdtool-devel \
selinux-policy-devel \
yum-utils \
perl \
perl-interpreter \
zstd \
nfpm \
openssl-devel \
Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-alma9
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dnf --best install -y cmake \
rrdtool-devel \
selinux-policy-devel \
yum-utils \
perl \
perl-interpreter \
procps-ng \
zstd \
nfpm \
Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-alma9-test
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dnf --best install -y \
python3-pip \
perl-Thread-Queue \
rrdtool \
perl \
perl-interpreter \
procps-ng \
zstd \
psmisc \
Expand Down
Loading

0 comments on commit 20cd46d

Please sign in to comment.