Skip to content

Commit

Permalink
tools: add GitHub actions to automatically build the package on tag v…
Browse files Browse the repository at this point in the history
…ersion (#20)

#20
  • Loading branch information
palazzem committed Sep 2, 2023
1 parent 1515859 commit 0d7254c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/building.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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: Detect build version
run: echo "PKG_VERSION=$(hatch version)" >> "$GITHUB_ENV"

- name: Build the package
run: hatch -v build -t sdist

- name: Log package content
run: tar -tvf dist/econnect_alarm-$PKG_VERSION.tar.gz

- name: Install the package
run: pip install dist/econnect_alarm-$PKG_VERSION.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-${{ env.PKG_VERSION }}.tar.gz
path: dist/econnect_alarm-${{ env.PKG_VERSION }}.tar.gz
if-no-files-found: error
2 changes: 1 addition & 1 deletion .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:

jobs:
econnect:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Check out repository code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:

jobs:
econnect:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
TOX_SKIP_ENV: lint

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 0d7254c

Please sign in to comment.