Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autobuild: Combine and simplify Windows build scripts #2502

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/autobuild/README.md
Original file line number Diff line number Diff line change
@@ -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).
169 changes: 169 additions & 0 deletions .github/autobuild/windows.ps1
Original file line number Diff line number Diff line change
@@ -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
hoffie marked this conversation as resolved.
Show resolved Hide resolved
{
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}"
Comment on lines +138 to +139
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the deploy script could be adapted to create the correct name (but that's for another PR)

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}"
}
}
14 changes: 7 additions & 7 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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'
Expand Down
104 changes: 0 additions & 104 deletions autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1

This file was deleted.

45 changes: 0 additions & 45 deletions autobuild/windows/autobuild_windowsinstaller_2_build.ps1

This file was deleted.

Loading