Skip to content

Commit

Permalink
fix(ci): minor fixes to release pipelines 042024 (#1290)
Browse files Browse the repository at this point in the history
* fix(ci): minor fixes to release pipelines 042024

* fix(ci): remove unused input from collect and libzmq promote jobs

* improve error message
  • Loading branch information
tuntoja authored Apr 24, 2024
1 parent a39e9d3 commit 393ddf3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
47 changes: 27 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 @@ -102,7 +103,7 @@ runs:
if [[ ${{ inputs.release_cloud }} -eq 1 && ( ${{ inputs.release_type }} == "hotfix" || ${{ inputs.release_type }} == "release" ) ]]; then
echo "[DEBUG] : Release cloud + ${{ 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/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
Expand All @@ -118,7 +119,7 @@ runs:
# NOT VALID, DO NOT DELIVER
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 @@ -128,8 +129,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 @@ -141,13 +144,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 @@ -161,11 +168,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
5 changes: 1 addition & 4 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
36 changes: 30 additions & 6 deletions .github/actions/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@ runs:
# 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
Expand All @@ -49,14 +56,31 @@ runs:
# 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 Down
1 change: 0 additions & 1 deletion .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ jobs:
major_version: ${{ needs.get-version.outputs.version }}
minor_version: ${{ needs.get-version.outputs.patch }}
stability: ${{ needs.get-version.outputs.stability }}
repository_name: standard
github_ref_name: ${{ github.ref_name }}
release_type: ${{ needs.get-version.outputs.release_type }}
release_cloud: ${{ needs.get-version.outputs.release_cloud }}
1 change: 0 additions & 1 deletion .github/workflows/libzmq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ jobs:
major_version: ${{ needs.get-version.outputs.version }}
minor_version: ${{ needs.get-version.outputs.patch }}
stability: ${{ needs.get-version.outputs.stability }}
repository_name: standard
github_ref_name: ${{ github.ref_name }}
release_type: ${{ needs.get-version.outputs.release_type }}
release_cloud: ${{ needs.get-version.outputs.release_cloud }}

0 comments on commit 393ddf3

Please sign in to comment.