adding env var to step on copying since it wont work without it #105
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 and Compile | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
# Checkout the code | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install CMake | |
uses: jwlawson/actions-setup-cmake@v1 | |
- name: Install vcpkg | |
run: | | |
git clone https://github.com/microsoft/vcpkg.git | |
.\vcpkg\bootstrap-vcpkg.bat | |
.\vcpkg\vcpkg integrate install | |
.\vcpkg\vcpkg integrate project | |
echo "VCPKG_ROOT=$(pwd)/vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- name: Build JSONCPP | |
run: | | |
git clone https://github.com/open-source-parsers/jsoncpp.git | |
cd jsoncpp | |
mkdir build | |
cd build | |
cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release | |
cmake --build . --config Release | |
- name: Set up JSONCPP paths | |
shell: pwsh | |
run: | | |
echo "JSONCPP_INCLUDE_DIR=D:/a/SAPI-POC/SAPI-POC/jsoncpp/include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
echo "JSONCPP_LIB_DIR=D:/a/SAPI-POC/SAPI-POC/jsoncpp/build/lib/Release" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
echo "JSONCPP_DLL_DIR=D:/a/SAPI-POC/SAPI-POC/jsoncpp/build/bin/Release" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- name: Verify JSONCPP Build Output | |
shell: pwsh | |
env: | |
JSONCPP_DLL_DIR: ${{ env.JSONCPP_DLL_DIR }} | |
run: | | |
dir $env:JSONCPP_DLL_DIR | |
- name: Inject JSONCPP configuration into CMakeLists.txt | |
run: | | |
$cmakeFile = "engine/CMakeLists.txt" | |
# Define the CMake code to be injected | |
$injection = @" | |
include_directories(${JSONCPP_INCLUDE_DIR}) | |
link_directories(${JSONCPP_LIB_DIR}) | |
# Link jsoncpp to your executables if needed | |
"@ | |
# Append the configuration safely at the end of the CMakeLists.txt file | |
Add-Content -Path $cmakeFile -Value $injection | |
shell: pwsh | |
env: | |
VCPKG_ROOT: ${{ env.VCPKG_ROOT }} | |
JSONCPP_DLL_DIR: ${{ env.JSONCPP_DLL_DIR }} | |
JSONCPP_INCLUDE_DIR: ${{ env.JSONCPP_INCLUDE_DIR }} | |
JSONCPP_LIB_DIR: ${{ env.JSONCPP_LIB_DIR }} | |
- name: Copy JSONCPP files to the engine build directory | |
run: | | |
Copy-Item -Path "$env:JSONCPP_INCLUDE_DIR\*" -Destination "D:/a/SAPI-POC/SAPI-POC/engine/include" -Recurse | |
Copy-Item -Path "$env:JSONCPP_LIB_DIR\*" -Destination "D:/a/SAPI-POC/SAPI-POC/engine/lib" -Recurse | |
shell: pwsh | |
env: | |
VCPKG_ROOT: ${{ env.VCPKG_ROOT }} | |
JSONCPP_DLL_DIR: ${{ env.JSONCPP_DLL_DIR }} | |
JSONCPP_INCLUDE_DIR: ${{ env.JSONCPP_INCLUDE_DIR }} | |
JSONCPP_LIB_DIR: ${{ env.JSONCPP_LIB_DIR }} | |
- name: Build pysapittsengine | |
run: | | |
cd engine | |
mkdir build | |
cd build | |
cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH=${{ env.VCPKG_ROOT }} -DCMAKE_INCLUDE_PATH=${{ env.JSONCPP_INCLUDE_DIR }} -DCMAKE_LIBRARY_PATH=${{ env.JSONCPP_LIB_DIR }} | |
cmake --build . --config Release | |
Copy-Item "$env:JSONCPP_DLL_DIR\jsoncpp.dll" -Destination "." | |
shell: pwsh | |
env: | |
VCPKG_ROOT: ${{ env.VCPKG_ROOT }} | |
JSONCPP_DLL_DIR: ${{ env.JSONCPP_DLL_DIR }} | |
JSONCPP_INCLUDE_DIR: ${{ env.JSONCPP_INCLUDE_DIR }} | |
JSONCPP_LIB_DIR: ${{ env.JSONCPP_LIB_DIR }} | |
- name: Print contents of build/bin directory | |
run: | | |
dir engine/build | |
dir engine/build/Release | |
# Move the DLL to VoiceServer directory | |
- name: Move DLL and other bits to VoiceServer directory | |
run: | | |
Move-Item -Force engine/build/Release/* VoiceServer/_libs/ | |
- name: Set up UV | |
uses: yezz123/setup-uv@v4 | |
- name: Sync UV dependencies | |
run: | | |
cd VoiceServer | |
uv sync | |
- name: Compile RegisterVoice.py with PyInstaller inside UV virtual environment | |
run: | | |
cd VoiceServer | |
$site_packages = uv run python -c "import site; print(site.getsitepackages()[0])" | Out-String | |
$site_packages = $site_packages.Trim() -replace "`r`n", "" # Remove any newlines | |
uv run python -m PyInstaller RegisterVoice.py --noupx --onedir --name "RegisterVoice" -i .\icon.ico --clean --add-binary "$site_packages/Lib/site-packages/azure/cognitiveservices/speech/Microsoft.CognitiveServices.Speech.core.dll;." --collect-all comtypes -y | |
- name: Compile VoiceServer.py with PyInstaller inside UV virtual environment | |
run: | | |
cd VoiceServer | |
$site_packages = uv run python -c "import site; print(site.getsitepackages()[0])" | Out-String | |
$site_packages = $site_packages.Trim() -replace "`r`n", "" # Remove any newlines | |
uv run python -m PyInstaller VoiceServer.py --noupx --onedir --noconsole --name "VoiceServer" -i .\icon.ico --clean --add-binary "$site_packages/Lib/site-packages/azure/cognitiveservices/speech/Microsoft.CognitiveServices.Speech.core.dll;." --collect-all comtypes --uac-admin -y | |
- name: Build Installer with Inno Setup | |
run: | | |
cd VoiceServer | |
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" ".\buildinstaller.iss" | |
- name: Zip the executables and _libs directory | |
run: | | |
cd VoiceServer | |
dir . | |
if ((Test-Path "dist/VoiceServer") -and (Test-Path "dist/RegisterVoice") -and (Test-Path "_libs")) { | |
# Compress the contents | |
powershell -Command "Compress-Archive -Path 'dist/VoiceServer','dist/RegisterVoice','_libs' -DestinationPath 'VoiceServer_Uninstalled.zip'" | |
} else { | |
Write-Host "One or more directories are missing. Compression aborted." | |
} | |
# Add this after the compression to verify the zip file exists | |
if (Test-Path "VoiceServer_Uninstalled.zip") { | |
Write-Host "Zip file created successfully." | |
dir VoiceServer_Uninstalled.zip | |
} else { | |
Write-Host "Zip file creation failed." | |
} | |
- name: Archive the zip of uninstalled version | |
uses: actions/upload-artifact@v4 | |
with: | |
name: uninstalled-version | |
path: VoiceServer/VoiceServer_Uninstalled.zip | |
# Archive the compiled executables | |
- name: Archive the output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: compiled-executables | |
path: | | |
VoiceServer/output/VoiceServerInstaller.exe |