From 85d0fcb27e61adbcc57ee45318812cd9820629b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bobo=20B=C3=A4ck=20Engstr=C3=B6m?= Date: Mon, 24 Nov 2025 08:54:09 +0100 Subject: [PATCH] chore: add publish to test pypi workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bobo Bäck Engström --- .github/workflows/publish-to-test-pypi.yml | 67 ++++++++++++++++++++++ VERSION | 1 + pyproject.toml | 7 ++- uv.lock | 1 - 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish-to-test-pypi.yml create mode 100644 VERSION diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml new file mode 100644 index 0000000..a2911ec --- /dev/null +++ b/.github/workflows/publish-to-test-pypi.yml @@ -0,0 +1,67 @@ +name: publish-to-test-pypi + +on: + push: + branches: ["main"] + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c + with: + python-version: "3.x" + + - name: Install uv + uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2 + + - name: Install hatch + run: uv tool install hatch + + - name: Inject unique build tag into VERSION file + run: | + BASE_VERSION=$(cat VERSION) + BUILD=".dev${{ github.run_id }}${{ github.run_number }}${{ github.run_attempt }}" + echo "${BASE_VERSION}${BUILD}" > VERSION + + - name: Build distributions with uv + run: uv build --wheel + + - name: Upload distributions as artifact + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 + with: + name: python-package-distributions-${{ github.run_id }} + path: dist/ + + publish-to-test-pypi: + name: Publish Python distribution to TestPyPI + needs: [build] + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/python-dcm230 + + permissions: + id-token: write + + steps: + - name: Download all build artifacts + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + name: python-package-distributions-${{ github.run_id }} + path: dist/ + + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + verbose: true diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.1 diff --git a/pyproject.toml b/pyproject.toml index 2280060..fe84951 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "python-dcm230" -version = "0.0.1" +dynamic = ["version"] description = "Driver for Eastron DCM230 DC energy Meters using Modbus RTU" readme = "README.md" @@ -42,6 +42,11 @@ build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] packages = ["src/dcm230"] +[tool.hatch.version] +source = "regex" +path = "VERSION" +pattern = "(?P.*)" + [dependency-groups] dev = [ "pre-commit>=4.3.0", diff --git a/uv.lock b/uv.lock index a8eadad..fcab142 100644 --- a/uv.lock +++ b/uv.lock @@ -185,7 +185,6 @@ wheels = [ [[package]] name = "python-dcm230" -version = "0.0.1" source = { editable = "." } dependencies = [ { name = "pymodbus", extra = ["serial"] },