This repository contains a GitHub Actions workflow to package a Python application into a Windows executable (.exe
) using PyInstaller.
https://ragug.medium.com/ci-cd-pipeline-for-pyinstaller-on-github-actions-for-windows-7f8274349278
The GitHub Actions workflow:
- Checks out the repository.
- Sets up Python 3.10.
- Installs dependencies for the Python project.
- Packages the application using PyInstaller.
- Uploads the executable as an artifact for download.
Before running the workflow:
- Ensure you have a
pyinstaller.spec
file in your repository. This file defines how PyInstaller packages your application. - If you're using a
requirements.txt
, make sure it's included in your repository.
pyinstaller-github-action/
├── assets
│ ├── c1.png
│ ├── c2.png
│ └── icon.ico
├── main.py
├── pyinstaller.spec
├── pyproject.toml # PyInstaller configuration
├── README.md
├── src
│ ├── first_screen.py
│ ├── __init__.py
│ ├── loading.py
│ └── utils.py
├── uv.lock
└── .github/
└── workflows/
└── get_windows_exe.yml # GitHub Actions workflow
The workflow file (package.yml
) is located in .github/workflows/
and is triggered on every push to the main
branch. Modify the branch name as needed.
-
Set Up Python: The workflow sets up Python 3.10. Update the
python-version
field to your desired Python version. -
Install Dependencies: Adjust the command to install your dependencies:
- If using
setup.py
:pip install .
- If using
requirements.txt
:pip install -r requirements.txt
- If using
-
Package Application: The workflow uses
pyinstaller.spec
to create the.exe
. Ensure thepyinstaller.spec
file correctly references your Python project. -
Upload Artifact: The final
.exe
is uploaded as an artifact namedWindows-exe
for download.
- Push your code to the
main
branch (or the branch configured in the workflow). - Navigate to the Actions tab in your GitHub repository.
- Select the Package Application with PyInstaller workflow.
- Monitor the workflow execution. Upon completion, the
.exe
will be available for download as an artifact.
- After the workflow completes, navigate to the Actions tab.
- Select the workflow run and scroll down to the Artifacts section.
- Download the
Windows-exe.zip
file.
- Test the generated
.exe
thoroughly to ensure it works as expected. - If you encounter issues with packaging, review your
pyinstaller.spec
file and ensure all dependencies are installed correctly.