cleaning up empty panes!!! #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| platform: linux | |
| arch: x64 | |
| - os: windows-latest | |
| platform: windows | |
| arch: x64 | |
| - os: macos-latest | |
| platform: macos | |
| arch: arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get version from package.json | |
| id: version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Python dependencies | |
| run: pip install -r requirements.txt pyinstaller | |
| - name: Install macOS build dependencies | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install xz pkg-config | |
| - name: Install dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| npm install | |
| npm install @rollup/rollup-linux-x64-gnu sqlite3 --save-optional | |
| env: | |
| npm_config_optional: true | |
| - name: Install dependencies (Windows x64) | |
| if: runner.os == 'Windows' && matrix.arch == 'x64' | |
| run: | | |
| npm cache clean --force | |
| npm install | |
| npm install @rollup/rollup-win32-x64-msvc sqlite3 --save | |
| env: | |
| npm_config_optional: false | |
| - name: Install dependencies (macOS ARM64) | |
| if: runner.os == 'macOS' && matrix.arch == 'arm64' | |
| run: | | |
| npm install | |
| npm install @rollup/rollup-darwin-arm64 sqlite3 --save | |
| env: | |
| npm_config_optional: true | |
| - name: Build PyInstaller binary (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| pyinstaller --onefile --clean --distpath pyinstaller_dist --noupx \ | |
| --hidden-import=npcpy --hidden-import=litellm --hidden-import=ollama \ | |
| --hidden-import=flask --hidden-import=flask_cors --hidden-import=flask_sse \ | |
| --hidden-import=redis --hidden-import=pyyaml --hidden-import=pillow \ | |
| --hidden-import=nltk --hidden-import=anthropic --hidden-import=openai \ | |
| --hidden-import=google-genai --hidden-import=tiktoken_ext.openai_public \ | |
| --hidden-import=tiktoken_ext --hidden-import=chromadb --hidden-import=pydantic \ | |
| --exclude-module=scipy --exclude-module=tensorflow --exclude-module=torch \ | |
| --exclude-module=sklearn --exclude-module=notebook --exclude-module=ipython \ | |
| --exclude-module=jupyter --exclude-module=nbconvert --exclude-module=cv2 \ | |
| --exclude-module=PIL.ImageTk --exclude-module=PIL.ImageQt --exclude-module=docx \ | |
| --exclude-module=pptx --exclude-module=cuda --exclude-module=cudnn \ | |
| --exclude-module=cudart --exclude-module=cublas --exclude-module=cupy \ | |
| --exclude-module=logfire --exclude-module=numba.cuda --exclude-module=torch.cuda \ | |
| --exclude-module=tensorflow.python.framework.cuda_util \ | |
| --collect-data=litellm --collect-data=npcpy npc_studio_serve.py | |
| mkdir -p resources/backend | |
| cp pyinstaller_dist/npc_studio_serve resources/backend/ | |
| chmod +x resources/backend/npc_studio_serve | |
| - name: Build PyInstaller binary (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| python -m PyInstaller --onefile --clean --distpath pyinstaller_dist --noupx --hidden-import=npcpy --hidden-import=npcsh --hidden-import=flask --hidden-import=flask_cors --hidden-import=flask_sse --hidden-import=redis --hidden-import=pyyaml --hidden-import=pillow --hidden-import=nltk --hidden-import=litellm --hidden-import=anthropic --hidden-import=openai --hidden-import=google-genai --hidden-import=tiktoken_ext.openai_public --hidden-import=tiktoken_ext --hidden-import=sentence_transformers --hidden-import=chromadb --collect-data=litellm --collect-data=npcpy --collect-data=npcsh npc_studio_serve.py | |
| mkdir -p resources/backend | |
| copy pyinstaller_dist\npc_studio_serve.exe resources\backend\npc_studio_serve.exe | |
| - name: Build PyInstaller binary (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| pyinstaller --onefile --clean --distpath pyinstaller_dist --noupx \ | |
| --hidden-import=npcpy --hidden-import=litellm --hidden-import=ollama \ | |
| --hidden-import=flask --hidden-import=flask_cors --hidden-import=flask_sse \ | |
| --hidden-import=redis --hidden-import=pyyaml --hidden-import=pillow \ | |
| --hidden-import=anthropic --hidden-import=openai --hidden-import=google-genai \ | |
| --hidden-import=tiktoken_ext.openai_public --hidden-import=tiktoken_ext \ | |
| --hidden-import=chromadb --hidden-import=pydantic \ | |
| --exclude-module=scipy --exclude-module=tensorflow --exclude-module=torch \ | |
| --exclude-module=sklearn --exclude-module=notebook --exclude-module=ipython \ | |
| --exclude-module=jupyter --exclude-module=nbconvert --exclude-module=cv2 \ | |
| --exclude-module=PIL.ImageTk --exclude-module=PIL.ImageQt --exclude-module=docx \ | |
| --exclude-module=pptx --exclude-module=cuda --exclude-module=cudnn \ | |
| --exclude-module=cudart --exclude-module=cublas --exclude-module=cupy \ | |
| --exclude-module=logfire --exclude-module=numba.cuda --exclude-module=torch.cuda \ | |
| --exclude-module=nltk --exclude-module=tensorflow.python.framework.cuda_util \ | |
| --collect-data=litellm --collect-data=npcpy npc_studio_serve.py | |
| mkdir -p resources/backend | |
| cp pyinstaller_dist/npc_studio_serve resources/backend/npc_studio_serve | |
| chmod +x resources/backend/npc_studio_serve | |
| - name: Build frontend | |
| run: npm run build:vite | |
| - name: Rebuild native modules for Electron (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: npx electron-rebuild --force --module-dir . --which-module sqlite3 | |
| - name: Rebuild native modules for Electron (Windows) | |
| if: runner.os == 'Windows' | |
| run: npx electron-rebuild --force --module-dir . --which-module sqlite3 | |
| - name: Import Apple Developer ID certificate and set signing environment | |
| if: runner.os == 'macOS' | |
| env: | |
| P12_PASSWORD: ${{ secrets.APPLE_DEVELOPER_ID_CERTIFICATE_PASSWORD }} | |
| run: | | |
| # Decode the certificate and save it | |
| echo "${{ secrets.APPLE_DEVELOPER_ID_APPLICATION }}" | base64 --decode > build_cert.p12 | |
| # Create a temporary keychain | |
| security create-keychain -p "$P12_PASSWORD" build.keychain | |
| security default-keychain -s build.keychain | |
| security unlock-keychain -p "$P12_PASSWORD" build.keychain | |
| # Import the certificate into the keychain | |
| security import build_cert.p12 -k build.keychain -P "$P12_PASSWORD" -A | |
| # Allow access to the certificate for code signing tools | |
| security set-key-partition-list -S apple-tool:,apple: -s -k "$P12_PASSWORD" build.keychain | |
| # Set environment variables for electron-builder to pick up for signing and notarization | |
| echo "CSC_LINK=$(pwd)/build_cert.p12" >> $GITHUB_ENV | |
| echo "CSC_KEY_PASSWORD=$P12_PASSWORD" >> $GITHUB_ENV | |
| - name: Build Electron app | |
| run: npm run electron:build | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TARGET_ARCH: ${{ matrix.arch }} | |
| - name: Prepare files for upload | |
| id: prepare | |
| run: | | |
| mkdir -p upload | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [ "${{ runner.os }}" = "Linux" ]; then | |
| find dist-electron -name "*.deb" -exec cp {} upload/npc-studio_${VERSION}_${{ matrix.arch }}.deb \; | |
| echo "files=upload/npc-studio_${VERSION}_${{ matrix.arch }}.deb" >> $GITHUB_OUTPUT | |
| echo "gcs_path=linux-${{ matrix.arch }}" >> $GITHUB_OUTPUT | |
| elif [ "${{ runner.os }}" = "Windows" ]; then | |
| find dist-electron -name "*npc-studio*.exe" -exec cp {} upload/npc-studio_${VERSION}_${{ matrix.arch }}.exe \; | |
| echo "files=upload/npc-studio_${VERSION}_${{ matrix.arch }}.exe" >> $GITHUB_OUTPUT | |
| echo "gcs_path=windows-${{ matrix.arch }}" >> $GITHUB_OUTPUT | |
| elif [ "${{ runner.os }}" = "macOS" ]; then | |
| find dist-electron -name "*.dmg" -exec cp {} upload/npc-studio_${VERSION}_${{ matrix.arch }}.dmg \; | |
| echo "files=upload/npc-studio_${VERSION}_${{ matrix.arch }}.dmg" >> $GITHUB_OUTPUT | |
| echo "gcs_path=macos-${{ matrix.arch }}" >> $GITHUB_OUTPUT | |
| fi | |
| shell: bash | |
| - name: Authenticate to Google Cloud | |
| if: github.ref == 'refs/heads/main' | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Set up Cloud SDK | |
| if: github.ref == 'refs/heads/main' | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Upload to Google Cloud Storage | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| for file in ${{ steps.prepare.outputs.files }}; do | |
| if [ -f "$file" ]; then | |
| filename=$(basename "$file") | |
| gsutil cp "$file" gs://npc-studio-executables/${{ steps.prepare.outputs.gcs_path }}/"$filename" | |
| echo "Uploaded $filename to gs://npc-studio-executables/${{ steps.prepare.outputs.gcs_path }}/" | |
| fi | |
| done | |
| shell: bash | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npc-studio-${{ matrix.platform }}-${{ matrix.arch }} | |
| path: upload/* | |
| retention-days: 30 | |
| update_manifest: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get version from package.json | |
| id: version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Update manifest | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| cat > manifest.json << EOF | |
| { | |
| "version": "$VERSION", | |
| "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)", | |
| "downloads": { | |
| "linux-x64": "https://storage.googleapis.com/npc-studio-executables/linux-x64/npc-studio_${VERSION}_x64.deb", | |
| "windows-x64": "https://storage.googleapis.com/npc-studio-executables/windows-x64/npc-studio_${VERSION}_x64.exe", | |
| "macos-arm64": "https://storage.googleapis.com/npc-studio-executables/macos-arm64/npc-studio_${VERSION}_arm64.dmg" | |
| } | |
| } | |
| EOF | |
| gsutil cp manifest.json gs://npc-studio-executables/manifest.json | |
| gsutil setmeta -h "Cache-Control:no-cache,max-age=0" gs://npc-studio-executables/manifest.json | |
| notify: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get version from package.json | |
| id: version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Create download links summary | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| echo "## New npc-studio build available!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** $VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Download links:" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Linux x64:** https://storage.googleapis.com/npc-studio-executables/linux-x64/npc-studio_${VERSION}_x64.deb" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Windows x64:** https://storage.googleapis.com/npc-studio-executables/windows-x64/npc-studio_${VERSION}_x64.exe" >> $GITHUB_STEP_SUMMARY | |
| echo "- **macOS ARM64:** https://storage.googleapis.com/npc-studio-executables/macos-arm64/npc-studio_${VERSION}_arm64.dmg" >> $GITHUB_STEP_SUMMARY |