Merge pull request #35 from TissueEngineeringLab/feature/automaticall… #17
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
# Workflow building the Windows Installer file | |
name: Build Windows Installer | |
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: | |
# Builds the Windows installer, tests it, and uploads it | |
build-windows-installer: | |
runs-on: windows-latest | |
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' | |
# Build 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 | |
# 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 | |
# Run the startup script installed by the .msi installer in test mode | |
- name: Run Startup Script | |
shell: cmd | |
run: '%localappdata%\MyoFInDer\start_myofinder.bat -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 to the main branch after a pull request is merged | |
push-installer: | |
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 | |
- name: Download Installer | |
uses: actions/download-artifact@v4 | |
with: | |
name: myofinder.msi | |
path: ${{ github.workspace }}\artifacts | |
# Replace the previous installer with the newly downloaded one | |
- name: Replace Installer File | |
shell: bash | |
run: mv '${{ github.workspace }}/artifacts/myofinder.msi' '${{ github.workspace }}/bin/myofinder.msi' | |
# Push the installer to the main branch | |
- name: Push Installer | |
run: | | |
git config user.name 'Antoine Weisrock' | |
git config user.email '[email protected]' | |
git add ${{ github.workspace }}\bin\myofinder.msi | |
git commit -m "ci: push Windows installer [actions skip]" | |
git push |