feat: add python dist as release artifact, as input to enable publish to pypi

- The release workflow never runs automatically. It must be manually kicked off.
- The release workflow has an input. When running it from the GH actions UI, you will see a "Publish build on PyPi" prompt. If this value is "true", the workflow will upload the build to PyPi, releasing it. If this is anything else (e.g. "false", the default), the workflow will build but not upload to PyPi.
- The `dist/` folder (where the python package is built) is uploaded as a workflow artifact as a zip file. This can be downloaded and inspected. This allows "dry" runs of the workflow.
- The workflow job and some steps have been renamed to clarify what they do
This commit is contained in:
psychedelicious 2023-12-16 20:02:09 +11:00
parent 0f1c5f382a
commit 5bf61382a4

View File

@ -1,13 +1,15 @@
name: PyPI Release name: PyPI Release
on: on:
push:
paths:
- 'invokeai/version/invokeai_version.py'
workflow_dispatch: workflow_dispatch:
inputs:
publish_package:
description: 'Publish build on PyPi? [true/false]'
required: true
default: 'false'
jobs: jobs:
release: build-and-release:
if: github.repository == 'invoke-ai/InvokeAI' if: github.repository == 'invoke-ai/InvokeAI'
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
env: env:
@ -39,9 +41,15 @@ jobs:
- name: Install python dependencies - name: Install python dependencies
run: pip install --upgrade build twine run: pip install --upgrade build twine
- name: Build package - name: Build python package
run: python3 -m build run: python3 -m build
- name: Upload build as workflow artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- name: Check distribution - name: Check distribution
run: twine check dist/* run: twine check dist/*
@ -54,6 +62,6 @@ jobs:
EXISTS=scripts.pypi_helper.local_on_pypi(); \ EXISTS=scripts.pypi_helper.local_on_pypi(); \
print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV
- name: Upload package - name: Publish build on PyPi
if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' && github.event.inputs.publish_package == 'true'
run: twine upload dist/* run: twine upload dist/*