Skip to content

Merge pull request #142 from unixorn/bump-to-0.12.0 #9

Merge pull request #142 from unixorn/bump-to-0.12.0

Merge pull request #142 from unixorn/bump-to-0.12.0 #9

Workflow file for this run

# This workflow will build a Python wheel, a Docker image containing the CLI tool and publish both to PyPi and DockerHub
name: Build and publish
# Run only when pushing a Git version tag
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
build-wheel:
name: Build and publish Python package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Bump version and build package
run: |
# Extract the package version from the latest git tag, removing the leading `v`
VERSION=$(git describe --tags --abbrev=0 | sed --quiet --regexp-extended 's/v(.*)/\1/p')
echo "$VERSION"
# Set package version using poetry CLI
poetry version "$VERSION"
poetry build
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: Python package
path: dist/
if-no-files-found: error
- name: Publish wheel
run: |
poetry publish --username __token__ --password ${{ secrets.PYPI_PASSWORD }}
docker-image:
needs: build-wheel
name: Build and publish Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Python package
uses: actions/download-artifact@v3
with:
name: Python package
path: dist/
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
build-args: |
application_version: ${{ github.ref_name }}
push: true
platforms: linux/arm64,linux/amd64,linux/arm/v7
tags: unixorn/ha-mqtt-discoverable:${{ github.ref_name }}