
variables:
  GIT_VERSION: "2.36.2"
  DEFAULT_HELP_FORMAT: "man"

stages:
  - build
  - test
  - updload

.build:
  stage: build
  script:
    - yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker
    - git clone https://github.com/git/git.git
    - cd git
    - git checkout v${GIT_VERSION}
    - autoconf
    - ./configure --prefix=${CI_PROJECT_DIR}/${NAME}
    - make && make install
    - cd ${CI_PROJECT_DIR}/${NAME}
    - zip -r --symlinks ../${NAME}.zip *
    - ls -al
  artifacts:
    name: ${NAME}
    paths:
      - ${NAME}.zip

.test:
  stage: test
  script:
    - unzip ${NAME}.zip -d ${NAME}
    - ${NAME}/bin/git --version | grep ${GIT_VERSION}

.upload:
  stage: upload
  script:
    - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ${NAME}.zip "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/fakegit/${GIT_VERSION}/"'

linux-el6-x86_64:
  extends: [".build-python"]
  image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el6-gcc44
  variables:
    NAME: "git-${GIT_VERSION}-linux-el6-x86_64"

test-el6-x86_64:
  extends: [".test-python"]
  image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el6-gcc44
  variables:
    NAME: "git-${GIT_VERSION}-linux-el6-x86_64"
  needs:
    - linux-el6-x86_64

package-el6-x86_64:
  extends: [".package"]
  image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el6-gcc44
  variables:
    NAME: "git-${GIT_VERSION}-linux-el6-x86_64"
  needs:
    - linux-el6-x86_64
    - test-el6-x86_64

# linux-el6-i686:
#   extends: [".build-python"]
#   image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el6-gcc44-x86
#   variables:
#     NAME: "git-${GIT_VERSION}-${CI_JOB_NAME}"
#     GIT_ROOT: "${CI_PROJECT_DIR}/${NAME}"

# test-el6-i686:
#   extends: [".test-python"]
#   image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el6-gcc44-x86
#   needs:
#     - linux-el6-i686

# linux-el7-x86_64:
#   extends: [".build-python"]
#   image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el7-gcc48
#   variables:
#     NAME: "git-${GIT_VERSION}-${CI_JOB_NAME}"
#     GIT_ROOT: "${CI_PROJECT_DIR}/${NAME}"

# test-el7-x86_64:
#   extends: [".test-python"]
#   image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el7-gcc48
#   needs:
#     - linux-el7-x86_64

# linux-el7-i686:
#   extends: [".build-python"]
#   image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el7-gcc48-x86
#   variables:
#     NAME: "git-${GIT_VERSION}-${CI_JOB_NAME}"
#     GIT_ROOT: "${CI_PROJECT_DIR}/${NAME}"

# test-el7-i686:
#   extends: [".test-python"]
#   image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-el7-gcc48-x86
#   needs:
#     - linux-el7-i686
