diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index be6d488fe..d3c561f28 100644 --- a/.github/workflows/publish.yml +++ b/.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 diff --git a/.github/workflows/update_citation.py b/.github/workflows/update_citation.py deleted file mode 100755 index 236466175..000000000 --- a/.github/workflows/update_citation.py +++ /dev/null @@ -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))