Skip to content

Commit 086157b

Browse files
committed
add test publish gh action
1 parent 4e4e40b commit 086157b

3 files changed

Lines changed: 70 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
python-version: ["3.11", "3.12", "3.13"]
1616

1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v6
1919

2020
- name: Install uv
21-
uses: astral-sh/setup-uv@v5
21+
uses: astral-sh/setup-uv@v7
2222
with:
2323
enable-cache: true
2424

.github/workflows/test-publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish to Test PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
id-token: write # Required for trusted publishing
9+
10+
jobs:
11+
test-publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v6
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v6
20+
with:
21+
python-version: '3.12' # tomllib requires >= 3.11
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v7
25+
26+
- name: Append .dev suffix for unique Test PyPI versions
27+
run: |
28+
python -c "
29+
import tomllib, pathlib, re
30+
path = pathlib.Path('pyproject.toml')
31+
text = path.read_text()
32+
data = tomllib.loads(text)
33+
version = data['project']['version']
34+
dev_version = f'{version}.dev${{ github.run_number }}'
35+
# Only replace the version inside the [project] section to avoid
36+
# accidentally matching a version key in [tool.*] sections.
37+
def replace_in_project_section(text, old_ver, new_ver):
38+
project_match = re.search(r'^\[project\]', text, re.MULTILINE)
39+
if not project_match:
40+
raise RuntimeError('[project] section not found in pyproject.toml')
41+
start = project_match.start()
42+
# Find the next top-level section header or end of file
43+
next_section = re.search(r'^\[(?!project[.\]])', text[start+1:], re.MULTILINE)
44+
end = (start + 1 + next_section.start()) if next_section else len(text)
45+
section = text[start:end]
46+
section = re.sub(
47+
r'(version\s*=\s*\")' + re.escape(old_ver) + r'\"',
48+
r'\g<1>' + new_ver + '\"',
49+
section, count=1,
50+
)
51+
return text[:start] + section + text[end:]
52+
text = replace_in_project_section(text, version, dev_version)
53+
path.write_text(text)
54+
print(f'Version set to {dev_version}')
55+
"
56+
57+
- name: Build package
58+
run: uv build
59+
60+
- name: Publish to Test PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1
62+
with:
63+
repository-url: https://test.pypi.org/legacy/

src/designer_plugin/d3sdk/function.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
RegisterPayload,
2626
)
2727

28-
2928
logger = logging.getLogger(__name__)
3029

3130

@@ -261,7 +260,11 @@ def __init__(self, module_name: str, func: Callable[P, T]):
261260
# For example, jupyter notebook server can be running, but function signature can
262261
# change constantly.
263262
if self in D3Function._available_d3functions[module_name]:
264-
logger.warning("Function '%s' in module '%s' is being replaced.", self.name, module_name)
263+
logger.warning(
264+
"Function '%s' in module '%s' is being replaced.",
265+
self.name,
266+
module_name,
267+
)
265268
D3Function._available_d3functions[module_name].discard(self)
266269
D3Function._available_d3functions[module_name].add(self)
267270

0 commit comments

Comments
 (0)