Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(chore): package perl dependencies (cpan / net-curl / libssh-session ...) #4755

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
864edf3
fix(chore): Move the perl dependencies to the plugins' repos
hamzabessa Nov 30, 2023
f46a96b
fix: deleting get-version file
hamzabessa Nov 30, 2023
42afd2d
fix: perl's workflow files
hamzabessa Nov 30, 2023
3d0508b
fix: deliver jobs in perl's workflow files
hamzabessa Nov 30, 2023
5e5ee10
fix: linting and deleting comments
hamzabessa Nov 30, 2023
13f4579
fix: add package-nfm action
hamzabessa Nov 30, 2023
32c0272
fix: docker container image
hamzabessa Nov 30, 2023
611e755
fix: docker image container
hamzabessa Nov 30, 2023
bb21252
fix: image container
hamzabessa Nov 30, 2023
41d1204
fix: container image
hamzabessa Nov 30, 2023
90fe42b
fix: image in certain workflows
hamzabessa Nov 30, 2023
550e903
fix: container image for deb packaging in certain files
hamzabessa Nov 30, 2023
2eb2f8f
fix: add bullseye-arm64 image
hamzabessa Nov 30, 2023
e8daf4d
fix: add new docker image
hamzabessa Nov 30, 2023
aa4ed79
fix: includes in docker workflow
hamzabessa Nov 30, 2023
3e76f96
fix: runner in docker builder for each distrib
hamzabessa Nov 30, 2023
ff3dd26
refactor: includes and path vars in docker packaging workflow
hamzabessa Nov 30, 2023
bb7fc4b
fix: add promote action and restore the job in all perl files
hamzabessa Nov 30, 2023
99cde30
fix: lenting
hamzabessa Nov 30, 2023
1f7b1f6
fix: promote job in dependecie files
hamzabessa Dec 1, 2023
1fa4152
fix: update perl-libssh-session packaging
hamzabessa Dec 1, 2023
4cb662a
fix: missing distrib in promote job
hamzabessa Dec 1, 2023
ce786f2
fix: runs and and paths
hamzabessa Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions .github/actions/package-nfpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: package-nfpm
description: Package module using nfpm
inputs:
nfpm_file_pattern:
description: The pattern of the nfpm configuration file(s)
required: true
package_extension:
description: The package extension (deb or rpm)
required: true
distrib:
description: The package distrib
required: true
major_version:
description: The major version
required: false
minor_version:
description: The minor version
required: false
release:
description: The package release number
required: false
arch:
description: The package architecture
required: false
commit_hash:
description: The commit hash
required: true
cache_key:
description: The package files cache key
required: true
rpm_gpg_key:
description: The rpm gpg key
required: true
rpm_gpg_signing_key_id:
description: The rpm gpg signing key identifier
required: true
rpm_gpg_signing_passphrase:
description: The rpm gpg signing passphrase
required: true

runs:
using: composite

steps:
- name: Import gpg key
env:
RPM_GPG_SIGNING_KEY: ${{ inputs.rpm_gpg_key }}
run: echo -n "$RPM_GPG_SIGNING_KEY" > key.gpg
shell: bash

- name: Build ${{ inputs.package_extension }} files
env:
RPM_GPG_SIGNING_KEY_ID: ${{ inputs.rpm_gpg_signing_key_id }}
RPM_GPG_SIGNING_PASSPHRASE: ${{ inputs.rpm_gpg_signing_passphrase }}
run: |
export MAJOR_VERSION="${{ inputs.major_version }}"
export VERSION="${{ inputs.major_version }}.${{ inputs.minor_version }}"
export RELEASE="${{ inputs.release }}"
export ARCH="${{ inputs.arch }}"

if [ "${{ inputs.package_extension }}" = "rpm" ]; then
export DIST=".${{ inputs.distrib }}"
export APACHE_USER="apache"
export APACHE_GROUP="apache"
else
export DIST=""
export APACHE_USER="www-data"
export APACHE_GROUP="www-data"
fi

MAJOR_LEFT=$( echo $MAJOR_VERSION | cut -d "." -f1 )
MAJOR_RIGHT=$( echo $MAJOR_VERSION | cut -d "-" -f1 | cut -d "." -f2 )
BUMP_MAJOR_RIGHT=$(( MAJOR_RIGHT_PART + 1 ))
if [ "$MAJOR_RIGHT" = "04" ]; then
BUMP_MAJOR_LEFT="$MAJOR_LEFT"
BUMP_MAJOR_RIGHT="10"
else
BUMP_MAJOR_LEFT=$(( $MAJOR_LEFT + 1 ))
BUMP_MAJOR_RIGHT="04"
fi

export NEXT_MAJOR_VERSION="$BUMP_MAJOR_LEFT.$BUMP_MAJOR_RIGHT"

export RPM_SIGNING_KEY_FILE="$(pwd)/key.gpg"
export RPM_SIGNING_KEY_ID="$RPM_GPG_SIGNING_KEY_ID"
export NFPM_RPM_PASSPHRASE="$RPM_GPG_SIGNING_PASSPHRASE"

