Skip to content

Commit 61f8bac

Browse files
committed
feat: add publish-to-test-pypi.yml
Signed-off-by: Milad Makdesi <milad@id8-engineering.io> Signed-off-by: Bobo Bäck Engström <bobo@id8-engineering.io>
1 parent 1a8fcb4 commit 61f8bac

4 files changed

Lines changed: 79 additions & 5 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
20+
with:
21+
python-version: "3.x"
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
25+
26+
- name: Install hatch
27+
run: uv tool install hatch
28+
29+
- name: Inject unique build tag into VERSION file
30+
run: |
31+
BASE_VERSION=$(cat VERSION)
32+
BUILD=".dev${{ github.run_id }}${{ github.run_number }}${{ github.run_attempt }}"
33+
echo "${BASE_VERSION}${BUILD}" > VERSION
34+
35+
- name: Build distributions with uv
36+
run: uv build --wheel
37+
38+
- name: Upload distributions as artifact
39+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
40+
with:
41+
name: python-package-distributions-${{ github.run_id }}
42+
path: dist/
43+
44+
publish-to-test-pypi:
45+
name: Publish Python distribution to TestPyPI
46+
needs: [build]
47+
runs-on: ubuntu-latest
48+
49+
environment:
50+
name: testpypi
51+
url: https://test.pypi.org/p/python-em511
52+
53+
permissions:
54+
id-token: write
55+
56+
steps:
57+
- name: Download all build artifacts
58+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
59+
with:
60+
name: python-package-distributions-${{ github.run_id }}
61+
path: dist/
62+
63+
- name: Publish to TestPyPI
64+
uses: pypa/gh-action-pypi-publish@release/v1
65+
with:
66+
repository-url: https://test.pypi.org/legacy/
67+
verbose: true

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

pyproject.toml

Lines changed: 11 additions & 4 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

@@ -17,15 +17,16 @@ maintainers = [
1717
{ name = "Bobo Bäck Engström", email = "bobo@id8-engineering.io"},
1818
{ name = "Milad Makdesi", email = "milad@id8-engineering.io"},
1919
]
20+
2021
requires-python = ">=3.10"
22+
2123
dependencies = [
2224
"pymodbus[serial]>=3.11"
2325
]
2426

2527
classifiers = [
2628
"Development Status :: 3 - Alpha",
2729
"Intended Audience :: Developers",
28-
"License :: OSI Approved :: MIT License",
2930
"Operating System :: OS Independent",
3031
"Programming Language :: Python :: 3.10",
3132
"Programming Language :: Python :: 3.11",
@@ -36,12 +37,17 @@ classifiers = [
3637
]
3738

3839
[build-system]
39-
requires = ["hatchling"]
40+
requires = ["hatchling", "uv-dynamic-versioning"]
4041
build-backend = "hatchling.build"
4142

4243
[tool.hatch.build.targets.wheel]
4344
packages = ["src/em511"]
4445

46+
[tool.hatch.version]
47+
source = "regex"
48+
path = "VERSION"
49+
pattern = "(?P<version>.*)"
50+
4551
[dependency-groups]
4652
dev = [
4753
"pre-commit>=4.3.0",
@@ -52,12 +58,13 @@ dev = [
5258

5359
[tool.ruff]
5460
line-length = 120
61+
exclude = ["src/em511/_version.py"]
5562

5663
[tool.ruff.lint]
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]

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)