Release Photons Interactor #129
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' | |
name: Release Photons Interactor | |
jobs: | |
interactor_static: | |
runs-on: ubuntu-latest | |
environment: docker | |
defaults: | |
run: | |
working-directory: apps/interactor/interactor_webapp/interactor | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 21.7.3 | |
- name: Install deps | |
shell: bash | |
run: npm ci | |
- name: Build | |
shell: bash | |
run: npm run build | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: webapp | |
path: apps/interactor/interactor_webapp/interactor/build/ | |
build: | |
name: Create the package | |
runs-on: ubuntu-latest | |
environment: docker | |
needs: interactor_static | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download static artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: webapp | |
path: apps/interactor/interactor_webapp/interactor/build/ | |
- uses: actions/setup-python@v5 | |
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/arm64,linux/amd64,linux/arm/v7,linux/arm/v6 | |
push: true | |
tags: | | |
${{ github.repository_owner }}/lifx-photons-interactor:latest | |
${{ github.repository_owner }}/lifx-photons-interactor:${{ steps.version.outputs.version }} |