Skip to content

Commit

Permalink
Enhance GitHub Actions workflow for building and deploying Python exe…
Browse files Browse the repository at this point in the history
…cutable; updated Python version to 3.12, improved dependency installation, and added verification steps.
  • Loading branch information
JHM69 committed Dec 13, 2024
1 parent 5ab8ac4 commit 58bfe95
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,59 @@
name: Build Executable
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 # Updated to latest version
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5 # Updated to latest version
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.12'

- name: Install dependencies
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt # Ensure you have a requirements.txt file
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 # Change 'main.py' to your main script name
pyinstaller --onefile main.py
- name: Upload executable
uses: actions/upload-artifact@v4 # Updated to v4
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: executable
path: dist/main
retention-days: 5 # Optional: specify retention period
path: dist/main
retention-days: 5

- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2 # Updated to v2
if: startsWith(github.ref, 'refs/tags/') # Only run on tag pushes
- 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 }} # Use built-in token instead of custom token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 58bfe95

Please sign in to comment.