Skip to content

Commit

Permalink
merged in main
Browse files Browse the repository at this point in the history
  • Loading branch information
telamonian committed Sep 6, 2024
1 parent 4cc80f6 commit 3d38221
Show file tree
Hide file tree
Showing 17 changed files with 376 additions and 71 deletions.
21 changes: 21 additions & 0 deletions .github/actions/build/macos/comfy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build Comfycli for Macos
description: Download, install, and set up Comfy
runs:
using: composite
steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Make Standalone
shell: sh
run: |
python -m pip install --upgrade pip
pip install comfy-cli
cd assets
comfy --skip-prompt --workspace ./ComfyUI install --fast-deps --m-series --skip-manager
comfy --workspace ./ComfyUI standalone --platform macos
comfy standalone --rehydrate
ls
# - name: Sign Wheels
# uses: ./.github/actions/build/macos/signwheel
Empty file.
24 changes: 24 additions & 0 deletions .github/actions/build/macos/signing/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup Apple Signing
description: Setup everything to sign and notarize
inputes:
CERTIFICATE_OSX_APPLICATION:
required: true
type: string
CERTIFICATE_PASSWORD:
required: true
type: string
runs:
using: composite
steps:
- name: Add MacOS certs
shell: sh
run: cd scripts && chmod +x add-osx-cert.sh && ./add-osx-cert.sh
env:
CERTIFICATE_OSX_APPLICATION: ${{ inputs.CERTIFICATE_OSX_APPLICATION }}
CERTIFICATE_PASSWORD: ${{ inputs.CERTIFICATE_PASSWORD }}
- name: Set ID
shell: sh
run: |
SIGN_ID=$(security find-identity -p codesigning -v | grep -E "Developer ID" | sed -n -e 's/.* "/"/p' | tr -d '""')
echo "SIGN_ID=$SIGN_ID" >> $GITHUB_ENV
20 changes: 20 additions & 0 deletions .github/actions/build/macos/signwheel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Sign Wheels
description: Unpack Sign Wheels and then RePack
runs:
using: composite
steps:
- name: Unpack
shell: sh
run: |
cd ./assets/python/wheels
find . -name '*.whl' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \;
find . -name "*.whl" -type f -delete
- name: Gather and Sign
shell: sh
run: |
cd ./assets/python/wheels
find . -name "*so" -o -name "*.dylib" -print0 | while read -d $'\0' file; do codesign --sign 6698D856280DC1662A8E01E5B63428CB6D6651BB --force --timestamp --options runtime --entitlements ../../entitlements.mac.plist "$file"; done
- name: Repack
shell: sh
run: |
for i in */; do zip -r "${i%/}.whl" "$i"; done
38 changes: 13 additions & 25 deletions .github/actions/build/windows/app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,32 @@ name: Windows Build App
description: Electron-Forge Build/Sign/publish
inputs:
DIGICERT_FINGERPRINT:
description: 'DigiCert SHA256 Fingerprint'
required: true
type: string
GITHUB_TOKEN:
description: 'GitHub Token'
required: true
type: string
sign-and-publish:
description: 'Sign the executable and publish to release page'
default: false
required: false
type: boolean
build-targets:
description: Override the default targets and build the passed targets. Comma separated list. Include '--target' and full names, eg '--targets=@electron-forge/maker-squirrel, ...etc'
required: false
default: ''
type: string
runs:
using: composite
steps:
- name: Use Node.js 20.x
uses: JP250552/setup-node@feature/corepack
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
corepack: true
- run: yarn install --immutable
node-version: 20
- run: yarn install
shell: cmd
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install ComfyUI and create standalone package
- name: Download and prepare ComfyUI
run: |
pip install comfy-cli
cd assets
comfy --skip-prompt --workspace ./ComfyUI install --fast-deps --nvidia --cuda-version 12.1
comfy --workspace ./ComfyUI standalone --platform windows --proc x86_64
rm -rf python cpython*.tar.gz
curl -L -o comfyui-win.7z https://github.com/Comfy-Org/python-dependencies/releases/download/embedded-windows-deps-cu11.8-py11.9-5/ComfyUI_windows_portable.7z
7z x comfyui-win.7z -odist/
move dist/ComfyUI_windows_portable/ComfyUI assets/
move dist/ComfyUI_windows_portable/python_embedded assets/python
cd assets && ls
shell: cmd
- name: Make app
shell: powershell
Expand All @@ -48,10 +36,10 @@ runs:
DEBUG: electron-forge:*
PUBLISH: ${{ inputs.sign-and-publish }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
run: yarn run ${{inputs.sign-and-publish == true && 'publish' || 'make'}} -- ${{inputs.build-targets}}
run: npm run ${{inputs.sign-and-publish == true && 'publish' || 'make'}}
- name: Print SignLogs
if: ${{inputs.sign-and-publish == true && always()}}
continue-on-error: true
if: ${{inputs.sign-and-publish == true && always()}}
continue-on-error: true
shell: powershell
run: cd $HOME ; gc .signingmanager\logs\smksp.log
- name: verify signing
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/build/windows/certificate/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Certificate Setup
description: Sets up DigiCert and make it ready for signing
inputs:
inputes:
DIGICERT_AUTHENTICATION_CERTIFICATE_BASE64:
required: true
type: string
Expand Down Expand Up @@ -46,4 +46,4 @@ runs:
smksp_cert_sync.exe
- name: health check
shell: cmd
run: smctl healthcheck --user
run: smctl healthcheck --user
26 changes: 24 additions & 2 deletions .github/workflows/debug_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,27 @@ jobs:
build-macos-debug:
runs-on: macos-latest
steps:
- name: Blank
run: echo "Intentionally left blank"
- name: Github checkout
uses: actions/checkout@v4
- name: Declare some variables
run: |
echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
shell: bash
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i
- name: Build Comfy
uses: ./.github/actions/build/macos/comfy
- name: Publish app
env:
PUBLISH: false
DEBUG: electron-forge*
run: npm run make -- --arch="arm64"
- name: Upload Build
uses: actions/upload-artifact@v4
with:
name: comfyui-electron-debug-macos-${{env.sha_short}}
path: out/make/zip/darwin/arm64/*.zip

6 changes: 3 additions & 3 deletions .github/workflows/debug_windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build App Windows Debug
name: Build Windows Debug

on:
workflow_dispatch:
Expand Down Expand Up @@ -26,5 +26,5 @@ jobs:
- name: Upload Build
uses: actions/upload-artifact@v4
with:
name: comfyui-electron-win32-debug-build-${{env.sha_short}}
path: out/make/zip/win32/x64/*.zip
name: comfyui-electron-debug-win32-${{env.sha_short}}
path: out/make/zip/win32/x64/*.zip
36 changes: 19 additions & 17 deletions .github/workflows/publish_macos.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# .github/workflows/release.yml
name: Release app
# .github/workflows/publish_macos.yml
name: Release MacOS app

on:
workflow_dispatch:
Expand All @@ -10,30 +10,32 @@ jobs:
steps:
- name: Github checkout
uses: actions/checkout@v4
- name: Output xcode version
run: xcodebuild -version
- name: Add MacOS certs
run: cd scripts && chmod +x add-osx-cert.sh && ./add-osx-cert.sh
env:
CERTIFICATE_OSX_APPLICATION: ${{ secrets.CERTIFICATE_OSX_APPLICATION }}
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i
- name: Download and prepare ComfyUI
- name: Set Up signing
uses: ./.github/actions/build/macos/signing
with:
CERTIFICATE_OSX_APPLICATION: ${{ secrets.CERTIFICATE_OSX_APPLICATION }}
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
- name: Make Comfy
uses: ./.github/actions/build/macos/comfy
- name: Sign Wheels
uses: ./.github/actions/build/macos/signwheel
- name: shim
run: |
curl -L -o comfyui-mac.tar.gz https://github.com/Comfy-Org/python-dependencies/releases/download/mac-arm-deps-py3.12-2024-08-16-050751/mac_arm_python_env.tar.gz
tar -xzvf comfyui-mac.tar.gz
rm -rf ComfyUI
mv dist/ComfyUI ./assets/UI/ComfyUIBackend
rm -rf comfyui-mac.tar.gz
chmod +x scripts/shim.sh && ./scripts/shim.sh
- name: Publish app
env:
DEBUG: electron-forge:*
DEBUG: electron-osx-sign*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SIGN_ID: ${{env.SIGN_ID}}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: yarn run publish -- --arch="x64","arm64"
run: yarn run publish -- --arch="arm64"
- name: Check Notarization
run: |
spctl -a -vvv -t install "out/ComfyUI-darwin-arm64/ComfyUI.app"
2 changes: 1 addition & 1 deletion .github/workflows/publish_windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# .github/workflows/release.yml
# .github/workflows/publish_windows.yml
name: Release Windows app

on:
Expand Down
2 changes: 2 additions & 0 deletions assets/entitlements.mac.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
34 changes: 19 additions & 15 deletions forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,28 @@ import { FuseV1Options, FuseVersion } from '@electron/fuses';
const config: ForgeConfig = {
packagerConfig: {
asar: true,
...process.env.PUBLISH == 'true' && {windowsSign: {
debug:true,
hookFunction: (filePath) => {
if (!filePath.endsWith("ComfyUI.exe")) return; // For now just ignore any file that isnt the main exe will need to change when building with installers/auto updates / a compiled python servesr
import("child_process").then(cp => cp.execSync(`signtool.exe sign /sha1 ${process.env.DIGICERT_FINGERPRINT} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 ${filePath}`));
...process.env.PUBLISH == 'true' && {
windowsSign: {
debug:true,
hookFunction: (filePath) => {
if (!filePath.endsWith("ComfyUI.exe")) return; // For now just ignore any file that isnt the main exe will need to change when building with installers/auto updates / a compiled python servesr
import("child_process").then(cp => cp.execSync(`signtool.exe sign /sha1 ${process.env.DIGICERT_FINGERPRINT} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 ${filePath}`));
},
},
}},
osxSign: {
optionsForFile: (filepath) => {
return { entitlements: './assets/entitlements.mac.plist' };
osxSign: {
identity: process.env.SIGN_ID,
optionsForFile: (filepath) => {
return { entitlements: './assets/entitlements.mac.plist' };
}
},
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
teamId: process.env.APPLE_TEAM_ID
},
},
extraResource: ['./assets/UI', './assets/ComfyUI', './assets/python.tgz'],
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
teamId: process.env.APPLE_TEAM_ID
},
extraResource: ['./assets/UI', './assets/ComfyUI', process.platform !== 'linux' ? './assets/python' : './assets/python.tgz'],

},
rebuildConfig: {},
hooks: {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"description": "The best modular GUI to run AI diffusion models.",
"main": ".vite/build/main.js",
"packageManager": "[email protected]",
"type": "commonjs",
"scripts": {
"clean": "rimraf .vite dist out",
"clean:assets": "rimraf assets/ComfyUI assets/cpython*.tar.gz assets/python assets/override.txt assets/python.tgz assets/requirements.*",
Expand Down Expand Up @@ -56,7 +55,7 @@
"name": "Robin Huang",
"email": "[email protected]"
},
"license": "GPL-3.0-only",
"license": "GPL",
"dependencies": {
"adm-zip": "^0.5.15",
"axios": "^1.7.3",
Expand Down
3 changes: 3 additions & 0 deletions scripts/shim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cp -f scripts/shims/utils.js node_modules/@electron/osx-sign/dist/cjs/util.js

sed -i '' 's/packageOpts.quiet = true/packageOpts.quiet = false/g' "node_modules/@electron-forge/core/dist/api/package.js"
Loading

0 comments on commit 3d38221

Please sign in to comment.