FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add support for adding .cff-file variable in version_variables · Issue #962 · python-semantic-release/python-semantic-release · GitHub

Repository navigation

Add support for adding .cff-file variable in version_variables #962

Description

When you have a CITATION.cff file in a python project, the package version is stored in a variable version in this file which needs to be updated for each release, i.e.:

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: Druskat
    given-names: Stephan
    orcid: https://orcid.org/1234-5678-9101-1121
title: "My Research Software"
version: 2.0.4
identifiers:
  - type: doi
    value: 10.5281/zenodo.1234
date-released: 2021-08-11

Request support for adding CITATION.cff to version_variables list.

Activity

  1. added
    featureA new feature or a feature request
    confirmedPrevent from becoming stale
    on Jun 21, 2024
  2. codejedi365 commented on Jun 21, 2024

    Contributor

    @geddy11, the version variables specification is fairly flexible, you should be able to use filename:variable like this:

    [tool.semantic_release]
    version_variables = [
        "CITATION.cff:version",
    ]

    Since the citation.cff is valid yaml, it should work as it did over in #601. The minor nuance is that you likely will need to wrap the version value in quotes which is still valid yaml but it makes the regex match properly.

  3. added and removed
    confirmedPrevent from becoming stale
    on Jun 21, 2024
  4. geddy11 commented on Jun 21, 2024

    Author

    Wrapping version value in quotes works. GitHub "Cite this repository"-function also handles quotes apparently, so this is acceptable solution.

  5. added and removed
    featureA new feature or a feature request
    on Jun 21, 2024
  6. codejedi365 commented on Sep 27, 2024

    Contributor

    🎉 This resolution has been included in version 9.8.9 🎉

    The release is available on:


    @geddy11, I know we resolved this question earlier but I wanted to let you know of the latest release which has a more flexible regular expression now that you will no longer need quotes around your version number inside your yaml file.

  7. afuetterer commented on Nov 12, 2024

    Contributor

    This is great. Thanks for the addition.

    Is there a way to update date-released: 2021-08-11 (see example above) with the current date, when the version in citation.cff is bumped? I am still using the proposed sed workflow from #912.

  8. codejedi365 commented on Nov 12, 2024

    Contributor

    @afuetterer, there isn't a way through a build command variable unless you calculate your own date in the shell script. I think I have a sed line in the other PR that would update the date in option 1 if that's the way you want to go.

    I'm not sure why I didn't think of this before but it might be a better alternative to utilize the custom changelog templating engine. There would be lot more variables and context available to update your files.

    1. Create a folder templates
    2. Copy the directory from inside PSR (where you installed PSR, or here on GitHub) data/templates/angular/md into templates.
    3. Create a CITATION.cff.j2 in the templates folder. Add your default contents and then some jinja replacement variables.
    {%- set release = ctx.history.released.values() | first -%}
    cff-version: 1.2.0
    message: "If you use this software, please cite it as below."
    authors:
      - family-names: Druskat
        given-names: Stephan
        orcid: https://orcid.org/1234-5678-9101-1121
    title: "My Research Software"
    version: {{ release.version | string }}
    identifiers:
      - type: doi
        value: 10.5281/zenodo.1234
    date-released: {{ release.tagged_date.strftime("%Y-%m-%d") }}

    WARNING: Not tested but should get you close.

    With this solution the file will be generated/updated through the changelog generation activities either with the changelog command or during the version command.

    The downside to this is that you will have to maintain your own changelog templates instead of PSR maintaining the default ones. If the release notes file doesn't exist however, it will fall back to PSRs internal default template.

  9. afuetterer commented on Dec 10, 2024

    Contributor

    Thank you @codejedi365. I will try that. I already have my own templates in place, so another one is not a big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL