Skip to content

Add citation.cff and note for citing in README #4472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/update-citation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Auto-update CITATION.cff

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

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
id: get-doi # Assign an ID to this step to reference its outputs
env:
ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }}
run: |
ZENODO_DOI=$(python etc/scripts/fetch_latest_doi.py)
echo "ZENODO_DOI=${ZENODO_DOI}" >> "$GITHUB_OUTPUT"

- name: Update CITATION.cff
# Use the output from the 'get-doi' step as the argument for doi2cff
run: doi2cff update ${{ steps.get-doi.outputs.ZENODO_DOI }}

- 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
15 changes: 15 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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
orcid: 'https://orcid.org/0009-0006-0174-5727'
- family-names: Jono
given-names: Yang
- name: 'nexB Inc. and others.'
license: Apache-2.0
url: 'https://github.com/aboutcode-org/scancode-toolkit'
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this button added, will it be there automatically after a release?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you add a CITATION.cff file to the default branch of your repository, a link is automatically added to the repository landing page in the right sidebar, with the label "Cite this repository."

from https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files



Installation
============
Expand Down
18 changes: 18 additions & 0 deletions etc/scripts/fetch_latest_doi.py
Original file line number Diff line number Diff line change
@@ -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"])
Loading