for FILE in ${{ inputs.nfpm_file_pattern }}; do
DIRNAME=$(dirname $FILE)
BASENAME=$(basename $FILE)
cd $DIRNAME
sed -i "s/@APACHE_USER@/$APACHE_USER/g" $BASENAME
sed -i "s/@APACHE_GROUP@/$APACHE_GROUP/g" $BASENAME
sed -i "s/@COMMIT_HASH@/${{ inputs.commit_hash }}/g" $BASENAME
nfpm package --config $BASENAME --packager ${{ inputs.package_extension }}
cd -
mv $DIRNAME/*.${{ inputs.package_extension }} ./
done
shell: bash

- name: Cache packages
uses: actions/cache/save@v3
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}

# Update if condition to true to get packages as artifacts
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@v3
with:
name: packages-${{ inputs.distrib }}
path: ./*.${{ inputs.package_extension}}
retention-days: 1
85 changes: 85 additions & 0 deletions .github/actions/promote-to-stable/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: "promote testing to stable"
description: "Promote testing packages to stable."
inputs:
artifactory_token:
description: "Artifactory token"
required: true
module:
description: "Module"
required: true
distrib:
description: "The distribution used for packaging"
required: true
stability:
description: "The package stability (stable, testing, unstable)"
required: true

runs:
using: "composite"
steps:
- uses: jfrog/setup-jfrog-cli@v3
env:
JF_URL: https://centreon.jfrog.io
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }}

- name: Promote RPM packages to stable
if: ${{ startsWith(inputs.distrib, 'el') }}
run: |
set -x
echo "[DEBUG] - Distrib: ${{ inputs.distrib }}"

for ARCH in "noarch" "x86_64"; do
echo "[DEBUG] - Get path of $ARCH testing artifacts to promote to stable."
SRC_PATHS=$(jf rt s --include-dirs rpm-plugins/${{ inputs.distrib }}/testing/$ARCH/${{ inputs.module }}/*.rpm | jq -r '.[].path')

if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
echo "[DEBUG] - Source path found: $SRC_PATH"
done
else
echo "[DEBUG] - No source path found."
continue
fi


echo "[DEBUG] - Build $ARCH target path."
TARGET_PATH="rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module }}/"
echo "[DEBUG] - Target path: $TARGET_PATH"

echo "[DEBUG] - Promoting $ARCH testing artifacts to stable."
for ARTIFACT in ${SRC_PATHS[@]}; do
echo "[DEBUG] - Promoting $ARTIFACT to stable."
jf rt cp $ARTIFACT $TARGET_PATH --flat=true
done
done

shell: bash

- name: Promote DEB package to stable
if: ${{ startsWith(inputs.distrib, 'bullseye') }}
run: |
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-plugins-stable-testing/pool/${{ inputs.module }}/*.deb | jq -r '.[].path')
hamzabessa marked this conversation as resolved.
Show resolved Hide resolved

if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
echo "[DEBUG] - Source path found: $SRC_PATH"
done
else
echo "[DEBUG] - No source path found."
continue
fi

echo "[DEBUG] - Build target path."
TARGET_PATH="apt-plugins-stable-${{ inputs.stability }}/pool/${{ inputs.module }}/"
hamzabessa marked this conversation as resolved.
Show resolved Hide resolved
echo "[DEBUG] - Target path: $TARGET_PATH"

echo "[DEBUG] - Promoting DEB testing artifacts to stable."
for ARTIFACT in ${SRC_PATHS[@]}; do
echo "[DEBUG] - Promoting $ARTIFACT to stable."
jf rt cp $ARTIFACT $TARGET_PATH --flat=true
done

shell: bash
26 changes: 20 additions & 6 deletions .github/workflows/docker-builder-packaging-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,27 @@ on:

jobs:
create-and-push-docker:
runs-on: ubuntu-22.04

strategy:
matrix:
distrib: [centos7, alma8, alma9, bullseye]
include:
- project: plugins
- runner: ubuntu-22.04
dockerfile: packaging-plugins-centos7
image: packaging-plugins-centos7
- runner: ubuntu-22.04
dockerfile: packaging-plugins-alma8
image: packaging-plugins-alma8
- runner: ubuntu-22.04
dockerfile: packaging-plugins-alma9
image: packaging-plugins-alma9
- runner: ubuntu-22.04
dockerfile: packaging-plugins-bullseye
image: packaging-plugins-bullseye
- runner: ["self-hosted", "collect-arm64"]
dockerfile: packaging-plugins-bullseye
image: packaging-plugins-bullseye-arm64

runs-on: ${{ matrix.runner }}

steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -48,9 +62,9 @@ jobs:

- uses: docker/build-push-action@v3
with:
file: .github/docker/Dockerfile.packaging-${{ matrix.project }}-${{ matrix.distrib }}
file: .github/docker/Dockerfile.${{ matrix.dockerfile }}
context: .
build-args: "REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
pull: true
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/packaging-${{ matrix.project }}-${{ matrix.distrib }}:latest
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
Loading
Loading