Skip to content

Commit 593a859

Browse files
committed
Improve testpypi
1 parent db3f54e commit 593a859

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/publish-to-testpypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
python-version: "3.x"
2727

2828
- name: Install pypa/build
29-
run: python3 -m pip install --user build
29+
run: python3 -m pip install --user build packaging
3030

3131
- name: Prepublish BS
3232
run: python3 testpypi_prepublish.py

testpypi_prepublish.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
"""
55

66
import argparse
7+
import copy
78
import re
89
import subprocess
910
import sys
10-
import tomllib
1111
from pathlib import (
1212
Path)
1313

14+
from packaging.version import (
15+
Version)
16+
1417
PYPROJECT_TOML = Path("pyproject.toml")
1518
VERSION_PY = Path("pathspec/_version.py")
1619

@@ -31,10 +34,14 @@ def update_pyproject_toml() -> None:
3134

3235
print(f"Read: {VERSION_PY}")
3336
version_input = VERSION_PY.read_text()
34-
version = re.search(
37+
raw_version = re.search(
3538
'^__version__\\s*=\\s*["\'](.+)["\']', version_input, re.M,
3639
).group(1)
37-
version += f".dev{count}"
40+
version = Version(raw_version)
41+
if not version.is_postrelease:
42+
version = copy.replace(version, post=1)
43+
44+
version = copy.replace(version, dev=count)
3845

3946
print(f"Read: {PYPROJECT_TOML}")
4047
output = PYPROJECT_TOML.read_text()

0 commit comments

Comments
 (0)