You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78-2
Original file line number
Diff line number
Diff line change
@@ -281,7 +281,7 @@ setuptools.setup(
281
281
282
282
When you'll try to get current version in non-master branch, the content of this file will be returned instead.
283
283
284
-
### Development releases (prereleases) from another branch
284
+
### Development releases (prereleases) from `dev` branch
285
285
286
286
For example, current repo state is:
287
287
```
@@ -334,6 +334,79 @@ Then you decided to release new version:
334
334
-`N` in `.devN` suffix is a number of commits since the last change of a certain file.
335
335
-**Note: every change of this file in the `dev` branch will lead to this `N` suffix to be reset to `0`. Update this file only in the case when you've setting up the next release version!**
336
336
337
+
338
+
### Development releases (prereleases) from any branch (`feature`/`bugfix`/`preview`/`beta`/etc)
339
+
340
+
Just like previous example, but you want to make development releases (prereleases) with a branch name present in the version number.
341
+
342
+
In case of branch names which are PEP-440 compatible, you can just use `{branch}` substitution in a version template.
343
+
344
+
For example, if the branch name is something like `alpha`, `beta`, `preview` or `rc`:
345
+
```python
346
+
setuptools.setup(
347
+
...
348
+
version_config={
349
+
"count_commits_from_version_file": True,
350
+
"dev_template": "{tag}.{branch}{ccount}",
351
+
"dirty_template": "{tag}.{branch}{ccount}",
352
+
"version_file": VERSION_FILE
353
+
},
354
+
setup_requires=['setuptools-git-versioning'],
355
+
...
356
+
)
357
+
```
358
+
Adding a commit to the `alpha` branch will generate a version number like `1.2.3.alpha4`, new commit to the `beta` branch will generate a version number like `1.2.3.beta5` and so on.
359
+
360
+
It is also possible to use branch names prefixed with a major version number, like `1.0-alpha` or `1.1.beta`:
361
+
```python
362
+
setuptools.setup(
363
+
...
364
+
version_config={
365
+
"count_commits_from_version_file": True,
366
+
"dev_template": "{branch}{ccount}",
367
+
"dirty_template": "{branch}{ccount}",
368
+
"version_file": VERSION_FILE
369
+
},
370
+
setup_requires=['setuptools-git-versioning'],
371
+
...
372
+
)
373
+
```
374
+
Adding a commit to the `1.0-alpha` branch will generate a version number like `1.0.alpha2`, new commit to the `1.2.beta` branch will generate a version number like `1.2.beta3` and so on.
375
+
376
+
But if branch name is not PEP-440 compatible at all, like `feature/ABC-123` or `bugfix/ABC-123`, you'll get version number which `pip` cannot understand.
377
+
378
+
To fix that you can define a callback which will receive current branch name and return a propery formatted one:
379
+
```python
380
+
import re
381
+
382
+
defformat_branch_name(name):
383
+
# If branch has name like "bugfix/issue-1234-bug-title", take only "1234" part
0 commit comments