Skip to content

Replace start_myofinder.bat with myofinder.exe #18

Replace start_myofinder.bat with myofinder.exe

Replace start_myofinder.bat with myofinder.exe #18

# 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 myofinder.cpp source into a myofinder.exe executable
compile-executable:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# Compile the source into an executable file
- name: Build Executable
run: gcc '${{ github.workspace }}\src\windows_installer\myofinder.cpp' -lshlwapi -o '${{ github.workspace }}\bin\myofinder.exe'
# Always upload the executable file, so that the installer can be tested
- name: Upload Executable
uses: actions/upload-artifact@v4
with:
name: myofinder.exe
path: '${{ github.workspace }}\bin\myofinder.exe'
if-no-files-found: error
# Builds the Windows installer, tests it, and uploads it
build-windows-installer:
runs-on: windows-latest
needs: compile-executable
steps:
- name: Checkout
uses: actions/checkout@v4
# Set up Python 3.10
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
# 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
# Gets the compiled executable from the previous job
- name: Download Executable
uses: actions/download-artifact@v4
with:
name: myofinder.exe
path: '${{ github.workspace }}\bin'
# Generates the .msi file using Advanced Installer
- name: Generate MSI
uses: caphyon/[email protected]
with:
advinst-version: '20.9.1'
advinst-enable-automation: 'true'
aip-path: '${{ github.workspace }}\src\windows_installer\config.aip'
aip-build-name: DefaultBuild
aip-package-name: myofinder.msi
aip-output-dir: '${{ github.workspace }}\setup'
# For some reason the installation directory needs to be manually created
- name: Create Installation Folder
shell: pwsh
run: mkdir "$env:localappdata\MyoFInDer"
# 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 }}\setup\myofinder.msi",
"/qn",
"/l*vx",
"${{ github.workspace }}\setup\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 }}\setup\log.txt'
# 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
# For some reason the virtual environment cannot be created from the startup script
- name: Create Virtual Environment
shell: pwsh
run: python -m venv "$env:localappdata\MyoFInDer\venv"
# Run the startup script installed by the .msi installer in test mode
- name: Run Startup Script
shell: cmd
run: '%localappdata%\MyoFInDer\myofinder.exe -t ${{ env.WHEEL_NAME }}'
# If the workflow is started manually or by a push, upload the .msi installer
- name: Upload Installer
if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
uses: actions/upload-artifact@v4
with:
name: myofinder.msi
path: '${{ github.workspace }}\setup\myofinder.msi'
if-no-files-found: error
# Pushes the installer and the executable to the main branch
push-binaries:
runs-on: windows-latest
needs: build-windows-installer
if: contains(fromJSON('["push"]'), github.event_name)
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
# Download the previously uploaded installer and executable
- name: Download Binaries
uses: actions/download-artifact@v4
with:
pattern: myofinder*
path: '${{ github.workspace }}\bin'
merge-multiple: true
- name: Push Binaries
run: |
git config user.name 'Antoine Weisrock'
git config user.email '[email protected]'
git add '${{ github.workspace }}\bin\myofinder.msi' '${{ github.workspace }}\bin\myofinder.exe'
git commit -m "ci: push Windows binaries [actions skip]"
git push