Skip to content

prepare 0.47.0 release #155

prepare 0.47.0 release

prepare 0.47.0 release #155

name: Upload Python Package and Docker Image
on:
push:
tags:
- "v*"
jobs:
python-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Version from input
if: github.event_name != 'push'
run: |
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Version from pushed tag
if: github.event_name == 'push'
run: |
# from refs/tags/v1.2.3 get 1.2.3
echo "version=$(echo $GITHUB_REF | sed 's#.*/v##')" >> $GITHUB_ENV
- name: Autobump version
run: |
PLACEHOLDER="__version__ = 'develop'"
REPLACEMENT="__version__ = '${{ env.version }}'"
VERSION_FILE="weconnect_mqtt/__version.py"
# ensure the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
grep "$PLACEHOLDER" "$VERSION_FILE"
sed -i "s/$PLACEHOLDER/$REPLACEMENT/g" "$VERSION_FILE"
grep "$REPLACEMENT" "$VERSION_FILE"
shell: bash
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
docker-deploy:
needs: [python-deploy]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Version from input
if: github.event_name != 'push'
run: |
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Version from pushed tag
if: github.event_name == 'push'
run: |
# from refs/tags/v1.2.3 get 1.2.3
echo "version=$(echo $GITHUB_REF | sed 's#.*/v##')" >> $GITHUB_ENV
- name: Wait for PIPY to have the version available
run: |
pip3 download weconnect-mqtt==${{ env.version }} > /dev/null
while [ $? -ne 0 ]; do sleep 10; pip3 download weconnect-mqtt==${{ env.version }}; done
shell: bash {0}
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: |
tillsteinbach/weconnect-mqtt
ghcr.io/tillsteinbach/weconnect-mqtt
tags: |
type=raw,value=edge
type=pep440,pattern={{version}}
- name: Set up QEMU
uses: docker/[email protected]
- name: Setup Docker Buildx
uses: docker/[email protected]
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/[email protected]
with:
context: docker
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=${{ env.version }}
cache-from: type=gha
cache-to: type=gha,mode=max