Skip to content

Commit

Permalink
Merge branch 'dev-23.10.x' into MON-75562-ticket-duplication-dev-23.10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
sc979 committed May 28, 2024
2 parents 631fadb + 54e90c6 commit 38ea256
Show file tree
Hide file tree
Showing 28 changed files with 223 additions and 136 deletions.
37 changes: 24 additions & 13 deletions .github/actions/deb-delivery/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "deb-delivery"
description: "Package deb Centreon"
description: "Package deb packages"
inputs:
module_name:
description: "The package module name"
Expand All @@ -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 All @@ -19,6 +19,12 @@ inputs:
artifactory_token:
description: "Artifactory token"
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"
Expand All @@ -39,20 +45,25 @@ runs:
run: |
FILES="*.deb"
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
if [ "${{ inputs.stability }}" == "pkgtest" ]; then
ROOT_REPO_PATH="installers"
jf rt upload "*.deb" "$ROOT_REPO_PATH/${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}/" --flat
exit 0
# Handle either standard debian or ubuntu repository path
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
for FILE in $FILES; do
Expand All @@ -64,6 +75,6 @@ runs:
echo "[DEBUG] - Version: $VERSION"
jf rt upload "$FILE" "apt-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" --flat
done
shell: bash
2 changes: 1 addition & 1 deletion .github/actions/gherkin-lint/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: gherkin-lint
description: linter dedicated to gherkin files
description: Gherkin linter

inputs:
features_path:
Expand Down
35 changes: 26 additions & 9 deletions .github/actions/promote-to-stable/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,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 @@ -116,8 +116,21 @@ 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 }}/*${{ inputs.major_version }}.${{ inputs.minor_version }}*${{ inputs.distrib }}*.deb | jq -r '.[].path')
case "${{ inputs.major_version }}" in
"22.10"|"23.04"|"23.10")
SRC_PATHS=$(jf rt search --include-dirs $ROOT_REPO_PATH-testing/pool/${{ inputs.module }}/*.deb | jq -r '.[].path')
;;
*)
SRC_PATHS=$(jf rt search --include-dirs $ROOT_REPO_PATH-testing/pool/${{ inputs.module }}/*${{ inputs.distrib }}*.deb | jq -r '.[].path')
;;
esac
if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
Expand All @@ -129,7 +142,7 @@ runs:
fi
echo "[DEBUG] - Build target path."
TARGET_PATH="apt-standard-${{ inputs.major_version }}-${{ inputs.stability }}/pool/${{ inputs.module }}/"
TARGET_PATH="$ROOT_REPO_PATH-${{ inputs.stability }}/pool/${{ inputs.module }}/"
echo "[DEBUG] - Target path: $TARGET_PATH"
echo "[DEBUG] - Promoting DEB testing artifacts to stable."
Expand All @@ -138,13 +151,17 @@ runs:
jf rt download $ARTIFACT --flat
done
for ARTIFACT_DL in $(dir|grep -E "*.deb"); do
case "${{ inputs.major_version }}" in
"22.10"|"23.04"|"23.10")
ARTIFACT_SEARCH_PATTERN=".+\.deb"
;;
*)
ARTIFACT_SEARCH_PATTERN=".+${{ inputs.distrib }}.+\.deb"
;;
esac
for ARTIFACT_DL in $(dir -1|grep -E $ARTIFACT_SEARCH_PATTERN); 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, aborting 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
Expand Down
137 changes: 71 additions & 66 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,24 +28,26 @@ runs:

- name: Get released versions for components
run: |
set -eu
set -eux
# Variables
COMPONENTS_OSS=("centreon-awie" "centreon-dsm" "centreon-gorgone" "centreon-ha" "centreon-open-tickets" "centreon-web")
CURRENT_STABLE_BRANCH_MAJOR_VERSION=""
declare -a TMP_STABLE_TAGS=()
declare -a NEW_STABLE_TAGS=()
declare -a PREVIOUS_STABLE_TAGS=()
SCOPE_VERSION="OSS"
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"
Expand All @@ -56,33 +61,21 @@ runs:
MAJOR_VERSION=$(grep -E "MAJOR" .version | cut -d '=' -f2)
MINOR_VERSION=$(grep -E "MINOR" $COMPONENT_DIR/.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")
NEW_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
# 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
echo "New releases are: ${NEW_STABLE_TAGS[*]}"
echo "New tags to be published from new release that were not in previous releases:"
printf '%s\n' "${NEW_STABLE_TAGS[@]}"
# 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 ?
# Make NEW_STABLE_TAGS available for other steps
echo "NEW_STABLE_TAGS=${NEW_STABLE_TAGS[*]}" >> "$GITHUB_ENV"
Expand All @@ -92,20 +85,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 "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."
for TAG in ${NEW_STABLE_TAGS[@]}; do
if [ -z $(git tag --list "$TAG" | head -n 1) ]; then
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 @@ -118,6 +109,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 @@ -132,33 +125,34 @@ runs:
echo "GH CLI is already installed."
fi
# Rebuild NEW_STABLE_TAGS as an array
# for i in ${NEW_STABLE_TAGS[@]}; do
# NEW_RELEASE_TAGS+=("$i")
# done
# Create GITHUB release for each release components
# Abort if no tags
echo "Creating GITHUB releases."
for TAG in ${NEW_STABLE_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
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 }}"
# Rebuild NEW_STABLE_TAGS as an array
# for i in ${NEW_STABLE_TAGS[@]}; do
# NEW_RELEASE_TAGS+=("$i")
# done
for i in ${NEW_STABLE_TAGS[@]}; do
NEW_RELEASE_TAGS+=("$i")
done
# Create new JIRA versions (old way of doing it)
# TODO: add a future capacity to determine whether the release is hotfix or standard (using TYPE)
Expand All @@ -171,45 +165,56 @@ runs:
JIRA_RELEASE_NAME=""
JIRA_PROJECT_ID="${{ inputs.jira_project_id }}"
JIRA_RELEASE_RELEASED="false"
# Create JIRA version for each released component
echo "Creating JIRA releases."
for TAG in ${NEW_STABLE_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
# for i in ${NEW_STABLE_TAGS[@]}; do
# NEW_RELEASE_TAGS+=("$i")
# done
# Rebuild NEW_STABLE_TAGS as an array (required to build a proper json)
for i in ${NEW_STABLE_TAGS[@]}; do
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
JSON_TAGS=$(jq -n '{componentList:$ARGS.positional}' --args "${NEW_STABLE_TAGS[@]}")
JSON_TAGS=$(jq -n '{componentList:$ARGS.positional}' --args "${NEW_RELEASE_TAGS[@]}")
JSON_VERSION_INFO=$(jq -n --arg majorVersion "$MAJOR_VERSION" --arg scopeVersion "$SCOPE_VERSION" '$ARGS.named' )
RELEASE_JSON=$(echo "$JSON_VERSION_INFO" | jq -c --argjson json_tags "$JSON_TAGS" '. += $json_tags')
Expand Down
Loading

0 comments on commit 38ea256

Please sign in to comment.