From c96fa3f9375c2b35793efa00296a0e1e28a58f11 Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Mon, 14 Jul 2025 11:21:29 +0800 Subject: [PATCH 1/5] Add citation.cff and note for citing in README #57 Signed-off-by: Chin Yeung Li --- CITATION.cff | 19 +++++++++++++++++++ README.rst | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000000..829b375524 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,19 @@ +cff-version: 1.2.0 +message: If you use this software, please cite it using these metadata. +title: ScanCode-Toolkit +authors: + - family-names: Philippe + given-names: Ombredanne + orcid: 'https://orcid.org/0000-0001-5280-9256' + - family-names: Ayan + given-names: Sinha Mahapatra + - family-names: Jono + given-names: Yang + - family-names: Georg + given-names: Brandl + - name: 'nexB Inc. and others.' +license: Apache-2.0 +url: 'https://github.com/aboutcode-org/scancode-toolkit' +# version: +# date-released: +# doi: diff --git a/README.rst b/README.rst index 413567056e..e023e6cb5f 100644 --- a/README.rst +++ b/README.rst @@ -134,6 +134,9 @@ Other Important Documentation Pages: See also https://aboutcode.org for related companion projects and tools. +To cite this repository, visit the main page and click on the 'Cite this +repository' button for APA or BibTeX citation formats. + Installation ============ From 74c44959878395f23a4b1932ba97877742b4f6e3 Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Wed, 23 Jul 2025 13:18:03 +0800 Subject: [PATCH 2/5] Add Ayan's orcid and remove individual author #57 Signed-off-by: Chin Yeung Li --- CITATION.cff | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 829b375524..d1cf26463a 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -7,10 +7,9 @@ authors: orcid: 'https://orcid.org/0000-0001-5280-9256' - family-names: Ayan given-names: Sinha Mahapatra + orcid: 'https://orcid.org/0009-0006-0174-5727' - family-names: Jono given-names: Yang - - family-names: Georg - given-names: Brandl - name: 'nexB Inc. and others.' license: Apache-2.0 url: 'https://github.com/aboutcode-org/scancode-toolkit' From ab20b92b6afb95cc30874435ed452ce2d1556887 Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Thu, 24 Jul 2025 12:35:37 +0800 Subject: [PATCH 3/5] Update DOI, version, and release date in citation.cff automatically when publishing #57 Signed-off-by: Chin Yeung Li --- .github/workflows/update-citation.yml | 46 +++++++++++++++++++++++++++ CITATION.cff | 3 -- etc/scripts/fetch_latest_doi.py | 18 +++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/update-citation.yml create mode 100644 etc/scripts/fetch_latest_doi.py diff --git a/.github/workflows/update-citation.yml b/.github/workflows/update-citation.yml new file mode 100644 index 0000000000..c833b30709 --- /dev/null +++ b/.github/workflows/update-citation.yml @@ -0,0 +1,46 @@ +name: Auto-update CITATION.cff + +on: + release: + types: [published] + +jobs: + update-citation: + runs-on: ubuntu-24.04 + + strategy: + max-parallel: 4 + matrix: + python-version: [3.13] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install doi2cff + run: + pip install + git+https://github.com/citation-file-format/doi2cff + + - name: Fetch latest Zenodo DOI + env: + ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }} + run: | + python etc/scripts/fetch_latest_doi.py > latest_doi.txt + echo "Latest DOI: $(cat latest_doi.txt)" + + - name: Update CITATION.cff + run: doi2cff update $(cat latest_doi.txt) + + - name: Commit updated CITATION.cff + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git add CITATION.cff + git commit -m "Update CITATION.cff with latest Zenodo DOI" + git push origin HEAD:develop diff --git a/CITATION.cff b/CITATION.cff index d1cf26463a..6890fb8d42 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -13,6 +13,3 @@ authors: - name: 'nexB Inc. and others.' license: Apache-2.0 url: 'https://github.com/aboutcode-org/scancode-toolkit' -# version: -# date-released: -# doi: diff --git a/etc/scripts/fetch_latest_doi.py b/etc/scripts/fetch_latest_doi.py new file mode 100644 index 0000000000..caa7d94c45 --- /dev/null +++ b/etc/scripts/fetch_latest_doi.py @@ -0,0 +1,18 @@ +import requests +import os + +CONCEPT_DOI = "10.5281/zenodo.16361290" +ZENODO_API = "https://zenodo.org/api/records" +TOKEN = os.getenv("ZENODO_TOKEN") + +params = { + "q": f"conceptdoi:{CONCEPT_DOI}", + "sort": "version", + "size": 1, + "access_token": TOKEN +} + +r = requests.get(ZENODO_API, params=params) +r.raise_for_status() +latest_record = r.json()["hits"]["hits"][0] +print(latest_record["doi"]) From deaee379f95ee4dbc1e84b2cd3a9bd04ecda7bbb Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Thu, 24 Jul 2025 15:13:59 +0800 Subject: [PATCH 4/5] Update workflow to create PR instead of pushing to develop directly #57 Signed-off-by: Chin Yeung Li --- .github/workflows/update-citation.yml | 41 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/.github/workflows/update-citation.yml b/.github/workflows/update-citation.yml index c833b30709..5c48cdfe68 100644 --- a/.github/workflows/update-citation.yml +++ b/.github/workflows/update-citation.yml @@ -11,7 +11,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.13] + python-version: [3.13] steps: - name: Checkout code @@ -20,27 +20,38 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python-version }} - name: Install doi2cff run: - pip install - git+https://github.com/citation-file-format/doi2cff + pip install + git+https://github.com/citation-file-format/doi2cff - name: Fetch latest Zenodo DOI + id: get-doi # Assign an ID to this step to reference its outputs env: - ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }} + ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }} run: | - python etc/scripts/fetch_latest_doi.py > latest_doi.txt - echo "Latest DOI: $(cat latest_doi.txt)" + ZENODO_DOI=$(python etc/scripts/fetch_latest_doi.py) + echo "ZENODO_DOI=${ZENODO_DOI}" >> "$GITHUB_OUTPUT" - name: Update CITATION.cff - run: doi2cff update $(cat latest_doi.txt) + # Use the output from the 'get-doi' step as the argument for doi2cff + run: doi2cff update ${{ steps.get-doi.outputs.ZENODO_DOI }} - - name: Commit updated CITATION.cff - run: | - git config user.name "github-actions" - git config user.email "github-actions@github.com" - git add CITATION.cff - git commit -m "Update CITATION.cff with latest Zenodo DOI" - git push origin HEAD:develop + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + base: develop + branch: update-citation-${{ github.event.release.tag_name }} + commit-message: + 'Automated: Update CITATION.cff with the latest Zenodo DOI' + title: 'Automated: Update CITATION.cff' + body: | + This is an automated pull request to update the `CITATION.cff` file + with the latest Zenodo DOI fetched from Zenodo repository. + # Set to true to automatically merge the PR if all checks pass (optional) + # automerge: true + # Set to true to delete the branch after merging (optional) + # delete-branch: true From 30b0952149fbbe6a7d83cd2b0b906bbf000112da Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Thu, 24 Jul 2025 15:27:47 +0800 Subject: [PATCH 5/5] Add permission field #57 Signed-off-by: Chin Yeung Li --- .github/workflows/update-citation.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/update-citation.yml b/.github/workflows/update-citation.yml index 5c48cdfe68..4e82d49f29 100644 --- a/.github/workflows/update-citation.yml +++ b/.github/workflows/update-citation.yml @@ -4,6 +4,10 @@ on: release: types: [published] +permissions: + contents: write # Required for creating branch and committing updates + pull-requests: write # Required for creating the pull request + jobs: update-citation: runs-on: ubuntu-24.04