From b2a8c45553639650eeccd212042eae6178cd6e7a Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 15 Dec 2023 23:56:31 +1100 Subject: [PATCH 1/5] fix: build frontend in pypi-release workflow This was missing, resulting in the 3.5.0rc1 having no frontend. --- .github/workflows/pypi-release.yml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 5b7d2cd2fa..452454b072 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -15,19 +15,35 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} TWINE_NON_INTERACTIVE: 1 steps: - - name: checkout sources - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 - - name: install deps + - name: Setup Node 20 + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Install frontend dependencies + run: pnpm install --prefer-frozen-lockfile + + - name: Build frontend + run: pnpm run build + + - name: Install python dependencies run: pip install --upgrade build twine - - name: build package + - name: Build package run: python3 -m build - - name: check distribution + - name: Check distribution run: twine check dist/* - - name: check PyPI versions + - name: Check PyPI versions if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') run: | pip install --upgrade requests @@ -36,6 +52,6 @@ jobs: EXISTS=scripts.pypi_helper.local_on_pypi(); \ print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV - - name: upload package + - name: Upload package if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' run: twine upload dist/* From 1615df3aa160296d0ba6e54d8082efe3a7582622 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sat, 16 Dec 2023 00:32:31 +1100 Subject: [PATCH 2/5] fix: use node 18, set working directory - Node 20 has a problem with `pnpm`; set it to Node 18 - Set the working directory for the frontend commands --- .github/workflows/lint-frontend.yml | 6 +++--- .github/workflows/pypi-release.yml | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint-frontend.yml b/.github/workflows/lint-frontend.yml index 3b354d1003..a4e1bba428 100644 --- a/.github/workflows/lint-frontend.yml +++ b/.github/workflows/lint-frontend.yml @@ -21,16 +21,16 @@ jobs: if: github.event.pull_request.draft == false runs-on: ubuntu-22.04 steps: - - name: Setup Node 20 + - name: Setup Node 18 uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '18' - name: Checkout uses: actions/checkout@v4 - name: Setup pnpm uses: pnpm/action-setup@v2 with: - version: 8 + version: '8.12.1' - name: Install dependencies run: 'pnpm install --prefer-frozen-lockfile' - name: Typescript diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 452454b072..32648cfc57 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -18,21 +18,23 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup Node 20 + - name: Setup Node 18 uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '18' - name: Setup pnpm uses: pnpm/action-setup@v2 with: - version: 8 + version: '8.12.1' - name: Install frontend dependencies run: pnpm install --prefer-frozen-lockfile + working-directory: invokeai/frontend/web - name: Build frontend run: pnpm run build + working-directory: invokeai/frontend/web - name: Install python dependencies run: pip install --upgrade build twine From 3f970c8326244d653a0b0acaf9c351a969593f9f Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 15 Dec 2023 11:27:21 -0500 Subject: [PATCH 3/5] Don't copy extraneous paths into installer .zip --- installer/create_installer.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/installer/create_installer.sh b/installer/create_installer.sh index ed8cbb0d0a..722fe5771a 100755 --- a/installer/create_installer.sh +++ b/installer/create_installer.sh @@ -91,9 +91,11 @@ rm -rf InvokeAI-Installer # copy content mkdir InvokeAI-Installer -for f in templates lib *.txt *.reg; do +for f in templates *.txt *.reg; do cp -r ${f} InvokeAI-Installer/ done +mkdir InvokeAI-Installer/lib +cp lib/*.py InvokeAI-Installer/lib # Move the wheel mv dist/*.whl InvokeAI-Installer/lib/ From 0f1c5f382a681552d7903d016bcddb9a5f15e26c Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sat, 16 Dec 2023 19:39:29 +1100 Subject: [PATCH 4/5] feat(installer): delete frontend build after creating installer This prevents an empty `dist/` from breaking the app on startup. --- installer/create_installer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/create_installer.sh b/installer/create_installer.sh index 722fe5771a..b32f65d9bf 100755 --- a/installer/create_installer.sh +++ b/installer/create_installer.sh @@ -113,6 +113,6 @@ cp WinLongPathsEnabled.reg InvokeAI-Installer/ zip -r InvokeAI-installer-$VERSION.zip InvokeAI-Installer # clean up -rm -rf InvokeAI-Installer tmp dist +rm -rf InvokeAI-Installer tmp dist ../invokeai/frontend/web/dist/ exit 0 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 5/5] 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/*