140 lines
4.8 KiB
YAML
140 lines
4.8 KiB
YAML
on:
|
|
workflow_call:
|
|
inputs:
|
|
module_directory:
|
|
type: string
|
|
description: The module directory
|
|
required: true
|
|
nfpm_file_pattern:
|
|
type: string
|
|
description: The pattern of the nfpm configuration file(s)
|
|
required: true
|
|
distrib:
|
|
type: string
|
|
description: The distrib
|
|
required: true
|
|
package_extension:
|
|
type: string
|
|
description: The package extension (deb or rpm)
|
|
required: true
|
|
image_name:
|
|
type: string
|
|
description: The image name
|
|
required: true
|
|
version:
|
|
type: string
|
|
description: The package version
|
|
required: true
|
|
release:
|
|
type: string
|
|
description: The release number
|
|
required: true
|
|
cache_key:
|
|
type: string
|
|
description: The package files cache key
|
|
required: true
|
|
|
|
jobs:
|
|
package:
|
|
runs-on: ubuntu-22.04
|
|
container:
|
|
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image_name }}
|
|
credentials:
|
|
username: ${{ secrets.DOCKER_REGISTRY_ID }}
|
|
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
|
|
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Replace git sources by encoded files
|
|
if: "${{ inputs.encode_cache_key != '' }}"
|
|
run: |
|
|
rm -rf ${{ inputs.module_directory }}
|
|
tar zxf ${{ inputs.module_directory }}-${{ inputs.major_version }}.${{ inputs.minor_version }}.tar.gz
|
|
rm -f ${{ inputs.module_directory }}-${{ inputs.major_version }}.${{ inputs.minor_version }}.tar.gz
|
|
mv ${{ inputs.module_directory }}-${{ inputs.major_version }}.${{ inputs.minor_version }} ${{ inputs.module_directory }}
|
|
shell: bash
|
|
|
|
- name: Restore static directory cache
|
|
if: "${{ inputs.frontend_static_directory != '' && inputs.frontend_static_cache_key != '' }}"
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ inputs.frontend_static_directory }}
|
|
key: ${{ inputs.frontend_static_cache_key }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Restore translation directory cache
|
|
if: "${{ inputs.translation_directory != '' && inputs.translation_cache_key != '' }}"
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ inputs.translation_directory }}
|
|
key: ${{ inputs.translation_cache_key }}
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Import gpg key
|
|
env:
|
|
RPM_GPG_SIGNING_KEY: ${{ secrets.RPM_GPG_SIGNING_KEY }}
|
|
run: echo -n "$RPM_GPG_SIGNING_KEY" > key.gpg
|
|
shell: bash
|
|
|
|
- name: Build ${{ inputs.package_extension }} files
|
|
env:
|
|
RPM_GPG_SIGNING_KEY_ID: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
|
|
RPM_GPG_SIGNING_PASSPHRASE: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
|
|
run: |
|
|
export MAJOR_VERSION="${{ inputs.major_version }}"
|
|
export VERSION="${{ inputs.major_version }}.${{ inputs.minor_version }}"
|
|
export RELEASE="${{ inputs.release }}"
|
|
|
|
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/@COMMIT_HASH@/${{ github.sha }}/g" $BASENAME
|
|
nfpm package --config $BASENAME --packager ${{ inputs.package_extension }}
|
|
cd -
|
|
mv $DIRNAME/*.${{ inputs.package_extension }} ./
|
|
done
|
|
shell: bash
|
|
|
|
- name: Upload package artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: packages-${{ inputs.package_extension }}
|
|
path: ./*.${{ inputs.package_extension }}
|
|
retention-days: 1
|
|
|
|
- name: Cache packages
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ./*.${{ inputs.package_extension }}
|
|
key: ${{ inputs.cache_key }}
|