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 version: description: The package version ([major_version].[minor_version]) required: false major_version: description: The major version required: false minor_version: description: The minor version required: false release: description: The package release number required: true 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 stability: description: "Branch stability (stable, testing, unstable, canary)" required: true runs: using: composite steps: - name: Parse distrib name id: parse-distrib uses: ./.github/actions/parse-distrib with: distrib: ${{ inputs.distrib }} - 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: | if [ -z ${{ inputs.version }} ]; then export VERSION="${{ inputs.major_version }}.${{ inputs.minor_version }}" export MAJOR_VERSION="${{ inputs.major_version }}" export MINOR_VERSION="${{ inputs.minor_version }}" elif [ -z ${{ inputs.major_version }} ]; then export VERSION="${{ inputs.version }}" export MAJOR_VERSION=$( echo $VERSION | cut -d "-" -f1 ) export MINOR_VERSION=$( echo $VERSION | cut -d "-" -f2 ) fi 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="" if [ "${{ inputs.stability }}" == "unstable" ] || [ "${{ inputs.stability }}" == "canary" ]; then export RELEASE="$RELEASE${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }}" else export RELEASE="1${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }}" fi export APACHE_USER="www-data" export APACHE_GROUP="www-data" fi if [ -z "$MAJOR_VERSION" ]; then MAJOR_LEFT=$( echo $VERSION | cut -d "." -f1 ) MAJOR_RIGHT=$( echo $VERSION | cut -d "-" -f1 | cut -d "." -f2 ) 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" fi 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 - uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 with: path: ./*.${{ inputs.package_extension }} key: ${{ inputs.cache_key }} # Add to your PR the label upload-artifacts to get packages as artifacts - if: ${{ contains(github.event.pull_request.labels.*.name, 'upload-artifacts') }} name: Upload package artifacts uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: packages-${{ inputs.distrib }} path: ./*.${{ inputs.package_extension}} retention-days: 1