.packages:
  extends:
  - .rules:merge_request_pipelines:no_docs
  stage: package
  environment:
    name: package/$PKGS/$CI_COMMIT_REF_NAME
  needs:
  - 'helper images'
  - 'helper images binaries'
  - 'helper images fips'
  - 'binaries'
  - 'binaries-fips'
  before_script:
  - |
    # checking GPG signing support
    if [ -f "$GPG_KEY_PATH" ]; then
      cat ${GPG_KEY_PATH} | gpg --batch --no-tty --allow-secret-key-import --import -
      export GPG_KEYID=$(gpg --with-colon --list-secret-keys | head -n1 | cut -d : -f 5)
      export GPG_PASSPHRASE=$(cat ${GPG_PASSPHRASE_PATH})
    else
      echo -e "\033[0;31m****** GPG signing disabled ******\033[0m"
    fi
  script:
  - source ci/touch_make_dependencies
  - make $PKGS
  artifacts:
    paths:
    - out/deb/
    - out/rpm/
    expire_in: 7d

package-deb:
  extends:
  - .packages
  parallel:
    matrix:
    - PKGS:
      - package-deb-64bit
      - package-deb-arm-64bit
      - package-deb-32bit
      - package-deb-arm-32bit
      - package-deb-ibm

package-rpm:
  extends:
  - .packages
  parallel:
    matrix:
    - PKGS:
      - package-rpm-64bit
      - package-rpm-arm-64bit
      - package-rpm-32bit
      - package-rpm-arm-32bit
      - package-rpm-ibm
      - package-rpm-fips
