craft_appimage_x86_64:
  stage: build
  when: always
  image: kdeorg/centos7-craft:latest
  #needs: ["suse_tumbleweed_qt515"]
  tags:
    - linux
  variables:
    GIT_STRATEGY: none
    KDECI_CRAFT_PLATFORM: linux-64-gcc
    KDECI_CRAFT_CACHE: /mnt/craft-cache/$KDECI_CRAFT_PLATFORM/
    KDECI_CRAFT_CONFIG: ci-utilities/craft/qt5/CraftConfig.ini
    KDECI_CRAFT_PROJECT_CONFIG: $CI_PROJECT_DIR/src/.craft.ini
  interruptible: true
  before_script:
    - export LANG=en_US.UTF-8
    - git clone --recurse-submodules $CI_REPOSITORY_URL --branch=$CI_COMMIT_REF_NAME src/
    # Create empty .craft.ini if none exists
    - touch $KDECI_CRAFT_PROJECT_CONFIG
    - git clone https://invent.kde.org/packaging/craftmaster --branch=master
    - git clone https://invent.kde.org/sysadmin/ci-utilities
    # Define a short cut for the lengthy CraftMaster command line
    - function craftmaster { python3 craftmaster/CraftMaster.py --config $KDECI_CRAFT_CONFIG --config-override $KDECI_CRAFT_PROJECT_CONFIG --target $KDECI_CRAFT_PLATFORM $@; }
  script:
    # Set up craft settings and blueprint settings
    - craftmaster --setup
    # Get Craft itself ready
    - craftmaster -c -i --options virtual.ignored=True --update craft
    # Add the repository with the blueprints for Glaxnimate
    - craftmaster -c --add-blueprint-repository https://invent.kde.org/packaging/craft-blueprints-community.git
    # Install all of our dependencies
    - craftmaster -c --install-deps $CI_PROJECT_NAME
    # Build the actual application
    - craftmaster -c --no-cache --target master --src-dir $CI_PROJECT_DIR/src/ $CI_PROJECT_NAME
    # Ensure the tools needed to conduct packaging are installed
    - craftmaster -c -i --update linuxdeploy
    # Package it up!
    - craftmaster -c --package --target master --src-dir $CI_PROJECT_DIR/src/ $CI_PROJECT_NAME
    # Save our package
    - packageDir=$(craftmaster -c -q --get "packageDestinationDir()" virtual/base)
    - mkdir $CI_PROJECT_DIR/.kde-ci-packages/
    - cp -vf $packageDir/*.AppImage $CI_PROJECT_DIR/.kde-ci-packages/
  artifacts:
    expire_in: 3 days
    when: always
    expose_as: "Appimage"
    paths:
     - ".kde-ci-packages/"
     - "$KDECI_CRAFT_PLATFORM/logs"

