Skip to content

Merge pull request #88 from TissueEngineeringLab/feature/update_to_py… #148

Merge pull request #88 from TissueEngineeringLab/feature/update_to_py…

Merge pull request #88 from TissueEngineeringLab/feature/update_to_py… #148

# Workflow building the Windows Installer and executable files
name: Build Windows Binaries
on:
# Runs on pushes on the default branch
push:
branches: ["main"]
# Runs on pull requests targeting the default branch
pull_request:
types: [opened, edited, reopened, synchronize]
branches: ["main"]
# Runs automatically every first day of the month
schedule:
- cron: '0 12 1 * *'
# May also be started manually
workflow_dispatch:
jobs:
# Compiles the .cpp sources into .exe executables and uploads them
compile-executable:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
# Compile the sources into executable files
- name: Build Main Executable
run: gcc '${{ github.workspace }}\src\wix\src\myofinder.cpp' -lstdc++ -lshlwapi -static -static-libgcc -static-libstdc++ -o '${{ github.workspace }}\bin\myofinder.exe'
- name: Build Venv Installer
run: gcc '${{ github.workspace }}\src\wix\src\install_venv.cpp' -lstdc++ -lshlwapi -static -static-libgcc -static-libstdc++ -o '${{ github.workspace }}\bin\install_venv.exe'
- name: Build Venv Uninstaller
run: gcc '${{ github.workspace }}\src\wix\src\rollback_install.cpp' -lstdc++ -lshlwapi -static -static-libgcc -static-libstdc++ -o '${{ github.workspace }}\bin\rollback_install.exe'
# Upload the compiled files, so that they can be used by other jobs later
- name: Upload Executable Files
uses: actions/upload-artifact@v4
with:
name: myofinder_binaries
path: '${{ github.workspace }}\bin\*.exe'
if-no-files-found: error
# Builds the wheel from the latest project version and uploads it
build-wheel:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
# Set up Python 3.14
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
# Builds the wheel for the latest version
- name: Build Wheel
run: |
python -m venv '${{ github.workspace }}\venv'
${{ github.workspace }}\venv\Scripts\python.exe -m pip install --upgrade pip wheel build setuptools
${{ github.workspace }}\venv\Scripts\python.exe -m build ${{ github.workspace }} -o ${{ github.workspace }}\dist
# Upload the built wheel, so that it can be used by other jobs later
- name: Upload Wheel
uses: actions/upload-artifact@v4
with:
name: myofinder_wheel
path: '${{ github.workspace }}\dist\*.whl'
if-no-files-found: error
# Builds the .msi Windows installer and uploads it
build-installer:
runs-on: windows-latest
needs: compile-executable
steps:
- name: Checkout
uses: actions/checkout@v5
# Gets the compiled executables from a previous job
- name: Download Executables
uses: actions/download-artifact@v5
with:
name: myofinder_binaries
path: '${{ github.workspace }}\bin'
merge-multiple: 'true'
# Installs WiX
- name: Install WiX
shell: cmd
run: |
dotnet tool install --global wix --version 4.0.6
wix extension add --global WixToolset.UTIL.wixext/4.0.6
# Generates the .msi file using WiX
- name: Generate MSI
shell: cmd
run: |
cd ${{ github.workspace }}\src\wix\
wix build ${{ github.workspace }}\src\wix\myofinder.wxs .\custom_ui\*.wxs -ext WixToolset.UTIL.wixext -o ${{ github.workspace }}\bin\myofinder.msi
# Upload the generated .msi installer, so that it can be used by other jobs later
- name: Upload MSI
uses: actions/upload-artifact@v4
with:
name: myofinder_msi
path: '${{ github.workspace }}\bin\*.msi'
if-no-files-found: error
# Pushes the installer and the executable to the main branch
test-installer:
runs-on: windows-latest
needs: [build-installer, build-wheel]
steps:
- name: Checkout
uses: actions/checkout@v5
# Gets the generated .msi installer from a previous job
- name: Download MSI
uses: actions/download-artifact@v5
with:
name: myofinder_msi
path: '${{ github.workspace }}\bin'
merge-multiple: 'true'
# Gets the built wheel from a previous job
- name: Download Wheel
uses: actions/download-artifact@v5
with:
name: myofinder_wheel
path: '${{ github.workspace }}\dist'
merge-multiple: 'true'
# For some reason the installation directory needs to be manually created
- name: Create Installation Folder
shell: pwsh
run: mkdir "$env:localappdata\MyoFInDer"
# Getting the name of the wheel, cannot do it in the Windows shell
- name: Get Wheel Name
shell: bash
run: echo "WHEEL_NAME=$(echo '${{ github.workspace }}\dist\')$(ls '${{ github.workspace }}\dist' | grep \.whl$ | head -n 1)" >> $GITHUB_ENV
# Execute the .msi installer to check that it operates as expected
# Also, record the logs to a log file
- name: Run Installer
shell: pwsh
run: If ((Start-Process msiexec -Wait -PassThru -ArgumentList "/I",
"${{ github.workspace }}\bin\myofinder.msi",
"TESTINSTALL=${{ env.WHEEL_NAME }}",
"/qn",
"/l*vx",
"${{ github.workspace }}\log.txt").ExitCode -ne 0)
{exit 1} else
{Write-Output "::notice ::{MSI Installation succeeded}"}
# If the workflow is manually started, show some debug information
- name: Show Debug Info
if: contains(fromJSON('["workflow_dispatch"]'), github.event_name)
run: type '${{ github.workspace }}\log.txt'
# Run the installed MyoFInDer program
- name: Run MyoFInDer
shell: cmd
run: '"%localappdata%\MyoFInDer\myofinder.exe" --test'
# Pushes the installer to the main branch
push-installer:
runs-on: windows-latest
needs: test-installer
if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
steps:
- name: Checkout
uses: actions/checkout@v5
with:
token: ${{ secrets.PAT }}
# Gets the generated .msi installer from a previous job
- name: Download MSI
uses: actions/download-artifact@v5
with:
name: myofinder_msi
path: '${{ github.workspace }}\bin'
merge-multiple: 'true'
# Push the .msi installer to the current branch
- name: Push MSI
run: |
git config user.name 'Antoine Weisrock'
git config user.email 'antoine.weisrock@gmail.com'
git add '${{ github.workspace }}\bin\myofinder.msi'
git commit -m "ci: push Windows installer [actions skip]"
git push