From 3b051a11a46aa972094adde8a87bb37dd756231e Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Fri, 28 Feb 2025 18:22:42 -0500 Subject: [PATCH] [CI] Publish comfyui-frontend-package to pypi (#2774) --- .github/workflows/release.yaml | 64 +++++++++++++++++-- comfyui_frontend_package/.gitignore | 4 ++ comfyui_frontend_package/MANIFEST.in | 1 + comfyui_frontend_package/README.md | 13 ++++ .../comfyui_frontend_package/__init__.py | 0 comfyui_frontend_package/setup.py | 11 ++++ 6 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 comfyui_frontend_package/.gitignore create mode 100644 comfyui_frontend_package/MANIFEST.in create mode 100644 comfyui_frontend_package/README.md create mode 100644 comfyui_frontend_package/comfyui_frontend_package/__init__.py create mode 100644 comfyui_frontend_package/setup.py diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2953d79c2..637a81f39 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,11 +8,13 @@ on: - 'package.json' jobs: - draft_release: + build: runs-on: ubuntu-latest if: > github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'Release') + outputs: + version: ${{ steps.current_version.outputs.version }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -21,7 +23,7 @@ jobs: node-version: 'lts/*' - name: Get current version id: current_version - run: echo ::set-output name=version::$(node -p "require('./package.json').version") + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT - name: Build project env: SENTRY_DSN: ${{ secrets.SENTRY_DSN }} @@ -29,6 +31,24 @@ jobs: npm ci npm run build npm run zipdist + - name: Upload dist artifact + uses: actions/upload-artifact@v4 + with: + name: dist-files + path: | + dist/ + dist.zip + + draft_release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Download dist artifact + uses: actions/download-artifact@v4 + with: + name: dist-files - name: Create release id: create_release uses: softprops/action-gh-release@v2 @@ -37,17 +57,47 @@ jobs: with: files: | dist.zip - tag_name: v${{ steps.current_version.outputs.version }} + tag_name: v${{ needs.build.outputs.version }} target_commitish: ${{ github.event.pull_request.base.ref }} make_latest: ${{ github.event.pull_request.base.ref == 'main' }} draft: true prerelease: false generate_release_notes: true - publish_types: + + publish_pypi: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Download dist artifact + uses: actions/download-artifact@v4 + with: + name: dist-files + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install build dependencies + run: python -m pip install build + - name: Setup pypi package + run: | + mkdir -p comfyui_frontend_package/comfyui_frontend_package/static/ + cp -r dist/* comfyui_frontend_package/comfyui_frontend_package/static/ + - name: Build pypi package + run: python -m build + working-directory: comfyui_frontend_package + env: + COMFYUI_FRONTEND_VERSION: ${{ needs.build.outputs.version }} + - name: Publish pypi package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_TOKEN }} + packages-dir: comfyui_frontend_package/dist + + publish_types: + needs: build runs-on: ubuntu-latest - if: > - github.event.pull_request.merged == true && - contains(github.event.pull_request.labels.*.name, 'Release') steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/comfyui_frontend_package/.gitignore b/comfyui_frontend_package/.gitignore new file mode 100644 index 000000000..01ff74154 --- /dev/null +++ b/comfyui_frontend_package/.gitignore @@ -0,0 +1,4 @@ +comfyui_frontend_package/static/* +comfyui_frontend_package.egg-info/* + +__pycache__/ diff --git a/comfyui_frontend_package/MANIFEST.in b/comfyui_frontend_package/MANIFEST.in new file mode 100644 index 000000000..b8d8ede78 --- /dev/null +++ b/comfyui_frontend_package/MANIFEST.in @@ -0,0 +1 @@ +recursive-include comfyui_frontend_package/static * diff --git a/comfyui_frontend_package/README.md b/comfyui_frontend_package/README.md new file mode 100644 index 000000000..643aa4b6f --- /dev/null +++ b/comfyui_frontend_package/README.md @@ -0,0 +1,13 @@ +# comfyui_frontend pypi package + +This is the pypi package structure for the comfyui frontend. + +During build process, the compiled assets are copied into the `${PROJECT_ROOT}/comfyui_frontend_package/comfyui_frontend_package/static` directory. + +The package can be installed with the following command: + +```bash +pip install comfyui-frontend-package +``` + +Ref: diff --git a/comfyui_frontend_package/comfyui_frontend_package/__init__.py b/comfyui_frontend_package/comfyui_frontend_package/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/comfyui_frontend_package/setup.py b/comfyui_frontend_package/setup.py new file mode 100644 index 000000000..c316fbdd9 --- /dev/null +++ b/comfyui_frontend_package/setup.py @@ -0,0 +1,11 @@ +import os +from setuptools import setup, find_packages + +setup( + name="comfyui_frontend_package", + version=os.getenv("COMFYUI_FRONTEND_VERSION") or "0.1.0", + packages=find_packages(), + include_package_data=True, + install_requires=[], + python_requires=">=3.9", +)