From 2151c952c256ead9f215eb2efcdae57609c94bc1 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 22 Jun 2023 11:30:34 +0200 Subject: [PATCH 1/3] Don't trigger GitHub action twice on pre-releases --- .github/workflows/publish-to-pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 5756a93c..3ff0b24b 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -2,7 +2,7 @@ name: Publish releases to PyPI on: release: - types: [published, prereleased] + types: [published] jobs: build-and-publish: From 8ce0d59a9b99d48b4502f1cad774534b48981e96 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 22 Jun 2023 11:17:46 +0200 Subject: [PATCH 2/3] Use version number from GitHub release tag --- .github/workflows/publish-to-pypi.yml | 18 +++++++++++++++++- pyproject.toml | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 3ff0b24b..4114b27f 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -10,13 +10,29 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.5.3 + - name: Get tag + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - name: Set up Python 3.10 uses: actions/setup-python@v4.6.1 with: python-version: "3.10" - name: Install build run: >- - pip install build + pip install build tomli tomli-w + - name: Set Python project version from tag + shell: python + run: |- + import tomli + import tomli_w + + with open("pyproject.toml", "rb") as f: + pyproject = tomli.load(f) + + pyproject["project"]["version"] = "${{ steps.vars.outputs.tag }}" + + with open("pyproject.toml", "wb") as f: + tomli_w.dump(pyproject, f) - name: Build run: >- python3 -m build diff --git a/pyproject.toml b/pyproject.toml index 58b78b63..3ba66f49 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "python-matter-server" -version = "3.5.1" +version = "0.0.0" license = {text = "Apache-2.0"} description = "Python Matter WebSocket Server" readme = "README.md" From 44de51e01231d8ec57b6f3419c907e272019b87b Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 22 Jun 2023 15:58:47 +0200 Subject: [PATCH 3/3] Update pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 3ba66f49..eb197ebe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "python-matter-server" +# The version is set by GH action on release version = "0.0.0" license = {text = "Apache-2.0"} description = "Python Matter WebSocket Server"