diff --git a/CHANGELOG.md b/CHANGELOG.md index eac04449..bbd5f181 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added +* Make citation optional [#471](https://github.com/NLeSC/python-template/pull/471) * Make online documentation optional [#476](https://github.com/NLeSC/python-template/pull/476) * Added Python 3.12 support [#356](https://github.com/NLeSC/python-template/issues/356) * Template unit tests for documentation generation, linting and version bumping diff --git a/README.md b/README.md index 3127f093..344f45dc 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Use this [Copier](https://copier.readthedocs.io) template to generate an empty P - [Contributing guidelines](template/CONTRIBUTING.md.jinja), - Continuous code quality and code coverage reporting using [Sonarcloud](https://sonarcloud.io/), - Automatic creation of [issues](template/.github/next_steps) with instructions how to pass all GitHub action workflows and integrate with services like Zenodo and Read the Docs, -- Instructions how to make package [citable](template/.github/next_steps/02_citation.md.jinja) +- Instructions how to make package [citable](.github/next_steps/%7B%25%20if%20AddCitation%20%25%7D02_citation.md%7B%25%20endif%20%25%7D.jinja) - FAIR software recommendation badge, - Optional [pre commit hook](template/README.dev.md.jinja#running-linters-locally) to catch lint errors early diff --git a/copier.yml b/copier.yml index 9fa671da..f6f2f0fc 100644 --- a/copier.yml +++ b/copier.yml @@ -83,6 +83,12 @@ AddGitHubActions: default: "{{ template_profile != 'minimum' }}" help: GitHub actions to test the package and the documentation +AddCitation: + when: "{{ template_profile == 'ask' }}" + type: bool + default: "{{ template_profile != 'minimum' }}" + help: Citation file and cffconvert workflow which validates the citation file + AddChangeLog: when: "{{ template_profile == 'ask' }}" type: bool diff --git a/profiles.md b/profiles.md index 52a36cdd..1544f7d3 100644 --- a/profiles.md +++ b/profiles.md @@ -2,8 +2,8 @@ - package_name: - version: - template_profile: - - minumum --> DONE - - recommeded --> all questions - excluded with the defaults + - minumum --> DONE + - recommeded --> all questions - excluded with the defaults - optional --> all questions with answers off - github_organization: @@ -11,7 +11,7 @@ - email: - copyright_holder: - licence (exist) - + - community: - code of conduct --> if TRUE ask for email - contributing guidelines @@ -20,7 +20,7 @@ - developer documentation - online documentation (read the docs) - project_setup.md - + - code quality: - sonarcloud - ruff and lint workflow @@ -30,7 +30,7 @@ - publishing and release - zenodo - - keywords + - keywords - changelog.md - cffconvert workflow and citation file diff --git a/template/.github/next_steps/02_citation.md.jinja b/template/.github/next_steps/{% if AddCitation %}02_citation.md{% endif %}.jinja similarity index 100% rename from template/.github/next_steps/02_citation.md.jinja rename to template/.github/next_steps/{% if AddCitation %}02_citation.md{% endif %}.jinja diff --git a/template/.github/workflows/next_steps.yml b/template/.github/workflows/next_steps.yml index 81f1855c..dc8ba159 100644 --- a/template/.github/workflows/next_steps.yml +++ b/template/.github/workflows/next_steps.yml @@ -11,39 +11,30 @@ jobs: - name: Create Sonarcloud integration issue uses: JasonEtco/create-an-issue@v2 env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: filename: .github/next_steps/01_sonarcloud_integration.md id: sonarcloud - - - name: Create citation data issue - uses: JasonEtco/create-an-issue@v2 - env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} - with: - filename: .github/next_steps/02_citation.md - id: citation - name: Create Zenodo integration issue uses: JasonEtco/create-an-issue@v2 env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: filename: .github/next_steps/04_zenodo_integration.md id: zenodo - name: Create linting issue uses: JasonEtco/create-an-issue@v2 env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: filename: .github/next_steps/05_linting.md id: linting - name: List created issues run: | echo 'Created issues that must be completed to have fully working Python package: - * Sonarcloud integration ${{ '{{ ' -}} steps.sonarcloud.outputs.url }} - * Zenodo integration ${{ '{{ ' -}} steps.zenodo.outputs.url }} - * Citation data ${{ '{{ ' -}} steps.citation.outputs.url }} - * Linting fixes ${{ '{{ ' -}} steps.linting.outputs.url }}' + * Sonarcloud integration ${{ steps.sonarcloud.outputs.url }} + * Zenodo integration ${{ steps.zenodo.outputs.url }} + * Linting fixes ${{ steps.linting.outputs.url }}' - name: Cleanup files needed to create next steps issues run: | git config --global user.name 'NLeSC Python template' diff --git a/template/.github/workflows/cffconvert.yml b/template/.github/workflows/{% if AddCitation %}cffconvert.yml{% endif %} similarity index 100% rename from template/.github/workflows/cffconvert.yml rename to template/.github/workflows/{% if AddCitation %}cffconvert.yml{% endif %} diff --git a/template/.github/workflows/{% if AddCitation %}next_steps_citation.yml{% endif %} b/template/.github/workflows/{% if AddCitation %}next_steps_citation.yml{% endif %} new file mode 100644 index 00000000..48269288 --- /dev/null +++ b/template/.github/workflows/{% if AddCitation %}next_steps_citation.yml{% endif %} @@ -0,0 +1,29 @@ +on: [push] +permissions: + contents: write + issues: write +name: Create an issue for citation +jobs: + next_steps: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create citation data issue + uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + filename: .github/next_steps/02_citation.md + id: citation + - name: List created issues + run: | + echo 'Created issues that must be completed to have fully working Python package: + * Citation data ${{ steps.citation.outputs.url }}' + - name: Cleanup files needed to create next steps issues + run: | + git config --global user.name 'NLeSC Python template' + git config --global user.email 'nlesc-python-template@users.noreply.github.com' + git rm .github/workflows/next_steps_citation.yml + git rm -r .github/next_steps + git commit -am "Cleanup automated next steps issue generator" + git push diff --git a/template/CONTRIBUTING.md.jinja b/template/CONTRIBUTING.md.jinja index d95b39cc..cc1a1787 100644 --- a/template/CONTRIBUTING.md.jinja +++ b/template/CONTRIBUTING.md.jinja @@ -47,8 +47,8 @@ In case you feel like you've made a valuable contribution, but you don't know ho To create a release you need write permission on the repository. -1. Check the author list in [`CITATION.cff`](CITATION.cff) -1. Bump the version using `bump-my-version bump `. For example, `bump-my-version bump major` will increase major version numbers everywhere it's needed (code, meta, etc.) in the repo. Alternatively the version can be manually changed in {{ package_name }}/__init__.py, pyproject.toml, CITATION.cff and docs/conf.py (and other places it was possibly added). +{% if AddCitation -%}1. Check the author list in [`CITATION.cff`](CITATION.cff){%- endif %} +1. Bump the version using `bump-my-version bump `. For example, `bump-my-version bump major` will increase major version numbers everywhere it's needed (code, meta, etc.) in the repo. Alternatively the version can be manually changed in {{ package_name }}/__init__.py, pyproject.toml, {% if AddCitation %}CITATION.cff{%- endif -%} and docs/conf.py (and other places it was possibly added). {% if AddChangeLog -%} 1. Update the `CHANGELOG.md` to include changes made {%- endif %} diff --git a/template/MANIFEST.in b/template/MANIFEST.in deleted file mode 100644 index f128825e..00000000 --- a/template/MANIFEST.in +++ /dev/null @@ -1,4 +0,0 @@ -include CITATION.cff -include LICENSE -include NOTICE -include README.md diff --git a/template/MANIFEST.in.jinja b/template/MANIFEST.in.jinja new file mode 100644 index 00000000..67ee1713 --- /dev/null +++ b/template/MANIFEST.in.jinja @@ -0,0 +1,4 @@ +{% if AddCitation -%}include CITATION.cff{%- endif %} +include LICENSE +include NOTICE +include README.md diff --git a/template/README.dev.md.jinja b/template/README.dev.md.jinja index 74abbe85..cc00e400 100644 --- a/template/README.dev.md.jinja +++ b/template/README.dev.md.jinja @@ -133,10 +133,8 @@ This section describes how to make a release in 3 parts: ### (1/3) Preparation -{% if AddChangeLog -%} -1. Update the (don't forget to update links at bottom of page) -{%- endif %} -1. Verify that the information in [`CITATION.cff`](CITATION.cff) is correct. +{% if AddChangeLog -%}1. Update the (don't forget to update links at bottom of page).{%- endif %} +{% if AddCitation -%}1. Verify that the information in [`CITATION.cff`](CITATION.cff) is correct.{%- endif %} 1. Make sure the [version has been updated](#versioning). 1. Run the unit tests with `pytest -v` diff --git a/template/README.md.jinja b/template/README.md.jinja index be608685..d8792190 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -18,7 +18,9 @@ {%- endif -%} | **GitHub Actions** |   | | Build | [![build]({{repository_url}}/actions/workflows/build.yml/badge.svg)]({{repository_url}}/actions/workflows/build.yml) | +{% if AddCitation -%} | Citation data consistency | [![cffconvert]({{repository_url}}/actions/workflows/cffconvert.yml/badge.svg)]({{repository_url}}/actions/workflows/cffconvert.yml) | +{%- endif -%} | SonarCloud | [![sonarcloud]({{repository_url}}/actions/workflows/sonarcloud.yml/badge.svg)]({{repository_url}}/actions/workflows/sonarcloud.yml) | | MarkDown link checker | [![markdown-link-check]({{repository_url}}/actions/workflows/markdown-link-check.yml/badge.svg)]({{repository_url}}/actions/workflows/markdown-link-check.yml) | diff --git a/template/project_setup.md.jinja b/template/project_setup.md.jinja index 14c196f4..ba015fc9 100644 --- a/template/project_setup.md.jinja +++ b/template/project_setup.md.jinja @@ -92,11 +92,13 @@ help you decide which tool to use for packaging. - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/releases?id=changelogmd) {%- endif %} +{% if AddCitation -%} ## CITATION.cff - To allow others to cite your software, add a `CITATION.cff` file - It only makes sense to do this once there is something to cite (e.g., a software release with a DOI). - Follow the [making software citable](https://guide.esciencecenter.nl/#/citable_software/making_software_citable) section in the guide. +{%- endif -%} ## CODE_OF_CONDUCT.md diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index 964e5185..2d868d06 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -151,8 +151,10 @@ filename = "src/{{ package_name }}/__init__.py" [[tool.bumpversion.files]] filename = "pyproject.toml" +{% if AddCitation -%} [[tool.bumpversion.files]] filename = "CITATION.cff" +{%- endif %} [[tool.bumpversion.files]] filename = "docs/conf.py" diff --git a/template/CITATION.cff.jinja b/template/{% if AddCitation %}CITATION.cff{% endif %}.jinja similarity index 100% rename from template/CITATION.cff.jinja rename to template/{% if AddCitation %}CITATION.cff{% endif %}.jinja