From 5bf61382a40923cc013edb1d4b94518517b25715 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sat, 16 Dec 2023 20:02:09 +1100 Subject: [PATCH] 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 --- .github/workflows/pypi-release.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 32648cfc57..162cbe3427 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -1,13 +1,15 @@ name: PyPI Release on: - push: - paths: - - 'invokeai/version/invokeai_version.py' workflow_dispatch: + inputs: + publish_package: + description: 'Publish build on PyPi? [true/false]' + required: true + default: 'false' jobs: - release: + build-and-release: if: github.repository == 'invoke-ai/InvokeAI' runs-on: ubuntu-22.04 env: @@ -39,9 +41,15 @@ jobs: - name: Install python dependencies run: pip install --upgrade build twine - - name: Build package + - name: Build python package run: python3 -m build + - name: Upload build as workflow artifact + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist + - name: Check distribution run: twine check dist/* @@ -54,6 +62,6 @@ jobs: EXISTS=scripts.pypi_helper.local_on_pypi(); \ print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV - - name: Upload package - if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' + - name: Publish build on PyPi + if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' && github.event.inputs.publish_package == 'true' run: twine upload dist/*