-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa0a573
commit 22980d1
Showing
7 changed files
with
164 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Zenodo | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- fix-zenodo-workflow | ||
|
||
concurrency: zenodo | ||
jobs: | ||
zenodo: | ||
name: Zenodo | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
################################################### | ||
# | ||
# Prepare | ||
# | ||
################################################### | ||
|
||
- name: (PREPARE) Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
lfs: true | ||
fetch-depth: 0 | ||
|
||
- name: (PREPARE) Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.10.13 | ||
cache: pip | ||
|
||
################################################### | ||
# | ||
# Zenodo | ||
# | ||
################################################### | ||
|
||
- name: (ZENODO) Download files | ||
run: gh release download latest --dir /tmp/opentosca-vintner-zenodo-files | ||
|
||
- name: (ZENODO) Create new Zenodo version | ||
run: yarn release:zenodo | ||
env: | ||
ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }} | ||
ZENODO_URL: ${{ secrets.ZENODO_URL }} | ||
ZENODO_ORIGINAL_ID: ${{ secrets.ZENODO_ORIGINAL_ID }} | ||
VINTNER_VERSION: ${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
# | ||
*.ignored.yaml | ||
*.ignored.env | ||
|
||
# IDE | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import json | ||
import requests | ||
import datetime | ||
import os | ||
|
||
access_token = os.getenv('ZENODO_ACCESS_TOKEN') | ||
original_id = int(os.getenv('ZENODO_ORIGINAL_ID')) | ||
zenodo_url = os.getenv('ZENODO_URL', 'https://zenodo.org') | ||
zenodo_files = '/tmp/opentosca-vintner-zenodo-files' | ||
vintner_version = os.getenv('VINTNER_VERSION') | ||
|
||
if access_token is None: | ||
raise Exception('ZENODO_ACCESS_TOKEN not defined') | ||
|
||
if vintner_version is None: | ||
raise Exception('ZENODO_ACCESS_TOKEN not defined') | ||
|
||
|
||
def create_version(id): | ||
r = requests.post(zenodo_url + '/api/deposit/depositions/' + str(id) + '/actions/newversion', params={'access_token': access_token}) | ||
print(r.status_code) | ||
print(r.json()) | ||
data = r.json() | ||
|
||
# Delete all existing files | ||
if 'files' in data: | ||
for file in data['files']: | ||
r = requests.delete(file['links']['self'], params=params) | ||
print(r.status_code) | ||
print(r.json()) | ||
|
||
# Set new publish date | ||
set_metadata(data['id']) | ||
|
||
return data['id'] | ||
|
||
|
||
def publish_version(id): | ||
r = requests.post(zenodo_url + '/api/deposit/depositions/' + str(id) + '/actions/publish', params={'access_token': access_token}) | ||
print(r.status_code) | ||
print(r.json()) | ||
|
||
|
||
def set_metadata(id): | ||
data = {"metadata": { | ||
"title": "OpenTOSCA Vintner", | ||
"publication_date": current_date(), | ||
"access_right": "open", | ||
"creators": [ | ||
{ | ||
"name": "Stötzner, Miles", | ||
"affiliation": "University of Stuttgart", | ||
"orcid": "0000-0003-1538-5516" | ||
} | ||
], | ||
"license": "apache2.0", | ||
"imprint_publisher": "Zenodo", | ||
"upload_type": "software", | ||
"description": "OpenTOSCA Vintner is a TOSCA preprocessing and management layer which is able to deploy applications based on TOSCA orchestrator plugins. Preprocessing includes, e.g., the resolving of deployment variability. Please check out our GitHub repository: https://github.com/OpenTOSCA/opentosca-vintner", | ||
"keywords": ["OpenTOSCA", "Vintner", "TOSCA", "Variability4TOSCA", "variability", "variants", "deployment", "orchestration", "management", "open-source", "open source", "cloud"], | ||
"notes": "This project was partially funded by the German Federal Ministry for Economic Affairs and Climate Action (BMWK) as part of the Software-Defined Car (SofDCar) project (19S21002).", | ||
"version": vintner_version, | ||
}, | ||
} | ||
headers = {"Content-Type": "application/json"} | ||
|
||
r = requests.put(zenodo_url + '/api/deposit/depositions/' + str(id), data=json.dumps(data), headers=headers, params={'access_token': access_token}) | ||
print(r.status_code) | ||
print(r.json()) | ||
|
||
|
||
def upload_files(id): | ||
files = [file for file in os.listdir(zenodo_files) if os.path.isfile(os.path.join(zenodo_files, file))] | ||
for file in files: | ||
upload_file(id, file) | ||
|
||
|
||
def upload_file(id, file): | ||
url = zenodo_url + '/api/deposit/depositions/' + str(id) + '/files' | ||
data = {'name': file} | ||
files = {'file': open(os.path.join(zenodo_files, file), 'rb')} | ||
r = requests.post(url, params={'access_token': access_token}, data=data, files=files) | ||
print(r.status_code) | ||
print(r.json()) | ||
|
||
|
||
def current_date(): | ||
return datetime.datetime.now().isoformat()[0:10] | ||
|
||
|
||
version_id = create_version(original_id) | ||
upload_files(version_id) | ||
publish_version(version_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,7 +164,9 @@ | |
"puccini:check:single": "bash docs/cmds/puccini/check.sh", | ||
"puml:up": "cd docs && docker-compose up -d", | ||
"puml:down": "cd docs && docker-compose down", | ||
"large:check": "bash cmds/check-large-files.sh" | ||
"large:check": "bash cmds/check-large-files.sh", | ||
"release:npm": "npm publish", | ||
"release:zenodo": "python cmds/zenodo.py" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |