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 Nuitka
- Linux Executable - Standalone binary for Linux systems built with Nuitka
- macOS Executable - Standalone binary for macOS systems built with Nuitka (x64 and ARM64)
- 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
- Python packages (wheel and source distribution)
- Standalone executables for Windows, Linux, and macOS
- Debian packages for AMD64, ARM64, and ARMv7 architectures
- WinGet manifest files
- 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+
- Nuitka for executables (replaces PyInstaller)
- Docker for container builds
- dpkg-deb for Debian packages
Customizing Builds
Key files for customization:
g4f_cli.py- Entry point for executable buildsscripts/build-nuitka.sh- Nuitka build script for all platformsscripts/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