2023-02-04 21:58:21 +00:00
|
|
|
name: PyPI Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
2023-12-16 09:02:09 +00:00
|
|
|
inputs:
|
|
|
|
publish_package:
|
|
|
|
description: 'Publish build on PyPi? [true/false]'
|
|
|
|
required: true
|
|
|
|
default: 'false'
|
2023-02-04 21:58:21 +00:00
|
|
|
|
|
|
|
jobs:
|
2023-12-16 09:02:09 +00:00
|
|
|
build-and-release:
|
2023-02-04 22:58:07 +00:00
|
|
|
if: github.repository == 'invoke-ai/InvokeAI'
|
2023-02-04 21:58:21 +00:00
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
env:
|
|
|
|
TWINE_USERNAME: __token__
|
|
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
|
|
TWINE_NON_INTERACTIVE: 1
|
|
|
|
steps:
|
2023-12-15 12:56:31 +00:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
2023-02-04 21:58:21 +00:00
|
|
|
|
2023-12-15 13:32:31 +00:00
|
|
|
- name: Setup Node 18
|
2023-12-15 12:56:31 +00:00
|
|
|
uses: actions/setup-node@v4
|
|
|
|
with:
|
2023-12-15 13:32:31 +00:00
|
|
|
node-version: '18'
|
2023-12-15 12:56:31 +00:00
|
|
|
|
|
|
|
- name: Setup pnpm
|
|
|
|
uses: pnpm/action-setup@v2
|
|
|
|
with:
|
2023-12-15 13:32:31 +00:00
|
|
|
version: '8.12.1'
|
2023-12-15 12:56:31 +00:00
|
|
|
|
|
|
|
- name: Install frontend dependencies
|
|
|
|
run: pnpm install --prefer-frozen-lockfile
|
2023-12-15 13:32:31 +00:00
|
|
|
working-directory: invokeai/frontend/web
|
2023-12-15 12:56:31 +00:00
|
|
|
|
|
|
|
- name: Build frontend
|
|
|
|
run: pnpm run build
|
2023-12-15 13:32:31 +00:00
|
|
|
working-directory: invokeai/frontend/web
|
2023-12-15 12:56:31 +00:00
|
|
|
|
|
|
|
- name: Install python dependencies
|
2023-02-04 21:58:21 +00:00
|
|
|
run: pip install --upgrade build twine
|
|
|
|
|
2023-12-16 09:02:09 +00:00
|
|
|
- name: Build python package
|
2023-02-04 21:58:21 +00:00
|
|
|
run: python3 -m build
|
|
|
|
|
2023-12-16 09:02:09 +00:00
|
|
|
- name: Upload build as workflow artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: dist
|
|
|
|
path: dist
|
|
|
|
|
2023-12-15 12:56:31 +00:00
|
|
|
- name: Check distribution
|
2023-02-04 21:58:21 +00:00
|
|
|
run: twine check dist/*
|
|
|
|
|
2023-12-15 12:56:31 +00:00
|
|
|
- name: Check PyPI versions
|
2023-10-13 16:49:24 +00:00
|
|
|
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')
|
2023-02-04 21:58:21 +00:00
|
|
|
run: |
|
|
|
|
pip install --upgrade requests
|
|
|
|
python -c "\
|
|
|
|
import scripts.pypi_helper; \
|
|
|
|
EXISTS=scripts.pypi_helper.local_on_pypi(); \
|
|
|
|
print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV
|
|
|
|
|
2023-12-16 09:02:09 +00:00
|
|
|
- name: Publish build on PyPi
|
|
|
|
if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' && github.event.inputs.publish_package == 'true'
|
2023-02-04 22:05:29 +00:00
|
|
|
run: twine upload dist/*
|