# SPDX-FileCopyrightText: 2020-2025 Laurent Montel <montel@kde.org>
# SPDX-License-Identifier: CC0-1.0

include:
  - project: sysadmin/ci-utilities
    file:
      - /gitlab-templates/reuse-lint.yml
      - /gitlab-templates/linux-qt6.yml
      - /gitlab-templates/linux-qt6-next.yml
      - /gitlab-templates/json-validation.yml
      - /gitlab-templates/android-qt6.yml
      - /gitlab-templates/freebsd-qt6.yml
      - /gitlab-templates/windows-qt6.yml
      - /gitlab-templates/flatpak.yml

# Job for building a fully static extractor binary for e.g. use by Nextcloud
static-extractor:
  stage: build
  image: centos:centos7
  tags:
    - Linux
  when: manual
  script:
    - export BUILD_ROOT=/builds
    - export STAGING_ROOT=/builds/staging
    - scripts/setup-centos.sh
    - source /opt/rh/rh-git227/enable
    - source /opt/rh/devtoolset-11/enable
    - scripts/build-openssl.sh
    - scripts/build-iso-codes.sh
    - scripts/build-static-qt.sh
    - scripts/build-cmake-modules.sh
    - scripts/package.sh
  artifacts:
    expire_in: 1 week
    when: on_success
    paths:
     - "kde-ci-packages/"

# Publishing job for static extractor binaries
# This is separate as we need a newer Python than is easily available on the ancient
# CentOS image building this.
static-extractor-publish:
  stage: deploy
  image: invent-registry.kde.org/sysadmin/ci-images/sles15-craft:latest
  tags:
    - Linux
  needs:
    - static-extractor
  interruptible: true
  before_script:
    - export LANG=en_US.UTF-8
    - git clone https://invent.kde.org/sysadmin/ci-utilities.git --depth=1
    - git clone https://invent.kde.org/sysadmin/ci-notary-service.git --depth=1
  script:
    # basic smoke test
    - mkdir $CI_PROJECT_DIR/tmp
    - tar xv -C $CI_PROJECT_DIR/tmp -f $CI_PROJECT_DIR/kde-ci-packages/*.tgz
    - $CI_PROJECT_DIR/tmp/bin/kitinerary-extractor $CI_PROJECT_DIR/autotests/extractordata/synthetic/iata-bcbp-demo.pdf | grep "FlightReservation"
    # Publish
    - python3 -u ci-notary-service/publishbuild.py --config ci-utilities/signing/publishbuild.ini --platform linux "$CI_PROJECT_DIR/kde-ci-packages/"
