Release Photons Interactor #77
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_dispatch: | |
inputs: | |
skippypi: | |
description: 'Skip making pypi package' | |
default: '0' | |
skipdockermain: | |
description: 'Skip making main docker image' | |
default: '0' | |
skipdockerha: | |
description: 'Skip making docker image for home assistant' | |
default: '0' | |
name: Release Photons Interactor | |
jobs: | |
build: | |
name: Create the package | |
runs-on: ubuntu-latest | |
environment: docker | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
- run: python3 -m pip install venvstarter | |
- id: build | |
run: cd apps/interactor && pip install hatch==1.6.3 && hatch build | |
- id: version | |
run: | | |
VERSION=$(python -c "import runpy; print(runpy.run_path('apps/interactor/interactor/__init__.py')['VERSION'])") | |
VERSIONDASH=$(python -c "import runpy; print(runpy.run_path('apps/interactor/interactor/__init__.py')['VERSION'].replace('.', '-'))") | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "versiondash=$VERSIONDASH" >> $GITHUB_OUTPUT | |
- id: package | |
run: > | |
echo "package=lifx_photons_interactor-${{ steps.version.outputs.version}}.tar.gz" >> $GITHUB_OUTPUT | |
- id: create_release | |
uses: actions/create-release@v1 | |
if: github.event.inputs.skippypi == '0' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "release-interactor-${{ steps.version.outputs.version }}" | |
release_name: Photons Interactor ${{ steps.version.outputs.version }} | |
body: "https://photons.delfick.com/apps/interactor/changelog.html#release-interactor-${{ steps.version.outputs.versiondash }}" | |
draft: false | |
prerelease: false | |
- id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
if: github.event.inputs.skippypi == '0' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: "apps/interactor/dist/${{ steps.package.outputs.package }}" | |
asset_name: ${{ steps.package.outputs.package }} | |
asset_content_type: application/tar+gzip | |
- uses: pypa/[email protected] | |
if: github.event.inputs.skippypi == '0' | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_INTERACTOR }} | |
packages_dir: apps/interactor/dist | |
- name: Get the docker context | |
env: | |
VERSION: "${{ steps.version.outputs.version }}" | |
run: | | |
set -e | |
mkdir staging | |
cd staging | |
../apps/interactor/docker/harpoon get_docker_context lifx-photons-interactor | |
tar xf context_lifx-photons-interactor.tar | |
rm context_lifx-photons-interactor.tar | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
if: github.event.inputs.skipdockermain == '0' | |
with: | |
context: staging | |
file: ./staging/Dockerfile | |
platforms: linux/386,linux/arm64,linux/amd64,linux/arm/v6 | |
push: true | |
tags: | | |
${{ github.repository_owner }}/lifx-photons-interactor:latest | |
${{ github.repository_owner }}/lifx-photons-interactor:${{ steps.version.outputs.version }} |