diff --git a/.github/autobuild/README.md b/.github/autobuild/README.md new file mode 100644 index 0000000000..f6f8e4b7c2 --- /dev/null +++ b/.github/autobuild/README.md @@ -0,0 +1,7 @@ +# Scripts for building Jamulus via GitHub Actions + +The scripts in this folder are used by the Github autobuild actions in .github/workflows/autobuild.yml. +They are responsible for setting up the Github environment, building the binaries and passing the resulting artifacts back to the workflow. + +The scripts may work outside of Github, but haven't been designed or tested for that use case. +See the various platform-specific build scripts in their own folders for standalone builds (e.g. windows/deploy_windows.ps1). diff --git a/.github/autobuild/windows.ps1 b/.github/autobuild/windows.ps1 new file mode 100644 index 0000000000..b8bf08539e --- /dev/null +++ b/.github/autobuild/windows.ps1 @@ -0,0 +1,169 @@ +# Steps for generating Windows artifacts via Github Actions +# See README.md in this folder for details. +# See windows/deploy_windows.ps1 for standalone builds. + +param( + [Parameter(Mandatory=$true)] + [string] $Stage = "", + # Allow buildoption to be passed for jackonwindows build, leave empty for standard (ASIO) build: + [string] $BuildOption = "", + # unused, only required during refactoring as long as not all platforms have been updated: + [string] $GithubWorkspace ="" +) + +# Fail early on all errors +$ErrorActionPreference = "Stop" + +$QtDir = 'C:\Qt' +$ChocoCacheDir = 'C:\ChocoCache' +$Qt32Version = "5.15.2" +$Qt64Version = "5.15.2" +$AqtinstallVersion = "2.0.6" +$JackVersion = "1.9.17" +$Msvc32Version = "win32_msvc2019" +$Msvc64Version = "win64_msvc2019_64" +$JomVersion = "1.1.2" + +$JamulusVersion = $Env:jamulus_buildversionstring +if ( $JamulusVersion -notmatch '^\d+\.\d+\.\d+.*' ) +{ + throw "Environment variable jamulus_buildversionstring has to be set to a valid version string" +} + +Function Install-Qt +{ + param( + [string] $QtVersion, + [string] $QtArch + ) + $Args = ( + "--outputdir", "$QtDir", + "windows", + "desktop", + "$QtVersion", + "$QtArch", + "--archives", "qtbase", "qttools", "qttranslations", "qtwinextras" + ) + aqt install-qt @Args + if ( !$? ) + { + echo "WARNING: Qt installation via first aqt run failed, re-starting with different base URL." + aqt install-qt -b https://mirrors.ocf.berkeley.edu/qt/ @Args + if ( !$? ) + { + throw "Qt installation with args @Args failed with exit code $LastExitCode" + } + } +} + +Function Ensure-Qt +{ + if ( Test-Path -Path $QtDir ) + { + echo "Using Qt installation from previous run (actions/cache)" + return + } + + echo "Install Qt..." + # Install Qt + pip install "aqtinstall==$AqtinstallVersion" + if ( !$? ) + { + throw "pip install aqtinstall failed with exit code $LastExitCode" + } + + echo "Get Qt 64 bit..." + Install-Qt "${Qt64Version}" "${Msvc64Version}" + + echo "Get Qt 32 bit..." + Install-Qt "${Qt32Version}" "${Msvc32Version}" +} + +Function Ensure-jom +{ + choco install --no-progress -y jom --version "${JomVersion}" +} + +Function Ensure-JACK +{ + if ( $BuildOption -ne "jackonwindows" ) + { + return + } + + echo "Install JACK2 64-bit..." + # Install JACK2 64-bit + choco install --no-progress -y jack --version "${JackVersion}" + if ( !$? ) + { + throw "64bit jack installation failed with exit code $LastExitCode" + } + + echo "Install JACK2 32-bit..." + # Install JACK2 32-bit (need to force choco install as it detects 64 bits as installed) + choco install --no-progress -y -f --forcex86 jack --version "${JackVersion}" + if ( !$? ) + { + throw "32bit jack installation failed with exit code $LastExitCode" + } +} + +Function Build-App-With-Installer +{ + echo "Build app and create installer..." + $ExtraArgs = @() + if ( $BuildOption -ne "" ) + { + $ExtraArgs += ("-BuildOption", $BuildOption) + } + powershell ".\windows\deploy_windows.ps1" "C:\Qt\5.15.2" "C:\Qt\5.15.2" @ExtraArgs + if ( !$? ) + { + throw "deploy_windows.ps1 failed with exit code $LastExitCode" + } +} + +Function Pass-Artifact-to-Job +{ + # Add $BuildOption as artifact file name suffix. Shorten "jackonwindows" to just "jack": + $ArtifactSuffix = switch -Regex ( $BuildOption ) + { + "jackonwindows" { "_jack"; break } + "^\S+$" { "_${BuildOption}"; break } + default { "" } + } + + $artifact_deploy_filename = "jamulus_${JamulusVersion}_win${ArtifactSuffix}.exe" + + echo "Copying artifact to ${artifact_deploy_filename}" + cp ".\deploy\Jamulus*installer-win.exe" ".\deploy\${artifact_deploy_filename}" + if ( !$? ) + { + throw "cp failed with exit code $LastExitCode" + } + echo "Setting Github step output name=artifact_1::${artifact_deploy_filename}" + echo "::set-output name=artifact_1::${artifact_deploy_filename}" +} + +switch ( $Stage ) +{ + "setup" + { + choco config set cacheLocation $ChocoCacheDir + Ensure-Qt + Ensure-jom + Ensure-JACK + } + "build" + { + Build-App-With-Installer + } + "get-artifacts" + { + Pass-Artifact-to-Job + } + default + { + throw "Unknown stage ${Stage}" + } +} diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index d03f08bd94..c233c223f2 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -141,17 +141,17 @@ jobs: - config_name: Windows (artifact+codeQL) target_os: windows building_on_os: windows-2019 - cmd1_prebuild: powershell .\autobuild\windows\autobuild_windowsinstaller_1_prepare.ps1 - cmd2_build: powershell .\autobuild\windows\autobuild_windowsinstaller_2_build.ps1 - cmd3_postbuild: powershell .\autobuild\windows\autobuild_windowsinstaller_3_copy_files.ps1 + cmd1_prebuild: powershell .\.github\autobuild\windows.ps1 -Stage setup + cmd2_build: powershell .\.github\autobuild\windows.ps1 -Stage build -GithubWorkspace + cmd3_postbuild: powershell .\.github\autobuild\windows.ps1 -Stage get-artifacts -GithubWorkspace run_codeql: true - config_name: Windows JACK (artifact) target_os: windows building_on_os: windows-2019 - cmd1_prebuild: powershell .\autobuild\windows\autobuild_windowsinstaller_1_prepare.ps1 -BuildOption jackonwindows - cmd2_build: powershell .\autobuild\windows\autobuild_windowsinstaller_2_build.ps1 -BuildOption jackonwindows - cmd3_postbuild: powershell .\autobuild\windows\autobuild_windowsinstaller_3_copy_files.ps1 -BuildOption jackonwindows + cmd1_prebuild: powershell .\.github\autobuild\windows.ps1 -BuildOption jackonwindows -Stage setup + cmd2_build: powershell .\.github\autobuild\windows.ps1 -BuildOption jackonwindows -Stage build -GithubWorkspace + cmd3_postbuild: powershell .\.github\autobuild\windows.ps1 -BuildOption jackonwindows -Stage get-artifacts -GithubWorkspace run_codeql: false runs-on: ${{ matrix.config.building_on_os }} @@ -186,7 +186,7 @@ jobs: C:\ChocoCache ~\windows\NSIS ~\windows\ASIOSDK2 - key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1', 'windows/deploy_windows.ps1') }}-${{ matrix.config.cmd1_prebuild }} + key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/windows.ps1', 'windows/deploy_windows.ps1') }}-${{ matrix.config.cmd1_prebuild }} - name: Cache Android dependencies if: matrix.config.target_os == 'android' diff --git a/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 b/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 deleted file mode 100644 index 95a81cd644..0000000000 --- a/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 +++ /dev/null @@ -1,104 +0,0 @@ -# Powershell - -# autobuild_1_prepare: set up environment, install Qt & dependencies - - -#################### -### PARAMETERS ### -#################### - -param( - # Allow buildoption to be passed for jackonwindows build, leave empty for standard (ASIO) build - [string] $BuildOption = "" -) - -# Fail early on all errors -$ErrorActionPreference = "Stop" - -Function Install-Qt { - param( - [string] $QtVersion, - [string] $QtArch, - [string] $InstallDir - ) - $Args = ( - "--outputdir", "$InstallDir", - "windows", - "desktop", - "$QtVersion", - "$QtArch", - "--archives", "qtbase", "qttools", "qttranslations", "qtwinextras" - ) - aqt install-qt @Args - if ( !$? ) - { - echo "WARNING: Qt installation via first aqt run failed, re-starting with different base URL." - aqt install-qt -b https://mirrors.ocf.berkeley.edu/qt/ @Args - if ( !$? ) - { - throw "Qt installation with args @{Args} failed with exit code $LastExitCode" - } - } -} - -################### -### PROCEDURE ### -################### - -$QtDir = 'C:\Qt' -$ChocoCacheDir = 'C:\ChocoCache' -$Qt32Version = "5.15.2" -$Qt64Version = "5.15.2" -$AqtinstallVersion = "2.0.6" -$JackVersion = "1.9.17" -$Msvc32Version = "win32_msvc2019" -$Msvc64Version = "win64_msvc2019_64" -$JomVersion = "1.1.2" - -if ( Test-Path -Path $QtDir ) -{ - echo "Using Qt installation from previous run (actions/cache)" -} -else -{ - echo "Install Qt..." - # Install Qt - pip install "aqtinstall==$AqtinstallVersion" - if ( !$? ) - { - throw "pip install aqtinstall failed with exit code $LastExitCode" - } - - echo "Get Qt 64 bit..." - Install-Qt "${Qt64Version}" "${Msvc64Version}" "${QtDir}" - - echo "Get Qt 32 bit..." - Install-Qt "${Qt32Version}" "${Msvc32Version}" "${QtDir}" -} - -choco config set cacheLocation $ChocoCacheDir -choco install --no-progress -y jom --version "${JomVersion}" - - -################################# -### ONLY ADD JACK IF NEEDED ### -################################# - -if ($BuildOption -Eq "jackonwindows") -{ - echo "Install JACK2 64-bit..." - # Install JACK2 64-bit - choco install --no-progress -y jack --version "${JackVersion}" - if ( !$? ) - { - throw "64bit jack installation failed with exit code $LastExitCode" - } - - echo "Install JACK2 32-bit..." - # Install JACK2 32-bit (need to force choco install as it detects 64 bits as installed) - choco install --no-progress -y -f --forcex86 jack --version "${JackVersion}" - if ( !$? ) - { - throw "32bit jack installation failed with exit code $LastExitCode" - } -} diff --git a/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 b/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 deleted file mode 100644 index 960aed3ecf..0000000000 --- a/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -# Powershell - -# autobuild_2_build: actual build process - -#################### -### PARAMETERS ### -#################### - -# Get the source path via parameter and BuildOption to empty when not provided -param ( - [string] $jamulus_project_path = $Env:jamulus_project_path, - [string] $BuildOption = "" -) - -# Fail early on all errors -$ErrorActionPreference = "Stop" - -# Sanity check of parameters -if (("$jamulus_project_path" -eq $null) -or ("$jamulus_project_path" -eq "")) { - throw "expecting ""jamulus_project_path"" as parameter or ENV" -} elseif (!(Test-Path -Path $jamulus_project_path)) { - throw "non-existing jamulus_project_path: $jamulus_project_path" -} else { - echo "jamulus_project_path is valid: $jamulus_project_path" -} - - -################### -### PROCEDURE ### -################### - -echo "Build installer..." -# Build the installer -if ($BuildOption -ne "") -{ - powershell "$jamulus_project_path\windows\deploy_windows.ps1" "C:\Qt\5.15.2" "C:\Qt\5.15.2" -BuildOption $BuildOption -} -else -{ - powershell "$jamulus_project_path\windows\deploy_windows.ps1" "C:\Qt\5.15.2" "C:\Qt\5.15.2" -} -if ( !$? ) -{ - throw "deploy_windows.ps1 failed with exit code $LastExitCode" -} diff --git a/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 b/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 deleted file mode 100644 index 427a5e2c0c..0000000000 --- a/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 +++ /dev/null @@ -1,77 +0,0 @@ -# Powershell - -# autobuild_3_copy_files: copy the built files to deploy folder - -#################### -### PARAMETERS ### -#################### - -# Get the source path via parameter and set BuildOption to empty when not provided -param ( - [string] $jamulus_project_path = $Env:jamulus_project_path, - [string] $jamulus_buildversionstring = $Env:jamulus_buildversionstring, - [string] $BuildOption = "" -) - -# Fail early on all errors -$ErrorActionPreference = "Stop" - -# Sanity check of parameters -if (("$jamulus_project_path" -eq $null) -or ("$jamulus_project_path" -eq "")) { - throw "expecting ""jamulus_project_path"" as parameter or ENV" -} elseif (!(Test-Path -Path "$jamulus_project_path")) { - throw "non.existing jamulus_project_path: $jamulus_project_path" -} else { - echo "jamulus_project_path is valid: $jamulus_project_path" -} -if (($jamulus_buildversionstring -eq $null) -or ($jamulus_buildversionstring -eq "")) { - echo "expecting ""jamulus_buildversionstring"" as parameter or ENV" - echo "using ""NoVersion"" as jamulus_buildversionstring for filenames" - $jamulus_buildversionstring = "NoVersion" -} - -# Amend BuildOption when needed, only needed when the name build option in the artifact needs to be different -switch ($BuildOption) -{ - "jackonwindows" {$BuildOption = "jack"; break} -} - - -################### -### PROCEDURE ### -################### - -# Copy the file -echo "copy" -if ($BuildOption -ne "") -{ - $artifact_deploy_filename = "jamulus_${Env:jamulus_buildversionstring}_win_${BuildOption}.exe" -} -else -{ - $artifact_deploy_filename = "jamulus_${Env:jamulus_buildversionstring}_win.exe" -} - -echo "copying deploy file to $artifact_deploy_filename" -cp "$jamulus_project_path\deploy\Jamulus*installer-win.exe" "$jamulus_project_path\deploy\$artifact_deploy_filename" -if ( !$? ) -{ - throw "cp failed with exit code $LastExitCode"; -} - - -Function github_output_value -{ - param ( - [Parameter(Mandatory=$true)] - [string] $name, - [Parameter(Mandatory=$true)] - [string] $value - ) - - echo "github_output_value() $name = $value" - echo "::set-output name=$name::$value" -} - - -github_output_value -name "artifact_1" -value "$artifact_deploy_filename"