Create python-app.yml #1
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 Python application | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# Step 2: Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' # Specify your Python version | |
# Step 3: Install Poetry | |
- name: Install Poetry | |
run: | | |
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - | |
$env:PATH += ";$HOME\.poetry\bin" | |
echo "POETRY_HOME=$HOME\.poetry" >> $GITHUB_ENV | |
echo "PATH=$PATH;$HOME\.poetry\bin" >> $GITHUB_ENV | |
# Step 4: Install Dependencies | |
- name: Install Dependencies | |
run: | | |
cd src | |
poetry install --with dev | |
# **New Step: Run Additional Scripts (Download Libraries and Models)** | |
- name: Download Libraries and Models | |
run: | | |
cd src | |
poetry run python ./dev/download_libsimple.py | |
poetry run python ./dev/download_models.py | |
# Step 5: Build the Application | |
- name: Build Application | |
run: | | |
cd src | |
poetry run python build.py | |
# Step 6: Install Chocolatey (Package Manager for Windows) | |
- name: Install Chocolatey | |
run: | | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | |
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
# Step 7: Install Inno Setup | |
- name: Install Inno Setup | |
run: choco install innosetup -y | |
# Step 8: Compile Installer using Inno Setup | |
- name: Compile Installer | |
run: | | |
cd src/dev | |
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" setup.iss | |
# Step 9: Upload the Installer as an Artifact (Optional) | |
- name: Upload Installer Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: PicFinder-Installer | |
path: src/installer_dist/PicFinder\ Installer.exe |