Skip to content

Build EXE & Create Release #5

Build EXE & Create Release

Build EXE & Create Release #5

Workflow file for this run

name: Build EXE & Create Release
on:
workflow_dispatch:
branches:
- main
jobs:
build:
runs-on: windows-latest
steps:
# ۱. Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
# ۲. نصب Python 3.11
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
# ۳. نصب وابستگی‌ها
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pyinstaller
# ۴. خواندن متغیر VERSION از main.py
- name: Extract Version
id: get_version
run: |
$version = Select-String -Pattern 'VERSION\s*=\s*"(.*?)"' -Path "./main.py" | ForEach-Object { $_.Matches.Groups[1].Value }
Write-Host "Detected version: $version"
echo "VERSION=$version" >> $env:GITHUB_ENV
# ۵. ساخت فایل EXE با PyInstaller
- name: Build with PyInstaller
run: |
pyinstaller --noconfirm --onefile --windowed --icon "./assets/icon.ico" --name "PhotoSlicer v${{ env.VERSION }}" --add-data "engine.py;." --add-data "./assets;assets/" "./main.py"
# ۶. ذخیره EXE به Artifact
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: photo_slicer_build
path: ./dist/
release:
needs: build
runs-on: windows-latest
steps:
# ۷. Create GitHub Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: v${{ env.VERSION }}
release_name: Release v${{ env.VERSION }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ۸. Upload فایل EXE به Release
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/PhotoSlicer\ v${{ env.VERSION }}.exe
asset_name: PhotoSlicer-v${{ env.VERSION }}-windows-x64.exe
asset_type: application/octet-stream