fix(delivery): restore release with timestamp/hash on unstable (#4302)

This commit is contained in:
Kevin Duret 2023-03-24 10:58:00 +01:00 committed by David Boucher
parent 40b92d6381
commit 1f93301c8a
4 changed files with 41 additions and 40 deletions

View File

@ -10,12 +10,6 @@ inputs:
nexus_password:
description: The nexus password
required: true
version:
description: "Centreon packaged version"
required: true
release:
description: The release number
required: true
cache_key:
description: "The cached package key"
required: true

View File

@ -1,15 +1,12 @@
name: "rpm-delivery"
description: "rpm delivery"
inputs:
module_name:
description: "The package module name"
required: true
distrib:
description: "The distribution used for packaging"
required: true
version:
description: "Centreon packaged version"
required: true
release:
description: The release number
required: true
cache_key:
description: "The cached package key"
required: true
@ -51,7 +48,41 @@ runs:
- name: Publish RPMs to plugins repository
run: |
jf rt upload "*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/noarch/"
FILES="*.rpm"
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
mkdir noarch x86_64
for FILE in $FILES; do
echo "[DEBUG] - File: $FILE"
ARCH=$(echo $FILE | grep -oP '(x86_64|noarch)')
echo "[DEBUG] - Arch: $ARCH"
cp "$FILE" "$ARCH"
done
for ARCH in "noarch" "x86_64"; do
if [ "$(ls -A $ARCH)" ]; then
if [ "${{ inputs.stability }}" == "stable" ]; then
jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/" --flat
else
jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --flat
fi
fi
done
shell: bash
- name: Setup awscli
@ -65,10 +96,7 @@ runs:
run: |
FILES="*.rpm"
VERSION="${{ inputs.version }}"
RELEASE="${{ inputs.release }}"
REPOTYPE="${{ inputs.stability }}"
PROJECT="plugins"
PROJECT_PATH="standard"
DISTRIB="${{ inputs.distrib }}"
ARCH="noarch"
@ -82,24 +110,16 @@ runs:
if [ "$REPOTYPE" == "stable" ]; then
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/RPMS"
else
FOLDER="centreon-$PROJECT-$VERSION-$RELEASE"
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/$PROJECT/$FOLDER"
PROJECT_LOCATION="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/$PROJECT"
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}"
PROJECT_LOCATION="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}"
fi
echo "[DEBUG] - Folder: $FOLDER"
echo "[DEBUG] - Project : $PROJECT"
echo "[DEBUG] - Target : $TARGET"
echo "[DEBUG] - PROJECT_LOCATION : $PROJECT_LOCATION"
ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" mkdir -p "$TARGET"
scp -o StrictHostKeyChecking=no ./*.rpm "${{ inputs.yum_repo_address }}:$TARGET"
# Cleanup is done on unstable repository only
#if [ "$REPOTYPE" == "unstable" ]; then
# ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "ls -drc $PROJECT_LOCATION/* 2>&- | head -n -1 | xargs rm -rf"
#fi
# Update repository metadata
METADATAS="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH"
ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "sh "${{ inputs.update_repo_path }}" $METADATAS" 2>&-

View File

@ -1,14 +1,6 @@
on:
workflow_call:
inputs:
version:
description: "Plugins version"
type: string
required: true
release:
description: The release number
type: string
required: true
stability:
description: The package stability (stable, testing, unstable)
type: string
@ -48,9 +40,8 @@ jobs:
- name: Delivery
uses: ./.github/actions/rpm-delivery
with:
module_name: plugins
distrib: ${{ matrix.distrib }}
version: ${{ inputs.version }}
release: ${{ inputs.release }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
update_repo_path: ${{ secrets.update_repo_path }}
cloudfront_id: ${{ secrets.cloudfront_id }}
@ -73,8 +64,6 @@ jobs:
uses: ./.github/actions/deb-delivery
with:
distrib: ${{ matrix.distrib }}
version: ${{ inputs.version }}
release: ${{ inputs.release }}
nexus_username: ${{ secrets.nexus_username }}
nexus_password: ${{ secrets.nexus_password }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}

View File

@ -103,8 +103,6 @@ jobs:
if: ${{ contains(fromJson('["stable", "testing", "unstable"]'), needs.get-environment.outputs.stability) }}
uses: ./.github/workflows/plugin-delivery.yml
with:
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
stability: ${{ needs.get-environment.outputs.stability }}
secrets:
nexus_username: ${{ secrets.NEXUS_USERNAME }}