fabriziosalmi / UglyFeed

Retrieve, aggregate, filter, evaluate, rewrite and serve RSS feeds using Large Language Models for fun, research and learning purposes.
GNU Affero General Public License v3.0
103 stars 1 forks source link

Windows and OSX versions #27

Open fabriziosalmi opened 2 weeks ago

fabriziosalmi commented 2 weeks ago

Is your feature request related to a problem? Please describe.

Windows and OSX versions needed.

Describe the solution you'd like

To adapt the workflow to build native applications based on the provided approach for running the UglyFeed web application, we need to:

  1. Use streamlit as the primary command to start the application.
  2. Ensure the entry point for the application is gui.py.
  3. Use PyInstaller and py2app to package the application, ensuring that the Streamlit command is correctly configured within the native app's execution context.

Here's the adapted build-native-apps.yml workflow configuration:

Updated build-native-apps.yml

name: Build Native Apps

on:
  workflow_run:
    workflows: ["Release"]
    types:
      - completed

jobs:
  build-windows:
    runs-on: windows-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.8'

      - name: Install dependencies
        run: pip install -r requirements.txt

      - name: Install PyInstaller
        run: pip install pyinstaller

      - name: Create executable with PyInstaller
        run: |
          # Create a custom script to run Streamlit
          echo -e "import os\nos.system('streamlit run gui.py --server.address 0.0.0.0 --browser.gatherUsageStats false')" > start_uglyfeed.py
          # Use PyInstaller to package the application
          pyinstaller --onefile --windowed --name UglyFeed start_uglyfeed.py

      - name: Upload Windows executable
        uses: actions/upload-artifact@v2
        with:
          name: UglyFeed-Windows
          path: dist/UglyFeed.exe

  build-macos:
    runs-on: macos-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.8'

      - name: Install dependencies
        run: pip install -r requirements.txt

      - name: Install py2app
        run: pip install py2app

      - name: Create custom setup.py for py2app
        run: |
          echo "from setuptools import setup" > setup.py
          echo "import os" >> setup.py
          echo "APP = ['start_uglyfeed.py']" >> setup.py
          echo "OPTIONS = {'argv_emulation': True, 'packages': ['streamlit'], 'plist': {'LSUIElement': True}}" >> setup.py
          echo "setup(app=APP, options={'py2app': OPTIONS})" >> setup.py
          # Create a custom script to run Streamlit
          echo -e "import os\nos.system('streamlit run gui.py --server.address 0.0.0.0 --browser.gatherUsageStats false')" > start_uglyfeed.py

      - name: Build macOS application
        run: python setup.py py2app

      - name: Upload macOS application
        uses: actions/upload-artifact@v2
        with:
          name: UglyFeed-macOS
          path: dist/UglyFeed.app

  create-release:
    needs: [build-windows, build-macos]
    runs-on: ubuntu-latest
    steps:
      - name: Download Windows artifact
        uses: actions/download-artifact@v2
        with:
          name: UglyFeed-Windows
          path: ./dist/windows

      - name: Download macOS artifact
        uses: actions/download-artifact@v2
        with:
          name: UglyFeed-macOS
          path: ./dist/macos

      - name: Create GitHub release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body: |
            Automated build for UglyFeed version ${{ github.ref }}
          draft: false
          prerelease: false
          files: |
            ./dist/windows/UglyFeed.exe
            ./dist/macos/UglyFeed.app

Explanation:

  1. Trigger the Workflow:

    • The workflow triggers on the completion of the Release workflow, ensuring it runs only after the PyPI deployment.
  2. Windows Build:

    • Custom Script: A temporary start_uglyfeed.py script is created to run the Streamlit command.
    • PyInstaller: This script is packaged into a standalone executable using PyInstaller.
  3. macOS Build:

    • Custom Script: The same start_uglyfeed.py script is used for the macOS build.
    • py2app: This script is packaged into a macOS application using py2app.
    • Setup for py2app: The setup.py is dynamically created to configure py2app.
  4. Uploading Artifacts:

    • Both Windows and macOS applications are uploaded as artifacts after the build.
  5. Creating a GitHub Release:

    • After building the native applications, a new release is created on GitHub, attaching the built executables.

Notes:

fabriziosalmi commented 3 days ago

postponed to 0.1.x versions