Kaynağa Gözat

Fix out-of-date citation file by uploading to Zenodo (#3825)

* fix out-of-date citation file by uploading to Zenodo

* try Zenodo ID of version 2.0.0
Falko Schindler 7 ay önce
ebeveyn
işleme
772aa8d452

+ 12 - 11
.github/workflows/publish.yml

@@ -121,16 +121,6 @@ jobs:
         with:
           python-version: 3.11
 
-      - name: Install dependencies
-        run: |
-          python -m pip install --upgrade pip
-          pip install requests PyYAML
-
-      - name: Update Citation.cff
-        env:
-          ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }}
-        run: python .github/workflows/update_citation.py $(echo ${GITHUB_REF/refs\/tags\//})
-
       - name: Update version in pyproject.toml
         run: python .github/workflows/update_pyproject.py $(echo ${GITHUB_REF/refs\/tags\//})
 
@@ -139,9 +129,20 @@ jobs:
           git config --global user.name "github-actions[bot]"
           git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
           git add CITATION.cff pyproject.toml
-          git commit -m "Update citation.cff and pyproject.toml"
+          git commit -m "Update pyproject.toml"
           git push origin HEAD:main
 
+      - name: Upload to Zenodo
+        id: release
+        uses: megasanjay/upload-to-zenodo@v2.0.1
+        with:
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          zenodo_token: ${{ secrets.ZENODO_TOKEN }}
+          zenodo_deposition_id: 13623775
+          zenodo_publish: true
+          commit_message: "Update CITATION.cff"
+          citation_cff: true
+
   verify:
     needs: docker
     runs-on: ubuntu-latest

+ 0 - 38
.github/workflows/update_citation.py

@@ -1,38 +0,0 @@
-#!/usr/bin/env python3
-import os
-import sys
-from pathlib import Path
-from typing import Tuple
-
-import requests
-import yaml
-
-
-def get_infos() -> Tuple[str,  str]:
-    headers = {
-        'Accept': 'application/json',
-    }
-    params = {
-        'access_token': os.environ['ZENODO_TOKEN'],
-        'q': 'nicegui',
-        'sort': 'mostrecent',
-        'status': 'published',
-    }
-    try:
-        response = requests.get('https://zenodo.org/api/records', params=params, headers=headers, timeout=5)
-        response.raise_for_status()
-    # Hide all error details to avoid leaking the token
-    except Exception:
-        print('Error while getting the Zenodo infos')
-        sys.exit(1)
-    data = response.json()
-    metadata = data['hits']['hits'][0]['metadata']
-    return str(metadata['doi']), str(metadata['publication_date'])
-
-
-if __name__ == '__main__':
-    path = Path('CITATION.cff')
-    citation = yaml.safe_load(path.read_text())
-    citation['doi'], citation['date-released'] = get_infos()
-    citation['version'] = sys.argv[1].removeprefix('v')
-    path.write_text(yaml.dump(citation, sort_keys=False, default_flow_style=False))