.gitlab-ci.yml 2.63 KB
Newer Older
1 2 3 4 5 6 7 8
stages:
  - deploy

deploy_zenodo:
    stage: deploy
    image: python:3.6.11-buster
    #dependencies:
      ### Ideally to be used within a ci pipeline in where a container of the source code is build in a previous stage.
9
      ###  You can have a look into https://gitlab.in2p3.fr/escape2020/wp3/template_project_escape/-/blob/master/.gitlab-ci.yml
10
    #  - build_image
Enrique Garcia's avatar
Enrique Garcia committed
11
    before_script:
12 13 14 15 16 17
      ### 1 - Install dependencies in the image and upload the files to Zenodo
      - apt-get -y update

      ### INFORMATION FOR THE USER; Python, pip and wget are already installed in the container
      #- cat /etc/os-release  # Debian GNU/Linux 10 (buster)
      #- pip3 --version       # pip 20.1.1
Enrique Garcia's avatar
Enrique Garcia committed
18 19 20 21 22 23
      #- python3 --version    # 3.6.11 as expected
      - pip3 install requests numpy

      ### 2 - Check that you can correctly communicate with (sandobox)zenodo - Uncomment if needed.
      - python3 .zenodoci/test_connection_zenodo.py -t $SANDBOX_ZENODO_TOKEN -s True
      #- python3 .zenodoci/test_connection_zenodo.py -t $ZENODO_TOKEN -s False
24

Enrique Garcia's avatar
Enrique Garcia committed
25
      ### 3 - Get the last tag/release of the repository
Enrique's avatar
Enrique committed
26 27

      - export REPOSITORY_NAME=zenodoci
Enrique's avatar
Enrique committed
28
      - export REPOSITORY_BASE_URL=https://gitlab.in2p3.fr/escape2020/wp3/$REPOSITORY_NAME
29

Enrique Garcia's avatar
Enrique Garcia committed
30
      ### 4 - Download the repository and move it to the build directory
31 32
      ###  If no release is found/correctly parsed, the script will download the last commit pushed to the master branch
      - mkdir -p build
33
      - /bin/bash .zenodoci/parse_last_release.sh $REPOSITORY_NAME $REPOSITORY_URL
34
      - ls ./build
35

Enrique Garcia's avatar
Enrique Garcia committed
36 37
    script:
      ### 5 - To deploy a NEW DEPOSIT to ZENODO SANDBOX
38 39 40 41 42 43
      - >
        python3 .zenodoci/upload_new_deposit.py
        --token $SANDBOX_ZENODO_TOKEN
        --sandbox_zenodo True
        --input-directory ./build

Enrique Garcia's avatar
Enrique Garcia committed
44
      ### 5 - To deploy a NEW DEPOSIT to ZENODO
45 46 47 48 49 50
      #- >
      #    python3 .zenodoci/upload_new_deposit.py
      #    --token $ZENODO_TOKEN
      #    --sandbox_zenodo False
      #    --input-directory ./build

Enrique Garcia's avatar
Enrique Garcia committed
51
      ### 5 - To deploy a NEW VERSION to ZENODO: The deposit_id of the entry to be `new_versioned` MUST be provided.
52 53 54 55 56 57 58 59 60
      - >
        python3 .zenodoci/upload_new_version_deposit.py
        --token $SANDBOX_ZENODO_TOKEN
        --sandbox_zenodo True
        --input-directory ./build
        --deposit_id $DEPOSIT_ID_ZENODOCI
      #  --token $ZENODO_TOKEN
      #  --sandbox_zenodo False
    only:
61
      ### Ideally this stage should be run only when a new release / tag of the source code is created, i.e., (- tags).
62 63
      # The script is changed to check that the both `upload_new_deposit` and `upload_new_version_deposit` works nicely.
      - tags
64
      - branches  # For testing