Skip to content

Commit

Permalink
fix(ci): minor fixes to promote and release actions (#1343)
Browse files Browse the repository at this point in the history
* fix(ci): minor fixes to promote and release actions

* sync delivery release and promote

* sync delivery release and promote

* remove unused input in workflows
  • Loading branch information
tuntoja authored May 21, 2024
1 parent 1987973 commit bb648a7
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 51 deletions.
75 changes: 47 additions & 28 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 @@ -37,7 +37,7 @@ runs:
- name: Build name for DEB
shell: bash
if: ${{ inputs.distrib == 'bullseye' }}
if: ${{ contains(fromJSON('["bullseye", "bookworm", "jammy"]'), inputs.distrib) }}
run: |
echo "extfile=deb" >> $GITHUB_ENV
Expand All @@ -59,25 +59,19 @@ runs:
FILES="*.${{ env.extfile }}"
echo "[DEBUG] - Version: ${{ inputs.version }}"
echo "[DEBUG] - Distrib: ${{ inputs.distrib }}"
if [ -z "${{ inputs.module_name }}" ]; then
echo "module name is required"
exit 1
fi
if [ -z "${{ inputs.distrib }}" ]; then
echo "distrib 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 }}"
# 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
# Create ARCH dirs
mkdir noarch x86_64
Expand All @@ -94,18 +88,31 @@ runs:
done
# 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 cloud + hotfix or cloud + release, deliver to internal testing-<release_type>
# if cloud + develop, delivery to internal unstable
# if non-cloud, delivery to onprem testing or unstable
# 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
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/${{ 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/RPMS/${{ inputs.module_name }}/"
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
echo "[DEBUG] : NOT Release cloud + ${{ inputs.release_type }}, using rpm-standard."
ROOT_REPO_PATHS="rpm-standard"
UPLOAD_REPO_PATH="${{ inputs.version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/"
# 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 @@ -115,8 +122,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 +137,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 @@ -147,6 +160,12 @@ runs:
echo "[DEBUG] - Version: $VERSION"
jf rt upload "$FILE" "apt-standard-${{ inputs.version }}-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH"
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
jf rt upload "$FILE" "$ROOT_REPO_PATH/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH"
done
shell: bash
25 changes: 10 additions & 15 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 @@ -94,8 +91,6 @@ runs:
# 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
Expand All @@ -113,16 +108,21 @@ runs:
shell: bash

- name: Promote DEB packages to stable
if: ${{ contains(fromJSON('["bullseye", "bookworm"]') , inputs.distrib) }}
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 }}"
# 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_name }}/*${{ inputs.major_version }}.${{ inputs.minor_version }}*${{ inputs.distrib }}*.deb | jq -r '.[].path')
SRC_PATHS=$(jf rt search --include-dirs "$ROOT_REPO_PATH-testing/pool/${{ inputs.module_name }}/*${{ inputs.distrib }}*.deb | jq -r '.[].path')
if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
Expand All @@ -134,7 +134,7 @@ runs:
fi
echo "[DEBUG] - Build target path."
TARGET_PATH="apt-standard-${{ inputs.major_version }}-${{ inputs.stability }}/pool/${{ inputs.module_name }}/"
TARGET_PATH="$ROOT_REPO_PATH-${{ inputs.stability }}/pool/${{ inputs.module_name }}/"
echo "[DEBUG] - Target path: $TARGET_PATH"
echo "[DEBUG] - Promoting DEB testing artifacts to stable."
Expand All @@ -143,13 +143,8 @@ 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)
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, abort 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
16 changes: 10 additions & 6 deletions .github/actions/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ runs:
declare -a PREVIOUS_STABLE_TAGS=()
SCOPE_VERSION="COLLECT"
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 @@ -54,10 +57,15 @@ runs:
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))
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")
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
Expand Down Expand Up @@ -96,11 +104,6 @@ runs:
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."
Expand Down Expand Up @@ -149,6 +152,7 @@ runs:
else
echo "::error::Release tag $TAG was empty, exiting."
exit 1
fi
done
shell: bash
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 @@ -182,7 +182,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 @@ -209,7 +209,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 bb648a7

Please sign in to comment.