.gitlab-ci.yml 3.03 KB
Newer Older
1
stages:
Enrique Garcia's avatar
Enrique Garcia committed
2
  - test
3
  - deploy
4
  - test&deploy
5

Enrique Garcia's avatar
Enrique Garcia committed
6 7 8 9 10 11 12 13 14
test_install:
    stage: test
    image: python:3.6.11-buster
    script:
        - apt-get -y update
        - pip install .
    only:
        - branches

15 16 17 18 19
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.
20
      ###  You can have a look into https://gitlab.in2p3.fr/escape2020/wp3/template_project_escape/-/blob/master/.gitlab-ci.yml
21
    #  - build_image
Enrique Garcia's avatar
Enrique Garcia committed
22
    before_script:
23 24 25 26 27 28
      ### 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
29
      #- python3 --version    # 3.6.11 as expected
Enrique Garcia's avatar
Enrique Garcia committed
30 31
      - pip install requests numpy
      - pip install .  # Install ZenodoCI
Enrique Garcia's avatar
Enrique Garcia committed
32

33
      ### 2 - Test the communication to Zenodo - Uncomment if needed, or if already done it manually.
Enrique Garcia's avatar
Enrique Garcia committed
34 35
      - test_connection_zenodo --token $SANDBOX_ZENODO_TOKEN --sandbox True -r $CI_PROJECT_DIR
      #- test_connection_zenodo -t $ZENODO_TOKEN -s False --repo_dir $CI_PROJECT_DIR
36

37
    script:
Enrique Garcia's avatar
Enrique Garcia committed
38
      ### 3 - Get the last tag/release of the repository
Enrique's avatar
Enrique committed
39
      - export REPOSITORY_NAME=zenodoci
Enrique's avatar
Enrique committed
40
      - export REPOSITORY_BASE_URL=https://gitlab.in2p3.fr/escape2020/wp3/$REPOSITORY_NAME
41

Enrique Garcia's avatar
Enrique Garcia committed
42
      ### 4 - Download the repository and move it to the build directory
43 44
      ###  If no release is found/correctly parsed, the script will download the last commit pushed to the master branch
      - mkdir -p build
Enrique Garcia's avatar
Enrique Garcia committed
45
      - /bin/bash zenodoci/parse_last_release.sh $REPOSITORY_NAME $REPOSITORY_BASE_URL
46
      - ls ./build
47

Enrique Garcia's avatar
Enrique Garcia committed
48
      ### 5 - To deploy a NEW DEPOSIT to ZENODO SANDBOX
49
      - >
Enrique Garcia's avatar
Enrique Garcia committed
50
        upload_new_deposit --token $SANDBOX_ZENODO_TOKEN --sandbox True --input-directory ./build
51

Enrique Garcia's avatar
Enrique Garcia committed
52
      ### 5 - To deploy a NEW DEPOSIT to ZENODO
53
      #- >
Enrique Garcia's avatar
Enrique Garcia committed
54
      #    upload_new_deposit
55
      #    --token $ZENODO_TOKEN
56
      #    --sandbox False
57 58
      #    --input-directory ./build

Enrique Garcia's avatar
Enrique Garcia committed
59
      ### 5 - To deploy a NEW VERSION to ZENODO: The deposit_id of the entry to be `new_versioned` MUST be provided.
60
      - >
Enrique Garcia's avatar
Enrique Garcia committed
61
        upload_new_version_deposit
62
        --token $SANDBOX_ZENODO_TOKEN
63
        --sandbox True
64 65 66
        --input-directory ./build
        --deposit_id $DEPOSIT_ID_ZENODOCI
      #  --token $ZENODO_TOKEN
67 68
      #  --sandbox False

69
    only:
70
      ### Ideally this stage should be run only when a new release / tag of the source code is created, i.e., (- tags).
71 72
      # The script is changed to check that the both `upload_new_deposit` and `upload_new_version_deposit` works nicely.
      - tags
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
      - branches  # For testing


test_deploy_from_container:
    stage: test&deploy
    image: gitlab-registry.in2p3.fr/escape2020/wp3/zenodoci
    script:
        - pwd
        - ls
        - env
        - upload_new_deposit -h
        - codemeta2zenodo -h
    only:
        - tags
        - branches # testing