Skip to content

Commit

Permalink
fix(ci): fix release workflow and action issues (#1223)
Browse files Browse the repository at this point in the history
* fix(ci): handle concurrent hotfix and release (#1191)

* fix(ci): handle concurrent hotfix and release

* fixed missing inputs in nightly and libzmq workflow

* Update action.yml

---------

Co-authored-by: May <110405507+paul-oureib@users.noreply.github.com>

* fix(delivery): fix missing inputs for rpm split delivery (#1195)

* fix(delivery): use root_repo_paths instead of fixed values (#1196)

* fix(ci): fix release workflow and action issues (#1214)

* fix(ci): fix release workflow and action issues

* use jira_base_url input

* fix

---------

Co-authored-by: May <110405507+paul-oureib@users.noreply.github.com>
  • Loading branch information
tuntoja and mushroomempires committed Mar 29, 2024
1 parent 78824af commit ce67fa6
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 43 deletions.
38 changes: 35 additions & 3 deletions .github/actions/delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -49,6 +55,8 @@ runs:
- if: ${{ startsWith(inputs.distrib, 'el') }}
name: Publish RPMs
run: |
set -eux
FILES="*.${{ env.extfile }}"
echo "[DEBUG] - Version: ${{ inputs.version }}"
Expand All @@ -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"
Expand All @@ -76,13 +93,28 @@ runs:
mv "$FILE" "$ARCH"
done
for ROOT_REPO_PATH in "rpm-standard" "rpm-standard-internal"; do
# Build upload target path based on release_cloud and release_type values
# if cloud, deliver to testing-<release_type>
# 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_PATHS="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_PATHS="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"
exit 1
fi
# Deliver based on inputs
for ROOT_REPO_PATH in "$ROOT_REPO_PATHS"; 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
Expand Down
50 changes: 44 additions & 6 deletions .github/actions/promote-to-stable/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ inputs:
repository_name:
description: "The repository name"
required: true
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"
Expand All @@ -34,14 +43,38 @@ 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
if [[ ${{ inputs.github_base_ref }} == "master" ]]; then
ROOT_REPO_PATH="rpm-standard-internal"
else
ROOT_REPO_PATH="rpm-standard"
fi
# Build search path based on release_cloud and release_type values
# if cloud, search in testing-<release_type> 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 rpm-standard/${{ 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"
Expand All @@ -50,23 +83,28 @@ runs:
echo "[DEBUG] - No source path found."
continue
fi
# Build target path based on ARCH
echo "[DEBUG] - Build $ARCH artifactory target path."
TARGET_PATH="rpm-standard/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/"
echo "[DEBUG] - Target path: $TARGET_PATH"
echo "[INFO] - Build INTERNAL $ARCH target path."
TARGET_PATH_INTERNAL="rpm-standard-internal/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/"
echo "[INFO] - Target internal path: $TARGET_PATH_INTERNAL"
# 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
# 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
Expand All @@ -79,7 +117,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
Expand Down
85 changes: 52 additions & 33 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,7 +28,7 @@ runs:

- name: Get released versions for components
run: |
set -eu
set -eux
# Variables
COMPONENTS_COLLECT=("centreon-collect")
Expand All @@ -41,11 +44,6 @@ runs:
# 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
Expand All @@ -68,6 +66,8 @@ 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"
Expand All @@ -79,9 +79,10 @@ runs:
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 +95,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 +117,23 @@ 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
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
Expand All @@ -151,38 +159,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
7 changes: 7 additions & 0 deletions .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ jobs:
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: cache-${{ github.sha }}-rpmbuild-centreon-collect-${{ matrix.distrib }}-${{ 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) }}
Expand All @@ -154,6 +156,8 @@ jobs:
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: cache-${{ github.sha }}-debbuild-centreon-collect-${{ matrix.distrib }}-${{ 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]
Expand All @@ -177,3 +181,6 @@ jobs:
minor_version: ${{ needs.get-version.outputs.patch }}
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 }}
Loading

0 comments on commit ce67fa6

Please sign in to comment.