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

stages:
  - build
  - test
  - package

.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 NO_INSTALL_HARDLINKS=YesPlease
    - make NO_INSTALL_HARDLINKS=YesPlease install
  artifacts:
    name: ${NAME}
    paths:
      - ${NAME}

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

.package:
  stage: package
  script:
    - cd ${CI_PROJECT_DIR}/${NAME}
    - zip -r --symlinks ../${NAME}.zip *
    - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ../${NAME}.zip "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/git/${GIT_VERSION}/"'

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

test-el6-x86_64:
  extends: [".test"]
  image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-docker-tools/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-docker-tools/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"]
  image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-docker-tools/dev-el6-gcc44-x86
  variables:
    NAME: "git-${GIT_VERSION}-linux-el6-i686"

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

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

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

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

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

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

test-el7-i686:
  extends: [".test"]
  image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-docker-tools/dev-el7-gcc48-x86
  variables:
    NAME: "git-${GIT_VERSION}-linux-el7-i686"
  needs:
    - linux-el7-i686

package-el7-i686:
  extends: [".package"]
  image: gitlab-registry.synchrotron-soleil.fr/software-control-system/containers/dev-docker-tools/dev-el7-gcc48-x86
  variables:
    NAME: "git-${GIT_VERSION}-linux-el7-i686"
  needs:
    - linux-el7-i686
    - test-el7-i686
