From 4e9145f91c6a3c445f660f609a06bc94cf797e78 Mon Sep 17 00:00:00 2001 From: Emanuele Palazzetti Date: Sat, 2 Sep 2023 14:36:19 +0000 Subject: [PATCH] tools: add GitHub actions to automatically build the package on tag version --- .github/workflows/building.yaml | 50 +++++++++++++++++++++++++++++++++ pyproject.toml | 3 ++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/building.yaml diff --git a/.github/workflows/building.yaml b/.github/workflows/building.yaml new file mode 100644 index 0000000..c4e7ae5 --- /dev/null +++ b/.github/workflows/building.yaml @@ -0,0 +1,50 @@ +name: 'Building release package' + +on: + workflow_dispatch: + push: + tags: + - 'v*' + +permissions: + contents: read + +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Upgrade pip and install required tools + run: | + pip install --upgrade pip + pip install hatch + + - name: Build the package + run: hatch -v build -t sdist + + - name: Log package content + run: tar -tvf dist/*.tar.gz + + - name: Install the package + run: pip install dist/*.tar.gz + + - name: Test if the package is built correctly + run: python -c "import custom_components.econnect_alarm" + + - name: Upload release archive + uses: actions/upload-artifact@v3 + with: + name: econnect-alarm-{{ github.ref_name }} + path: dist/*.tar.gz diff --git a/pyproject.toml b/pyproject.toml index bf08d26..54433cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,3 +72,6 @@ allow-direct-references = true [tool.pytest.ini_options] asyncio_mode = "auto" + +[tool.hatch.build.targets.sdist] +only-include = ["custom_components/econnect_alarm"]