Do major clean up of Windows CI workflow (#10581)

- Move many of the post build operations in openrc2.proj to bash scripts, some of which can be shared with the macOS and Linux CIs.
- Improve performance of NSIS stage by grabbing a pre-packaged portable zip from GitHub. This typically saves the CI a minute and is more reliable.
This commit is contained in:
Ted John 2020-01-19 14:04:59 +00:00 committed by GitHub
parent 0702808692
commit 3ba8369f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 335 additions and 254 deletions

View File

@ -1,7 +1,7 @@
name: CI
on: [push, pull_request]
env:
BUILD_SERVER: GitHub
OPENRCT2_BUILD_SERVER: GitHub
OPENRCT2_ORG_TOKEN: ${{ secrets.OPENRCT2_ORG_TOKEN }}
OPENRCT2_VERSION: 0.2.4
jobs:
@ -24,52 +24,37 @@ jobs:
env:
CONFIGURATION: Release
PLATFORM: ${{ matrix.platform }}
GIT_COMMIT_SHA1: ${{ github.sha }}
steps:
- uses: actions/checkout@v1
name: Checkout
- name: Install NSIS
shell: bash
run: scripts/install-nsis
- name: Prepare environment
shell: bash
run: dos2unix test/tests/testdata/keys/*
- name: Build OpenRCT2
shell: pwsh
shell: bash
run: . scripts/setenv && build
- name: Build artifacts
shell: bash
run: |
$env:GIT_BRANCH = $env:GITHUB_REF -replace "refs/heads/(.*)", '$1'
$env:GIT_DESCRIBE = (git describe HEAD | sed -E "s/-g.+$//")
$env:BUILD_VERSION = $env:GIT_DESCRIBE | sed "s/v//" | sed "s/-/./"
Set-Content -Path 'resources\version.h' -Value "#define OPENRCT2_FILE_VERSION $($env:BUILD_VERSION -replace "\.", ",")"
Add-Content -Path 'resources\version.h' -Value "#define OPENRCT2_PRODUCT_VERSION `"$($env:BUILD_VERSION)-$($env:GIT_COMMIT_SHA1.Substring(0,10))`""
Remove-Item -Force -Recurse "C:\Program Files (x86)\NSIS"
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" && msbuild openrct2.proj'
- name: Run Tests
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat"
msbuild openrct2.proj /t:test
. scripts/setenv -q
build-portable
build-symbols
build-installer -i
- uses: actions/upload-artifact@master
name: Upload artifacts (CI)
with:
name: "OpenRCT2-Windows-${{ matrix.platform }}"
path: artifacts
- name: Run Tests
shell: bash
run: . scripts/setenv -q && run-tests
- name: Upload artifacts (openrct2.org)
shell: bash
run: |
if [[ "$OPENRCT2_ORG_TOKEN" != "" ]]; then
if [[ $GITHUB_REF == refs/tags/* ]]; then
GITHUB_BRANCH=
else
GITHUB_BRANCH=${GITHUB_REF#refs/heads/}
if [[ ! "$GITHUB_BRANCH" =~ ^(develop|push/) ]]; then
exit 0
fi
fi
scripts/upload-build artifacts/openrct2-portable-*.zip "windows-portable-$PLATFORM" $OPENRCT2_VERSION $GIT_COMMIT_SHA1 $GITHUB_BRANCH
scripts/upload-build artifacts/openrct2-installer-*.exe "windows-installer-$PLATFORM" $OPENRCT2_VERSION $GIT_COMMIT_SHA1 $GITHUB_BRANCH
scripts/upload-build artifacts/openrct2-symbols-*.zip "windows-symbols-$PLATFORM" $OPENRCT2_VERSION $GIT_COMMIT_SHA1 $GITHUB_BRANCH
. scripts/setenv -q
if [[ "$OPENRCT2_PUSH" == "true" ]]; then
upload-build artifacts/openrct2-portable-*.zip "windows-portable-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH
upload-build artifacts/openrct2-installer-*.exe "windows-installer-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH
upload-build artifacts/openrct2-symbols-*.zip "windows-symbols-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH
else
echo 'Not going to push build'
fi
osx:
name: macOS
@ -79,6 +64,7 @@ jobs:
name: Checkout
- name: Build OpenRCT2
run: |
. scripts/setenv
xcodebuild
mkdir -p artifacts
mv build/Release/OpenRCT2.app artifacts
@ -88,24 +74,15 @@ jobs:
name: "OpenRCT2-macOS"
path: artifacts
- name: Upload artifacts (openrct2.org)
env:
GITHUB_SHA1: ${{ github.sha }}
run: |
if [[ "$OPENRCT2_ORG_TOKEN" != "" ]]; then
if [[ $GITHUB_REF == refs/tags/* ]]; then
GITHUB_BRANCH=
else
GITHUB_BRANCH=${GITHUB_REF#refs/heads/}
if [[ ! "$GITHUB_BRANCH" =~ ^(develop|push/) ]]; then
exit 0
fi
fi
echo -e '\033[0;36mCompressing OpenRCT2.app...'
. scripts/setenv
if [[ "$OPENRCT2_PUSH" == "true" ]]; then
echo -e "\033[0;36mCompressing OpenRCT2.app...\033[0m"
cd artifacts
zip -rq openrct2-macos.zip OpenRCT2.app
../scripts/upload-build openrct2-macos.zip macos $OPENRCT2_VERSION $GITHUB_SHA1 $GITHUB_BRANCH
upload-build openrct2-macos.zip macos $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH
else
echo 'Not going to push build'
fi
build-appimage:
name: Linux (x64, AppImage)

View File

@ -2,60 +2,36 @@
<!-- Main msbuild project for OpenRCT2 -->
<!-- Inputs (/p: or environment variables)
- OPENRCT2_BUILD_SERVER
- GIT_TAG
- GIT_BRANCH
- GIT_COMMIT_SHA1
- GIT_DESCRIBE
- OPENRCT2_ORG_TOKEN
- NO_NSIS: set to true to prevent the NSIS installer building
- OPENRCT2_BRANCH
- OPENRCT2_SHA1
- OPENRCT2_SHA1_SHORT
- OPENRCT2_DESCRIBE
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="PublishAll">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<!-- Import custom build tasks -->
<Import Project="openrct2.targets" />
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<Platform Condition="'$(PLATFORM)'==''">x64</Platform>
<GIT_COMMIT_SHA1_SHORT Condition="'$(GIT_COMMIT_SHA1)'!=''">$(GIT_COMMIT_SHA1.Substring(0, 7))</GIT_COMMIT_SHA1_SHORT>
<Version>0.2.4</Version>
<VersionExtra Condition="'$(GIT_BRANCH)'!=''">-$(GIT_BRANCH)-$(GIT_COMMIT_SHA1_SHORT)</VersionExtra>
<VersionExtra Condition="'$(GIT_TAG)'!=''"></VersionExtra>
<TargetLibsVersion>16</TargetLibsVersion>
<Platform Condition="'$(Platform)'==''">x64</Platform>
<!-- Set dynamic OpenRCT2 #defines -->
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(BUILD_SERVER)'!=''">/D "OPENRCT2_BUILD_SERVER=\"$(BUILD_SERVER)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(GIT_BRANCH)'!=''">/D "OPENRCT2_BRANCH=\"$(GIT_BRANCH)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(GIT_COMMIT_SHA1)'!=''">/D "OPENRCT2_COMMIT_SHA1=\"$(GIT_COMMIT_SHA1)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(GIT_COMMIT_SHA1_SHORT)'!=''">/D "OPENRCT2_COMMIT_SHA1_SHORT=\"$(GIT_COMMIT_SHA1_SHORT)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(GIT_DESCRIBE)'!=''">/D "OPENRCT2_VERSION_TAG=\"$(GIT_DESCRIBE)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_BUILD_SERVER)'!=''">/D "OPENRCT2_BUILD_SERVER=\"$(OPENRCT2_BUILD_SERVER)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_BRANCH)'!=''">/D "OPENRCT2_BRANCH=\"$(OPENRCT2_BRANCH)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_SHA1)'!=''">/D "OPENRCT2_COMMIT_SHA1=\"$(OPENRCT2_SHA1)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_SHA1_SHORT)'!=''">/D "OPENRCT2_COMMIT_SHA1_SHORT=\"$(OPENRCT2_SHA1_SHORT)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_DESCRIBE)'!=''">/D "OPENRCT2_VERSION_TAG=\"$(OPENRCT2_DESCRIBE)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(Configuration)'=='Release'">/D "USE_BREAKPAD" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
<RootDir>$(MsBuildThisFileDirectory)</RootDir>
<DistDir>$(RootDir)distribution\</DistDir>
<ArtifactsDir>$(RootDir)artifacts\</ArtifactsDir>
<TargetDir>$(RootDir)bin\</TargetDir>
<NsisScript>$(DistDir)windows\install.nsi</NsisScript>
<OutputExe>$(TargetDir)openrct2.exe</OutputExe>
<OutputCom>$(TargetDir)openrct2.com</OutputCom>
<OutputDll>$(TargetDir)openrct2.dll</OutputDll>
<g2Output>$(TargetDir)data\g2.dat</g2Output>
<PublishPostfix>-$(Configuration)-$(Platform)</PublishPostfix>
<PublishPostfix Condition="'$(GIT_COMMIT_SHA1_SHORT)'!=''">$(PublishPostfix)-$(GIT_COMMIT_SHA1_SHORT)</PublishPostfix>
<PublishPostfix>$(PublishPostfix.ToLower())</PublishPostfix>
<PublishZip>$(ArtifactsDir)openrct2-portable$(PublishPostfix).zip</PublishZip>
<PublishSymbolsZip Condition="'$(GIT_COMMIT_SHA1_SHORT)'==''">$(ArtifactsDir)openrct2-symbols$(PublishPostfix).zip</PublishSymbolsZip>
<PublishSymbolsZip Condition="'$(GIT_COMMIT_SHA1_SHORT)'!=''">$(ArtifactsDir)openrct2-symbols$(PublishPostfix).zip</PublishSymbolsZip>
<PublishInstallerExe>$(ArtifactsDir)openrct2-installer$(PublishPostfix).exe</PublishInstallerExe>
<UploadFilename>OpenRCT2-$(Version)$(VersionExtra)-windows-$(Platform.ToLower())</UploadFilename>
<!-- Set openrct2.sln properties -->
<SlnProperties>$(SlnProperties);Platform=$(Platform)</SlnProperties>
<SlnProperties Condition="'$(BUILD_SERVER)'!=''">$(SlnProperties);OPENRCT2_CL_ADDITIONALOPTIONS=$(OPENRCT2_CL_ADDITIONALOPTIONS)</SlnProperties>
<SlnProperties Condition="'$(OPENRCT2_BUILD_SERVER)'!=''">$(SlnProperties);OPENRCT2_CL_ADDITIONALOPTIONS=$(OPENRCT2_CL_ADDITIONALOPTIONS)</SlnProperties>
</PropertyGroup>
<!-- 3rd party libraries / dependencies -->
@ -80,43 +56,6 @@
<g2Inputs Include="$(RootDir)resources\g2\*" />
</ItemGroup>
<ItemGroup Label="Symbol Items">
<SymbolItems Include="$(OutputExe)" />
<SymbolItems Include="$(OutputCom)" />
<SymbolItems Include="$(OutputDll)" />
<SymbolItems Include="$(TargetDir)openrct2-dll.pdb" />
<SymbolItems Include="$(TargetDir)openrct2-win.pdb" />
</ItemGroup>
<ItemGroup Label="Publish Items">
<PublishItems Include="$(OutputExe)" />
<PublishItems Include="$(OutputCom)" />
<PublishItems Include="$(OutputDll)" />
<PublishItems Include="$(TargetDir)data" />
<PublishItems Include="$(DistDir)changelog.txt" />
<PublishItems Include="$(DistDir)readme.txt" />
<PublishItems Include="$(RootDir)contributors.md" />
<PublishItems Include="$(RootDir)licence.txt" />
</ItemGroup>
<ItemGroup Label="Upload Artifacts">
<UploadArtifacts Include="$(PublishZip)">
<Name>$(UploadFilename).zip</Name>
<FlavourId Condition="'$(Platform)'=='Win32'">1</FlavourId>
<FlavourId Condition="'$(Platform)'=='x64'">6</FlavourId>
</UploadArtifacts>
<UploadArtifacts Include="$(PublishInstallerExe)">
<Name>$(UploadFilename).exe</Name>
<FlavourId Condition="'$(Platform)'=='Win32'">2</FlavourId>
<FlavourId Condition="'$(Platform)'=='x64'">7</FlavourId>
</UploadArtifacts>
<UploadArtifacts Include="$(PublishSymbolsZip)">
<Name>$(UploadFilename)-symbols.zip</Name>
<FlavourId Condition="'$(Platform)'=='Win32'">5</FlavourId>
<FlavourId Condition="'$(Platform)'=='x64'">10</FlavourId>
</UploadArtifacts>
</ItemGroup>
<Target Name="DownloadLibs">
<!-- libs -->
<DownloadDependency Name="Libs"
@ -142,13 +81,6 @@
<PropertyGroup>
<SlnProperties>$(SlnProperties);Configuration=$(Configuration)</SlnProperties>
</PropertyGroup>
<ItemGroup>
<CleanItems Include="$(OutputCom)" />
<CleanItems Include="$(g2Output)" />
<CleanItems Include="$(ArtifactsDir)openrct2-installer-$(Configuration)-$(Platform)*.exe" />
<CleanItems Include="$(ArtifactsDir)openrct2-portable-$(Configuration)-$(Platform)*.zip" />
<CleanItems Include="$(ArtifactsDir)openrct2-symbols-$(Configuration)-$(Platform)*.zip" />
</ItemGroup>
<Delete Files="@(CleanItems)" />
<RemoveDir Directories="$(TargetDir)data" />
<MSBuild Projects="openrct2.sln" Targets="Clean" Properties="$(SlnProperties)" />
@ -156,9 +88,9 @@
<Target Name="BeforeBuild" BeforeTargets="Build;Rebuild" DependsOnTargets="DownloadLibs">
<PropertyGroup>
<BuildString Condition="'$(GIT_COMMIT_SHA1_SHORT)'!=''">$(GIT_COMMIT_SHA1_SHORT)</BuildString>
<BuildString Condition="'$(GIT_BRANCH)'!=''">$(BuildString) ($(GIT_BRANCH))</BuildString>
<BuildString Condition="'$(GIT_DESCRIBE)'!=''">$(BuildString) ($(GIT_DESCRIBE))</BuildString>
<BuildString Condition="'$(OPENRCT2_SHA1_SHORT)'!=''">$(OPENRCT2_SHA1_SHORT)</BuildString>
<BuildString Condition="'$(OPENRCT2_BRANCH)'!=''">$(BuildString) ($(OPENRCT2_BRANCH))</BuildString>
<BuildString Condition="'$(OPENRCT2_DESCRIBE)'!=''">$(BuildString) ($(OPENRCT2_DESCRIBE))</BuildString>
</PropertyGroup>
<ItemGroup>
<DataItems Include="$(RootDir)data\**\*" />
@ -183,18 +115,6 @@
<MSBuild Projects="openrct2.sln" Targets="Rebuild" Properties="$(SlnProperties)" />
</Target>
<Target Name="Test">
<!-- Scan repositories prior to running tests as it can take a while -->
<Message Text="Building OpenRCT2 repository indexes..." Importance="high" />
<Exec Command="$(TargetDir)openrct2.exe scan-objects"
WorkingDirectory="$(TargetDir)"
StandardOutputImportance="normal" />
<Message Text="Running tests..." Importance="high" />
<Exec Command="$(TargetDir)tests.exe &quot;--gtest_output=xml:$(ArtifactsDir)test-results.xml&quot;"
WorkingDirectory="$(TargetDir)" />
</Target>
<!-- Target to build g2.dat containing OpenRCT2 sprites -->
<Target Name="g2" AfterTargets="Build" Inputs="@(g2Inputs)" Outputs="$(g2Output)"
Condition="'$(TestConfig)'!='true'">
@ -203,13 +123,6 @@
StandardOutputImportance="normal" />
</Target>
<!-- Target to create openrct2.exe (windows) and openrct2.com (console) -->
<Target Name="CreateGUI" DependsOnTargets="Build" AfterTargets="Build" Inputs="$(OutputExe)" Outputs="$(OutputCom)">
<Copy SourceFiles="$(OutputExe)" DestinationFiles="$(OutputCom)" />
<Exec Command="editbin /subsystem:console &quot;$(OutputCom)&quot;" />
<Exec Command="editbin /subsystem:windows &quot;$(OutputExe)&quot;" />
</Target>
<!-- Target to download the title sequences -->
<Target Name="DownloadTitleSequences" AfterTargets="Build">
<DownloadDependency Name="TitleSequences"
@ -236,70 +149,4 @@
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)testdata\replays" />
</Target>
<!-- Target to publish OpenRCT2 as a portable zip -->
<Target Name="PublishPortable" DependsOnTargets="Build;g2" Inputs="@(PublishItems)" Outputs="$(PublishZip)"
Condition="'$(TestConfig)'!='true'">
<MakeDir Directories="$(ArtifactsDir)" />
<Message Importance="high" Text="Creating $([System.IO.Path]::GetFileName($(PublishZip)))..." />
<_7z Output="$(PublishZip)" Inputs="@(PublishItems)" />
</Target>
<!-- Target to publish the OpenRCT2 debug symbols -->
<Target Name="PublishSymbols" DependsOnTargets="Build" Inputs="@(SymbolItems)" Outputs="$(PublishSymbolsZip)"
Condition="'$(TestConfig)'!='true'">
<MakeDir Directories="$(ArtifactsDir)" />
<Message Importance="high" Text="Creating $([System.IO.Path]::GetFileName($(PublishSymbolsZip)))..." />
<_7z Output="$(PublishSymbolsZip)" Inputs="@(SymbolItems)" />
</Target>
<!-- Target to publish the OpenRCT2 as an NSIS installer -->
<Target Name="PublishInstaller"
DependsOnTargets="Build;g2"
Inputs="@(PublishItems);$(NsisScript)"
Outputs="$(PublishInstallerExe)"
Condition="'$(NO_NSIS)'!='true' AND '$(TestConfig)'!='true'">
<PropertyGroup>
<PublishInstallerExeName>$([System.IO.Path]::GetFilename($(PublishInstallerExe)))</PublishInstallerExeName>
</PropertyGroup>
<MakeDir Directories="$(ArtifactsDir)" />
<!-- Create the installer -->
<Message Text="Building Windows Installer (NSIS script)" Importance="high" />
<Exec Command="makensis /DOUTFILE=$(PublishInstallerExe) ^
/DAPPV_MAIN=$(Version) ^
/DAPPV_EXTRA=$(VersionExtra) ^
/DPLATFORM=$(Platform) ^
$(NsisScript)"
StandardOutputImportance="normal" />
</Target>
<Target Name="PublishAll"
DependsOnTargets="PublishSymbols;PublishPortable;PublishInstaller" />
<!-- Target to upload the artifacts to OpenRCT2.org -->
<Target Name="UploadArtifacts" DependsOnTargets="PublishAll"
Condition="'$(TestConfig)'!='true'">
<PropertyGroup>
<UploadLink>https://openrct2.org/altapi/?command=push-build</UploadLink>
<UploadFileNameShort>%(UploadArtifacts.Filename)%(UploadArtifacts.Extension)</UploadFileNameShort>
<UploadGitBranch>master</UploadGitBranch>
<UploadGitBranch Condition="'$(GIT_BRANCH)'!=''">$(GIT_BRANCH)</UploadGitBranch>
</PropertyGroup>
<Message Text="Uploading $(UploadFileNameShort)" Importance="high" />
<Error Condition="'$(OPENRCT2_ORG_TOKEN)'==''" Text="OPENRCT2_ORG_TOKEN not set." />
<Error Condition="'$(GIT_COMMIT_SHA1)'==''" Text="GIT_COMMIT_SHA1 not set." />
<Exec EchoOff="true" Command="curl.exe -s -o - ^
--form &quot;key=$(OPENRCT2_ORG_TOKEN)&quot; ^
--form &quot;fileName=%(UploadArtifacts.Name)&quot; ^
--form &quot;version=$(Version)&quot; ^
--form &quot;gitHash=$(GIT_COMMIT_SHA1)&quot; ^
--form &quot;gitBranch=$(UploadGitBranch)&quot; ^
--form &quot;flavourId=%(UploadArtifacts.FlavourId)&quot; ^
--form &quot;file=@%(UploadArtifacts.Identity)&quot; ^
&quot;$(UploadLink)&quot;"
CustomErrorRegularExpression="&quot;error&quot;:1" />
</Target>
</Project>

26
scripts/build Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
set -e
# Ensure we are in root directory
basedir="$(readlink -f `dirname $0`/..)"
cd $basedir
# Patch version.h
if [[ "$OPENRCT2_BUILD" != "" ]]; then
echo -e "\033[0;36mPatching version.h...\033[0m"
fileversion=$OPENRCT2_VERSION.$OPENRCT2_BUILD
productversion="$fileversion-${OPENRCT2_SHA1_SHORT}"
fileversion=${fileversion//./,}
echo "#define OPENRCT2_FILE_VERSION $fileversion" > "resources/version.h"
echo "#define OPENRCT2_PRODUCT_VERSION \"$productversion\"" >> "resources/version.h"
cat "resources/version.h"
fi
# Build everything
echo -e "\033[0;36mBuilding OpenRCT2 for Windows $CONFIGURATION|$PLATFORM...\033[0m"
vstool msbuild openrct2.proj //t:build
# Create openrct2.exe and openrct2.com with correct subsystem
cp bin/openrct2.exe bin/openrct2.com
vstool editbin //subsystem:console bin/openrct2.com
vstool editbin //subsystem:windows bin/openrct2.exe

47
scripts/build-installer Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
set -e
if [[ "$#" -gt 2 || "$1" == "-h" ]]; then
echo 'Create a Windows installer for OpenRCT2'
echo ''
echo 'Usage: create-installer [-i] [<destination>]'
echo ''
echo ' -i install portable NSIS'
exit 1
fi
installnsis=
output=$1
if [[ "$1" == "-i" ]]; then
installnsis=true
output=$2
fi
basedir="$(readlink -f `dirname $0`/..)"
if [[ "$output" == "" ]]; then
mkdir -p "$basedir/artifacts"
output="$basedir/artifacts/openrct2-installer-$CONFIGURATION-$PLATFORM.exe"
fi
outputdir=$(dirname $output)
if ! [ -d "$outputdir" ]; then
echo -e >&2 "\033[0;31m$outputdir does not exist\033[0m"
exit 1
fi
output=$(cygpath -w $(readlink -f $output))
# Check makensis is available
if [[ "$installnsis" == "true" ]]; then
$basedir/scripts/install-nsis -d /tmp/nsis
export PATH=/tmp/nsis/bin:$PATH
fi
if ! [ -x "$(command -v makensis)" ]; then
echo -e >&2 "\033[0;31mmakensis not found\033[0m"
exit 1
fi
nsispath=$(cygpath -w $basedir/distribution/windows/install.nsi)
echo -e "\033[0;36mCreating installer for OpenRCT2 $OPENRCT2_VERSION-$OPENRCT2_VERSION_EXTRA ($PLATFORM)...\033[0m"
makensis "/DOUTFILE=$output" "//DAPPV_MAIN=$OPENRCT2_VERSION" "//DAPPV_EXTRA=${OPENRCT2_VERSION_EXTRA//\//\\}" "//DPLATFORM=$PLATFORM" "$nsispath"
printf '\033[0;32m%s\033[0m\n' "${output} created successfully"

58
scripts/build-portable Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
set -e
if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then
# Create a Windows symbols archive for OpenRCT2
basedir="$(readlink -f `dirname $0`/..)"
cd $basedir/bin
destination=../artifacts/openrct2-portable-$CONFIGURATION-$PLATFORM.zip
# Check 7z is available
if ! [ -x "$(command -v 7z)" ]; then
echo -e >&2 "\033[0;7z not found\033[0m"
exit 1
fi
echo -e "\033[0;36mCreating portable zip for Windows OpenRCT2...\033[0m"
if [[ -f $destination ]]; then
rm $destination
fi
7z a -r $destination \
openrct2.exe openrct2.com openrct2.dll data \
../distribution/changelog.txt \
../distribution/contributors.md \
../distribution/licence.txt \
../distribution/readme.txt \
destination=$(cygpath -w $(readlink -f $destination))
printf '\033[0;32m%s\033[0m\n' "${destination} created successfully"
else
if [[ "$#" -ne 2 ]]; then
echo 'Turn an OpenRCT2 cmake install into a portable tar.gz.'
echo ''
echo 'Usage: create-portable-build <output-file> <install-path>'
exit 1
fi
output=$1
install=$2
echo -e "\033[0;36mCreating $output..."
workdir=$output-temp
if [[ -d "$workdir" ]]
then
rm -rf $workdir
fi
mkdir -p $workdir/OpenRCT2
cp -r $install/bin/* $workdir/OpenRCT2
cp -r $install/share/doc $workdir/OpenRCT2
cp -r $install/share/openrct2 $workdir/OpenRCT2/data
pushd $workdir > /dev/null
tar -czf output.tar.gz OpenRCT2
popd > /dev/null
mv $workdir/output.tar.gz $output
rm -rf $workdir
echo -e "\033[0;32m$output created successfully"
fi

25
scripts/build-symbols Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -e
# Create a Windows symbols archive for OpenRCT2
basedir="$(readlink -f `dirname $0`/..)"
cd $basedir/bin
destination=../artifacts/openrct2-symbols-$CONFIGURATION-$PLATFORM.zip
# Check 7z is available
if ! [ -x "$(command -v 7z)" ]; then
echo -e >&2 "\033[0;7z not found\033[0m"
exit 1
fi
echo -e "\033[0;36mCreating symbols archive for OpenRCT2...\033[0m"
if [[ -f $destination ]]; then
rm $destination
fi
7z a $destination \
openrct2.exe openrct2.com openrct2.dll \
openrct2-dll.pdb openrct2-win.pdb
destination=$(cygpath -w $(readlink -f $destination))
printf '\033[0;32m%s\033[0m\n' "${destination} created successfully"

View File

@ -1,29 +0,0 @@
#!/bin/bash
set -e
if [[ "$#" -ne 2 ]]; then
echo 'Turn an OpenRCT2 cmake install into a portable tar.gz.'
echo ''
echo 'Usage: create-portable-build <output-file> <install-path>'
exit 1
fi
output=$1
install=$2
echo -e "\033[0;36mCreating $output..."
workdir=$output-temp
if [[ -d "$workdir" ]]
then
rm -rf $workdir
fi
mkdir -p $workdir/OpenRCT2
cp -r $install/bin/* $workdir/OpenRCT2
cp -r $install/share/doc $workdir/OpenRCT2
cp -r $install/share/openrct2 $workdir/OpenRCT2/data
pushd $workdir > /dev/null
tar -czf output.tar.gz OpenRCT2
popd > /dev/null
mv $workdir/output.tar.gz $output
rm -rf $workdir
echo -e "\033[0;32m$output created successfully"

34
scripts/install-nsis Normal file → Executable file
View File

@ -1,25 +1,43 @@
#!/bin/bash
set -e
if [[ "$#" -ne 0 && "$#" -ne 2 ]]; then
echo 'Install a portable version of NSIS which can build the OpenRCT2 Windows installer.'
echo ''
echo 'Usage: install-nsis [-d <destination>]'
echo ''
echo ' -d <destination> download prebuilt zip'
exit 1
fi
nsisdir="C:/ProgramData/chocolatey/lib/nsis.portable"
if [[ -d $nsisdir ]]
then
echo -e "\033[0;36mNSIS already installed."
if [[ "$1" == "-d" ]]; then
echo -e "\033[0;36mDownloading prebuilt NSIS from GitHub...\033[0m"
curl -sLo nsis.zip "https://github.com/OpenRCT2/Dependencies/releases/download/v20/nsis.zip"
7z -bd -y "-o$2" x nsis.zip
rm nsis.zip
echo -e "\033[0;32mNSIS downloaded, add "$2/bin" to PATH\033[0m"
exit 0
fi
echo -e "\033[0;36mDownloading NSIS from chocolatey..."
# Download NSIS with chocolatey and then download extra plugins
nsisdir="C:/ProgramData/chocolatey/lib/nsis.portable"
if [[ -d $nsisdir ]]
then
echo -e "\033[0;36mNSIS already installed.\033[0m"
exit 0
fi
echo -e "\033[0;36mDownloading NSIS from chocolatey...\033[0m"
cinst nsis.portable --version=3.01-beta1
echo -e "\033[0;36mDownloading KillProcDLL for NSIS..."
echo -e "\033[0;36mDownloading KillProcDLL for NSIS...\033[0m"
curl -sLo nsisxtra.zip "http://nsis.sourceforge.net/mediawiki/images/5/53/KillProcDll%26FindProcDll.zip"
7z x nsisxtra.zip
cp FindProcDLL.dll "$nsisdir/tools/nsis-3.0b1/Plugins/x86-ansi"
echo -e "\033[0;36mDownloading UAC plugin for NSIS..."
echo -e "\033[0;36mDownloading UAC plugin for NSIS...\033[0m"
curl -sLo uac.zip "http://nsis.sourceforge.net/mediawiki/images/8/8f/UAC.zip"
7z x uac.zip
cp UAC.nsh "$nsisdir/tools/nsis-3.0b1/Include"
cp -r Plugins "$nsisdir/tools/nsis-3.0b1"
echo -e "\033[0;32mNSIS installed!"
echo -e "\033[0;32mNSIS installed!\033[0m"

17
scripts/run-tests Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
set -e
# Ensure we are in root directory
basedir="$(readlink -f `dirname $0`/..)"
cd $basedir/bin
# Ensure test data uses LF
dos2unix testdata/keys/*
# Scan objects first so that does not happen within a test
echo -e "\033[0;36mBuilding OpenRCT2 repository indexes...\033[0m"
./openrct2 scan-objects
# Now run all the tests
echo -e "\033[0;36mRunning OpenRCT2 tests...\033[0m"
./tests --gtest_output=xml:../artifacts/test-results.xml

70
scripts/setenv Executable file
View File

@ -0,0 +1,70 @@
#!/bin/bash
# This sets up more environment variables using existing the environment
# It should be dot sourced into your environment
if [[ "$GITHUB_ACTIONS" != "true" ]]; then
export OPENRCT2_BUILD_SERVER=$(hostname)
export OPENRCT2_VERSION=0.2.4
GITHUB_REF=$(git rev-parse --symbolic-full-name HEAD)
GITHUB_SHA=$(git rev-parse HEAD)
fi
echo -e "\033[0;36mSetting up environment for OpenRCT2...\033[0m"
# Get the build number (number of commits since last tag)
export OPENRCT2_DESCRIBE=$(git describe HEAD)
get_build_number()
{
local pattern='.+-([0-9]+)-.+'
[[ $OPENRCT2_DESCRIBE =~ $pattern ]]
echo "${BASH_REMATCH[1]}"
}
export OPENRCT2_BUILD=$(get_build_number)
# Get the name of the branch and decide whether we should push the build to openrct2.org
export OPENRCT2_TAG=
export OPENRCT2_PUSH=
if [[ $GITHUB_REF == refs/tags/* ]]; then
export OPENRCT2_BRANCH=
export OPENRCT2_TAG=true
export OPENRCT2_PUSH=true
else
export OPENRCT2_BRANCH=${GITHUB_REF#refs/heads/}
if [[ "$OPENRCT2_BRANCH" =~ ^(develop|push/) ]]; then
export OPENRCT2_PUSH=true
fi
fi
if [[ "$OPENRCT2_ORG_TOKEN" == "" ]]; then
export OPENRCT2_PUSH=
fi
# Get the short SHA1
export OPENRCT2_SHA1=$GITHUB_SHA
export OPENRCT2_SHA1_SHORT=${OPENRCT2_SHA1:0:7}
export OPENRCT2_VERSION_EXTRA=
if [[ "$OPENRCT2_TAG" != "true" ]]; then
export OPENRCT2_VERSION_EXTRA=$OPENRCT2_BRANCH-$OPENRCT2_SHA1_SHORT
fi
# Add scripts directory to PATH
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$(pwd)/${1#./}"
}
scriptsdir="$(realpath `dirname ${BASH_SOURCE[0]}`)"
export PATH="$scriptsdir:$PATH"
# Output all the variables
if [[ "$1" != "-q" ]]; then
echo "----------------------------------------------"
echo "OPENRCT2_BUILD_SERVER: $OPENRCT2_BUILD_SERVER"
echo "OPENRCT2_TAG: $OPENRCT2_TAG"
echo "OPENRCT2_BRANCH: $OPENRCT2_BRANCH"
echo "OPENRCT2_VERSION: $OPENRCT2_VERSION"
echo "OPENRCT2_VERSION_EXTRA: $OPENRCT2_VERSION_EXTRA"
echo "OPENRCT2_BUILD: $OPENRCT2_BUILD"
echo "OPENRCT2_DESCRIBE: $OPENRCT2_DESCRIBE"
echo "OPENRCT2_PUSH: $OPENRCT2_PUSH"
echo "OPENRCT2_SHA1: $OPENRCT2_SHA1"
echo "OPENRCT2_SHA1_SHORT: $OPENRCT2_SHA1_SHORT"
echo "----------------------------------------------"
fi

2
scripts/vstool Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
vstool.cmd $@

23
scripts/vstool.cmd Normal file
View File

@ -0,0 +1,23 @@
@echo off
rem Invokes a tool within a Visual Studio prompt
rem Uses %PLATFORM% to set architecture of prompt
set "vspath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"
if exist "%vspath%" goto found
set "vspath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
if exist "%vspath%" goto found
:notfound
echo Visual Studio directory not found
exit /b 1
:found
if "%platform%"=="x64" (
call "%vspath%\Common7\Tools\VsDevCmd.bat" -no_logo -arch=x64
) else (
call "%vspath%\Common7\Tools\VsDevCmd.bat" -no_logo
)
%*
exit /b %errorlevel%