* Add comprehensive build workflow and package configuration Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com> * Complete build workflow implementation with documentation and testing Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com> * Update WinGet package structure and build dependencies per feedback Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com> * Simplify WinGet package identifier to "g4f" and add winget/* to .gitignore Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
3.1 KiB
Build Workflow Documentation
This document explains the comprehensive build workflow for g4f that creates packages for multiple platforms and package managers.
Workflow Overview
The .github/workflows/build-packages.yml workflow automatically builds multiple package formats when a version tag is pushed to the repository.
Supported Package Formats
- PyPI Package - Python wheel and source distribution
- Windows Executable - Standalone .exe file built with PyInstaller
- Linux Executable - Standalone binary for Linux systems
- macOS Executable - Standalone binary for macOS systems
- Debian Packages - .deb files for Ubuntu/Debian (amd64, arm64, armhf)
- WinGet Package - Windows Package Manager manifest
- Docker Images - Multi-architecture container images
Triggering a Build
To trigger a build, push a version tag to the repository:
git tag v1.2.3
git push origin v1.2.3
The workflow will:
- Detect the tag and extract the version
- Build all package formats in parallel
- Create a GitHub release with all artifacts
- Publish to PyPI (for releases)
- Generate WinGet manifest for Windows Package Manager
Manual Build Triggering
You can also manually trigger builds using the workflow_dispatch event:
- Go to the "Actions" tab in GitHub
- Select "Build All Packages" workflow
- Click "Run workflow"
- Optionally specify a version number
Package Locations
After a successful build, packages are available:
- GitHub Releases: All executables and packages as release assets
- PyPI:
pip install g4f - Docker Hub:
docker pull hlohaus789/g4f:latest - WinGet:
winget install g4f(after manifest approval)
Build Requirements
The workflow handles all dependencies automatically, but for local development:
- Python 3.10+
- PyInstaller for executables
- Docker for container builds
- dpkg-deb for Debian packages
Customizing Builds
Key files for customization:
g4f_cli.py- Entry point for executable buildsscripts/build-deb.sh- Debian package build scriptwinget/manifests/- WinGet package manifest templates.github/workflows/build-packages.yml- Main workflow configuration
Version Handling
The workflow supports multiple version sources:
- Git tags (preferred for releases)
- Environment variable
G4F_VERSION - Manual input in workflow dispatch
Version must follow PEP 440 format for PyPI compatibility.
Troubleshooting
Common issues and solutions:
- Build fails: Check Python version compatibility and dependencies
- Version errors: Ensure version follows PEP 440 format
- Missing artifacts: Check if all build jobs completed successfully
- Docker push fails: Verify Docker Hub credentials are set in repository secrets
Security Notes
The workflow uses secure practices:
- Trusted action versions
- Environment isolation
- Secret management for credentials
- No hardcoded sensitive data
Contributing
To improve the build system:
- Test changes locally first
- Update documentation
- Consider backward compatibility
- Test with multiple Python versions