Skip to main content
Ctrl K

ZenodoCI

The library is intended to be part of a complete CI pipeline. This stage deploys to Zenodo the files found in the ./build directory, configured in the .gitlab-ci.yml file

2
contributors
Get started
archived repository70 commitsLast commit ≈ 59 months ago0 stars1 fork

Cite this software

Description

This project is now part of the eossr library

ZenodoCI

DOI pipeline status License: MIT coverage report

Library to manage an upload to Zenodo through its REST API.

Install

  $ git clone https://gitlab.in2p3.fr/escape2020/wp3/zenodoci.git
  $ cd zenodoci
  $ pip install .

Then you would be able to run any of the following;

  $ upload_new_deposit --token $ZENODO_TOKEN --sandbox False --input_dir <./path_proj_dir>
  $ upload_new_version_deposit -t $ZENODO_TOKEN -s False -i <./your_proj_dir> -id <ZENODO_PROJ_ID>
  $ test_connection_zenodo -t $ZENODO_TOKEN -s False --repo_dir <PROJ_DIR>

Please note that all the code developed in this project, together with the codemeta2zenodo crosswalk are included and installed into a Docker container that can be found at the container registry of this project.

Fell free to pull it and use at any moment.

Quickstart - Deploy your project to Zenodo (one-click-build-and-publish).

  1. Include a codementa.json metadata file to your project.
  2. Create a token at zenodo and add it as an environment variable to your project (see below).
  3. Add in your .gitlab-ci.yml file the following stage to deploy your project into Zenodo.
  4. Create a release.

The code to be added to the .gitlab-ci.yml file is the following (COMMON FOR EVERY PROJECT).

To create a new entry or deposit

stages:
    - `(...) all your CI stages (...)`
    - deploy

`(...) All the code to be run in your CI pipeline (...)`

deploy_to_zenodo:
    stage: deploy
    image: gitlab-registry.in2p3.fr/escape2020/wp3/zenodoci:v1.2
    before_script:
      - test_connection_zenodo --token $ZENODO_TOKEN --sandbox False -p $CI_PROJECT_DIR
    script:
      - mkdir -p build
      - parse_last_release_git.sh $CI_PROJECT_NAME $CI_PROJECT_URL
      - if [[ -f ./codemeta.json ]]; then cp ./codemeta.json ./build; fi
      - ls ./build

      - upload_new_deposit --token $SANDBOX_ZENODO_TOKEN --sandbox True --input-dir ./build
    only:
      - tags

To create a new version of an existing entry

Substitute

      - upload_new_version_deposit -t $ZENODO_TOKEN -s True -i ./build -id $ZENODO_PROJECT_ID

for

      - upload_new_version_deposit -t $ZENODO_TOKEN -s True -i ./build -id $ZENODO_PROJECT_ID

and please check the correct indentation on the file.

Zenodo token & GitLab CI environment variable

To allow GitLab communicate with Zenodo through their APIs, a personal access token must be created and included into the GitLab project (as a masked ! environment variable).

Please note that (to date) the token can be assigned only to a single Zenodo account. To create the token:

  • Go to zenodo.org.
  • Click on Account --> Applications --> Personal access token --> New token and Select the desired Scopes.

This token will be passed later in the deployment stage of the ZenodoCI pipeline (the same that you should also include into your project to automatise the upload).

For not sharing publicly your personal token, you should create an environment variable in your GitLab repository. This way, the token could be used as a variable without revealing its value. To create an an environment variable:

  • Go to your GitLab project.
  • Click on Settings --> CI/CD --> Variables --> Add variable --> Fill the fields --> Mask your variable(s) !!

Please name your environment variables as follows (so that no changes should be done to the .gitlab-ci.yml file);

  • ZENODO_TOKEN or SANDBOX_ZENODO_TOKEN
  • ZENODO_PROJECT_ID

so that environment variable(s) should look like:

    $ upload_new_deposit --token $ZENODO_TOKEN --sandbox False --input-directory <./build> 
    $ upload_new_version_deposit -t $ZENODO_TOKEN -s False -i <./your_proj_dir> -id $ZENODO_PROJECT_ID

Contact

Contact us for any question or doubt related with the current library, the ESCAPE project, the metadata schema context or the integration of any project to Zenodo, Gitlab or the ESCAPE OSSR.

Keywords
Programming languages
  • Python 97%
  • Shell 2%
  • Dockerfile 1%
License
</>Source code

Contributors

TV
Thomas Vuillaume

Member of community

ESCAPE OSSR