Enhance GitHub Actions workflow for building and deploying Python exe… #3
This file contains 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 Deploy | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Upgrade pip | |
run: | | |
python -m pip install --upgrade pip | |
pip --version | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install wheel | |
pip install -r requirements.txt || pip install google-generativeai | |
- name: Verify installations | |
run: | | |
python --version | |
pip list | |
- name: Build executable | |
run: | | |
pip install pyinstaller | |
pyinstaller --onefile main.py | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: executable | |
path: dist/main | |
retention-days: 5 | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: dist/main | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |