Skip to content

Commit 04eee2d

Browse files
committed
feat: add publish-to-test-pypi.yml
Signed-off-by: Milad Makdesi <milad@id8-engineering.io>
1 parent 1a8fcb4 commit 04eee2d

4 files changed

Lines changed: 79 additions & 5 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: publish-to-test-pypi
2+
3+
on:
4+
push:
5+
branches: ["test_pypi"]
6+
7+
jobs:
8+
build:
9+
name: Build distribution
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
18+
with:
19+
python-version: "3.x"
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
23+
24+
- name: Install hatch
25+
run: uv tool install hatch
26+
27+
- name: Build distributions with uv
28+
run: uv build
29+
30+
- name: DEBUG - list installed packages
31+
run: uv pip list
32+
33+
- name: Upload distributions as artifact
34+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
35+
with:
36+
name: python-package-distributions
37+
path: dist/
38+
39+
publish-to-test-pypi:
40+
name: Publish Python distribution to TestPyPI
41+
needs: [build]
42+
runs-on: ubuntu-latest
43+
44+
environment:
45+
name: testpypi
46+
url: https://test.pypi.org/p/python-em511
47+
48+
permissions:
49+
id-token: write
50+
51+
steps:
52+
- name: Download all build artifacts
53+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
54+
with:
55+
name: python-package-distributions
56+
path: dist/
57+
58+
- name: Publish to TestPyPI
59+
uses: pypa/gh-action-pypi-publish@release/v1
60+
with:
61+
repository-url: https://test.pypi.org/legacy/

pyproject.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "python-em511"
3-
version = "0.0.1"
3+
dynamic = ["version"]
44
description = "Driver for Carlo Gavazzi EM511 Series Single Phase Energy Meters using Modbus RTU"
55
readme = "README.md"
66

@@ -36,12 +36,19 @@ classifiers = [
3636
]
3737

3838
[build-system]
39-
requires = ["hatchling"]
39+
requires = ["hatchling", "uv-dynamic-versioning"]
4040
build-backend = "hatchling.build"
4141

4242
[tool.hatch.build.targets.wheel]
4343
packages = ["src/em511"]
4444

45+
[tool.hatch.version]
46+
source = "uv-dynamic-versioning"
47+
48+
[tool.uv-dynamic-versioning]
49+
enable = true
50+
vcs = "git"
51+
4552
[dependency-groups]
4653
dev = [
4754
"pre-commit>=4.3.0",
@@ -57,7 +64,7 @@ line-length = 120
5764
select = ["ALL"]
5865

5966
ignore = [
60-
"COM812", # in conflict with formatter
67+
"COM812", # in conflict with formatter
6168
]
6269

6370
[tool.ruff.lint.pydocstyle]

src/em511/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
using Carlo Gavazzi EM511 energy meters.
55
"""
66

7+
from importlib.metadata import PackageNotFoundError, version
8+
79
from .em511 import Em511
810

9-
__all__ = ["Em511"]
11+
__all__ = ["Em511", "__version__"]
12+
13+
try:
14+
__version__ = version("python-em511")
15+
except PackageNotFoundError:
16+
__version__ = "0.0.5"

uv.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)