carstencodes/pdm-bump

Feature request: manually set version

Closed this issue · 5 comments

edsq commented

It would be nice to be able to manually set the version, e.g.

$ pdm bump 1.0.1.customversion1234
Performing increment of version: 1.0.0 -> 1.0.1.customversion1234

As an example use case, I have a CI workflow for publishing a test release on TestPyPI. To avoid name+version conflicts, I perform a patch bump, then append .dev$(date +%s) to get a unique development version using the date in seconds. It would simplify things greatly if the script were as simple as:

pdm bump patch
pdm bump $(pdm show --version).dev$(date +%s)

(Of course, it would simplify things even more if this kind of datetime based dev versioning were implemented natively, but that feels like it might be too specific a use case.)

This could be implemented as an optional argument like pdm bump --custom 1.0.1.customversion1234, if that feels better.

I am actually thinking of something similar.

On the current roadmap, there is a build-hook, which should be available with rev 0.7.0 or fully-fledged with 0.8.0. A rough implementation is available on my private gitea.

The basic idea is to provide an auto command. If the hook is acivated using the pdm configuration file OR pyproject, the auto command will be called each time, pdm build or pdm run is called.

Within the configuration, templates can be applied like

  • dev
  • local
  • alpha

The version increment is available by adding one of the following place-holders:

  • commit_id
  • commits (since last tag)
  • timestamp/date (formatted)
  • a combination of the above

Would that fit your needs, @edsq ?

Otherwise I would actually add a to command doing as requested above.

Unfortunately, I cannot provide a roadmap yet, but it migh be in mid of march.

edsq commented

That would be perfect! I think I would still need a to command, though, so that I could reset the version after a temporary bump (unless you're interested in also addding that functionality to the auto command!). If you'd point me in the right direction to get started, I'd be happy to take a shot at implementing it.

I think I have to refactor the actions and commandline parser coupling to do so. This should be done by the end of the month at least. I had to postpone this due to some overtime at work during the last weeks.

@edsq I finally managed to create a first draft implementation. Feel free to test it.

edsq commented

Thank you! It does just what I need.