-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MON-52713 Centreon next 24.04 (Jira release #19809#) (#1277)
- Loading branch information
Showing
111 changed files
with
9,701 additions
and
8,837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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" | ||
|
@@ -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." | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.