Skip to content

[Bugfix] Pull request for testing pyapplication deployment script #18

[Bugfix] Pull request for testing pyapplication deployment script

[Bugfix] Pull request for testing pyapplication deployment script #18

name: Deploy PyInstaller Executables
on:
workflow_call:
workflow_dispatch:
pull_request:
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
torch_variant: [cpu, cu129]
include:
- os: ubuntu-latest
platform: linux-x64
build_script: ./INSTALL/pyinstaller/make_pyinstaller_image.sh
executable_ext: ""
macos_app_flag: ""
- os: macos-latest
platform: macos-x64
build_script: ./INSTALL/pyinstaller/make_pyinstaller_image.sh
executable_ext: ""
macos_app_flag: "--macos-app"
- os: windows-latest
platform: windows-x64
build_script: ./INSTALL/pyinstaller/make_pyinstaller_image.ps1
executable_ext: ".exe"
macos_app_flag: ""
exclude:
- os: macos-latest
torch_variant: cu129
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Free up disk space (Linux/macOS)
if: matrix.torch_variant != 'cpu' && runner.os != 'Windows'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -h
shell: bash
- name: Free up disk space (Windows)
if: matrix.torch_variant != 'cpu' && runner.os == 'Windows'
run: |
Get-PSDrive C
Remove-Item -Recurse -Force $env:TEMP\* -ErrorAction SilentlyContinue
pip cache purge
Get-PSDrive C
shell: pwsh
- name: Install tomli for version extraction (Linux/macOS)
if: runner.os != 'Windows'
run: python -m pip install tomli
shell: bash
- name: Install tomli for version extraction (Windows)
if: runner.os == 'Windows'
run: python -m pip install tomli
shell: pwsh
- name: Extract version from pyproject.toml (Linux/macOS)
if: runner.os != 'Windows'
id: get_version_unix
run: |
VERSION=$(python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
shell: bash
- name: Extract version from pyproject.toml (Windows)
if: runner.os == 'Windows'
id: get_version_win
run: |
$VERSION = python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])"
echo "version=$VERSION" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
shell: pwsh
- name: Create virtual environment (Linux/macOS)
if: runner.os != 'Windows'
run: python -m venv .venv
shell: bash
- name: Create virtual environment (Windows)
if: runner.os == 'Windows'
run: python -m venv .venv
shell: pwsh
- name: Install dependencies and build (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
chmod +x ${{ matrix.build_script }}
${{ matrix.build_script }} ${{ matrix.torch_variant }} ${{ matrix.macos_app_flag }}
shell: bash
- name: Install dependencies and build (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
& ${{ matrix.build_script }} ${{ matrix.torch_variant }}
shell: pwsh
- name: Rename executable or directory (Linux/macOS)
if: runner.os != 'Windows'
run: |
cd dist
ls -la
BASE="photomap-${{ matrix.torch_variant }}"
EXT="${{ matrix.executable_ext }}"
VERSION="${{ steps.get_version_unix.outputs.version || steps.get_version_win.outputs.version }}"
ARCHIVE_NAME="photomap-${{ matrix.platform }}-${{ matrix.torch_variant }}-v$VERSION"
if [ -f "photomap$EXT" ]; then
mv "photomap$EXT" "$ARCHIVE_NAME$EXT"
elif [ -d "photomap.app" ]; then
mv "photomap.app" "$ARCHIVE_NAME.app"
elif [ -d "photomap" ]; then
mv "photomap" "$ARCHIVE_NAME"
else
echo "Neither photomap$EXT nor photomap directory found!"
exit 1
fi
ls -la
shell: bash
- name: Rename executable or directory (Windows)
if: runner.os == 'Windows'
run: |
cd dist
$base = "photomap-${{ matrix.torch_variant }}"
$ext = "${{ matrix.executable_ext }}"
$version = "${{ steps.get_version_unix.outputs.version || steps.get_version_win.outputs.version }}"
$archiveName = "photomap-${{ matrix.platform }}-${{ matrix.torch_variant }}-v$version"
if (Test-Path "photomap$ext") {
Rename-Item -Path "photomap$ext" -NewName "$archiveName$ext"
} elseif (Test-Path "photomap") {
Rename-Item -Path "photomap" -NewName "$archiveName"
} else {
Write-Error "Neither photomap$ext nor photomap directory found!"
exit 1
}
Get-ChildItem *
shell: pwsh
- name: Debug - List dist contents
run: ls -la dist/
shell: bash
if: runner.os != 'Windows'
- name: Debug - List dist contents (Windows)
run: Get-ChildItem dist/
shell: pwsh
if: runner.os == 'Windows'
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: photomap-${{ matrix.platform }}-${{ matrix.torch_variant }}-v${{ steps.get_version_unix.outputs.version || steps.get_version_win.outputs.version }}
path: dist/photomap-${{ matrix.platform }}-${{ matrix.torch_variant }}-v${{ steps.get_version_unix.outputs.version || steps.get_version_win.outputs.version }}*
retention-days: 30