Skip to content

Commit fc8ceb5

Browse files
MiladMakdesiDexter9532
authored andcommitted
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 fc8ceb5

4 files changed

Lines changed: 75 additions & 3 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: ["main"]
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: 7 additions & 2 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,17 @@ 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 = "regex"
47+
path = "VERSION"
48+
pattern = "(?P<version>.*)"
49+
4550
[dependency-groups]
4651
dev = [
4752
"pre-commit>=4.3.0",

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)