From 58bfe95c3dc877e6a88b88594c2779f2f623ef00 Mon Sep 17 00:00:00 2001 From: Jahangir Hossain Date: Fri, 13 Dec 2024 14:45:58 -0400 Subject: [PATCH] Enhance GitHub Actions workflow for building and deploying Python executable; updated Python version to 3.12, improved dependency installation, and added verification steps. --- .github/workflows/main.yml | 46 +++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a99f74..9004eeb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,12 @@ -name: Build Executable +name: Build and Deploy on: push: branches: - master + pull_request: + branches: + - master jobs: build: @@ -11,35 +14,46 @@ jobs: 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 \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file