Commit dee18390 authored by Enrique Garcia's avatar Enrique Garcia
Browse files

changes for first release - so gitlab-ci works and the information of the new entry is correct

parent 341178fd
Pipeline #78652 failed with stage
in 16 seconds
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.
### You can have a look into https://gitlab.in2p3.fr/escape2020/escape/template_project_escape/-/blob/master/.gitlab-ci.yml
# - build_image
script:
### 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
#- python3 --version # 3.6.11 as th
- pip3 install requests
### 2 - Get the last tag/release of the repository
- export REPOSITORY_NAME=template_project_escape
- export REPOSITORY_URL=https://gitlab.in2p3.fr/escape2020/escape/$REPOSITORY_NAME.git
- export LAST_RELEASE=`git ls-remote --tags --refs --sort="v:refname" $REPOSITORY_URL | tail -n1 | sed 's/.*\///'`
### 3 - Download the repository and move it to the build directory
### If no release is found/correctly parsed, the script will download the last commit pushed to the master branch
- mkdir -p build
- >
fi [ -z "$LAST_RELEASE" ]
then
echo "No tag / new release found ! - Or error when parsing. Downloading last commit to the repository (master branch) ;"
wget -O $REPOSITORY_NAME-master.zip https://gitlab.in2p3.fr/escape2020/escape/"$REPOSITORY_NAME"/-/archive/master/"$REPOSITORY_NAME"-master.zip
mv $REPOSITORY_NAME-master.zip ./build
else
echo "$LAST_RELEASE tag / release found !"
wget -O $REPOSITORY_NAME-$LAST_RELEASE.zip https://gitlab.in2p3.fr/escape2020/escape/"$REPOSITORY_NAME"/-/archive/"$LAST_RELEASE"/"$REPOSITORY_NAME"-"$LAST_RELEASE".zip
mv $REPOSITORY_NAME-$LAST_RELEASE.zip ./build
fi
- ls ./build
### 4 - To deploy a NEW DEPOSIT to ZENODO SANDBOX
- >
python3 .zenodoci/upload_new_deposit.py
--token $SANDBOX_ZENODO_TOKEN
--sandbox_zenodo True
--input-directory ./build
### 4 - To deploy a NEW DEPOSIT to ZENODO
#- >
# python3 .zenodoci/upload_new_deposit.py
# --token $ZENODO_TOKEN
# --sandbox_zenodo False
# --input-directory ./build
### 4 - To deploy a NEW VERSION to ZENODO: The deposit_id of the entry to be `new_versioned` MUST be provided.
- >
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:
### Ideally this stage should be run only when a new release / tag of the source code is created (- tags).
# The script is changed to check that the both `upload_new_deposit` and `upload_new_version_deposit` works nicely.
- tags
- master
\ No newline at end of file
{
"metadata": {
"title": "template repository ESCAPE",
"title": "ZenodoCI",
"upload_type": "software",
"description": "A template repository for the ESCAPE project",
"description": "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",
"creators": [{"name": "Garcia, Enrique",
"affiliation": "LAPP, CNRS"},
{"name": "Vuillaume, Thomas",
"affiliation": "LAPP, CNRS",
"orcid": "0000-0002-5686-2078"}],
"affiliation": "LAPP, CNRS",
"orcid": "0000-0003-2224-4594"}],
"access_right": "open",
"license": "GPL-3.0+",
"license": "MIT",
"communities": [{"identifier": "escape2020"}],
"keywords": [],
"language": "eng",
"notes": "(This will appear as a subtitle)",
"version": "2.0",
"notes": "Deploy stage (into the Zenodo repository) for a CI (GitLab) pipeline.",
"version": "1.0",
"grants": [{"id": "10.13039/501100000780::824064"}]
}
}
\ No newline at end of file
......@@ -48,9 +48,9 @@ if __name__ == '__main__':
for file in os.listdir(args.input_directory):
full_path_file = args.input_directory + '/' + file
new_upload = z.upload_files_entry(deposition_id,
name_file=file,
path_file=full_path_file)
new_upload = z.upload_file_entry(deposition_id,
name_file=file,
path_file=full_path_file)
print(f"File {file} correctly uploaded !\n", new_upload)
......
......@@ -49,19 +49,19 @@ if __name__ == '__main__':
new_deposition_id = new_version.json()['links']['latest_draft'].rsplit('/')[-1]
# # If you DO NOT want to erase the old files, comment the following lines
# old_files_ids = [file['id'] for file in new_version.json()['files']]
# for file_id in old_files_ids:
# z.deposition_files_delete(new_deposition_id,
# file_id)
# 2-PRE If you DO NOT want to erase the old files, comment the following lines
old_files_ids = [file['id'] for file in new_version.json()['files']]
for file_id in old_files_ids:
z.erase_file_entry(new_deposition_id,
file_id)
# 2 - Upload new version of file(s)
for file in os.listdir(args.input_directory):
full_path_file = args.input_directory + '/' + file
new_upload = z.upload_files_entry(new_deposition_id,
name_file=file,
path_file=full_path_file)
new_upload = z.upload_file_entry(new_deposition_id,
name_file=file,
path_file=full_path_file)
print(f"File {file} correctly uploaded !\n", new_upload)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment