Add automated build with GitHub Actions
-
Add automated build for dmdext so that users can get the latest from "Actions" tab
Then scrolling down :
This does not generate a release, but could be added.
I later found out that snapshot builds are generated and available elsewhere : https://ci.appveyor.com/project/freezy/dmd-extensions/history
@freezy, you may or may not want to keep this PR then 😃
I later found out that snapshot builds are generated and available elsewhere : https://ci.appveyor.com/project/freezy/dmd-extensions/history
@freezy, you may or may not want to keep this PR then 😃
Yes but the build is available only one month on appveyor. Which mean for example that the latest release is not available anymore 😅
This is awesome, thanks a lot!
As @VincentMolinie said, it would be more reliable having this at GitHub directly. However, what's still missing here is:
- [ ] Update version based on tag / branch and name the artifacts accordingly.
- [ ] Pull the installer files as well, not just the .zip files.
@ojacques if you're up to having a look at those two points that'd be great. Here's the build scripts I'm using at AppVeyor:
Before build script:
function replaceNumericVersion($name, $fileContent) {
$RegularExpression = [regex] "^[^/]*\[assembly:\s*$name\(\""(\d+)\.(\d+)\.(\d+)(\.(\d+))?\""\)"
foreach($content in $fileContent)
{
$match = [System.Text.RegularExpressions.Regex]::Match($content, $RegularExpression)
if ($match.Success) {
$major=$match.groups[1].value -as [int]
$minor=$match.groups[2].value -as [int]
$patch=$match.groups[3].value -as [int]
$revision=$match.groups[4].value -as [int]
#"$major.$minor.$patch.$revision -> $major.$minor.$patch.$env:APPVEYOR_BUILD_NUMBER"
return $fileContent -replace "^[^/]*\[assembly:\s*$name\(\""[^""]*\""\)", "[assembly: $name(""$major.$minor.$patch.$env:APPVEYOR_BUILD_NUMBER"")"
}
}
}
function replaceFullVersion($name, $fileContent) {
$RegularExpression = [regex] "[^/]*\[assembly:\s*$name\(\""(\d)\.(\d)\.(\d)(-([\w\W]+))?\""\)"
foreach($content in $fileContent)
{
$match = [System.Text.RegularExpressions.Regex]::Match($content, $RegularExpression)
if ($match.Success) {
$major=$match.groups[1].value -as [int]
$minor=$match.groups[2].value -as [int]
$patch=$match.groups[3].value -as [int]
$tag=$match.groups[5].value
#$branch= &git rev-parse --abbrev-ref HEAD
$branch = if (Test-Path "env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH") {
$env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
} Else {
$env:APPVEYOR_REPO_BRANCH
}
if ($branch -eq "master") {
if ($tag) {
$version = "$major.$minor.$patch-$tag-r$env:APPVEYOR_BUILD_NUMBER"
} else {
$version = "$major.$minor.$patch-r$env:APPVEYOR_BUILD_NUMBER"
}
} else {
$version = "$major.$minor.$patch-$($branch.ToUpper())-r$env:APPVEYOR_BUILD_NUMBER"
}
Add-AppveyorMessage -Message "Changing version from $major.$minor.$patch-$tag to $version"
Update-AppveyorBuild -Version $version
return $fileContent -replace "^[^/]*\[assembly:\s*$name\(\""[^""]*\""\)", "[assembly: $name(""$version"")"
}
}
}
function replaceAny($name, $replaceWith, $fileContent) {
$RegularExpression = [regex] "^[^/]*\[assembly:\s*$name\(\""[^""]*\""\)"
foreach($content in $fileContent)
{
$match = [System.Text.RegularExpressions.Regex]::Match($content, $RegularExpression)
if ($match.Success) {
return $fileContent -replace "^[^/]*\[assembly:\s*$name\(\""[^""]*\""\)", "[assembly: $name(""$replaceWith"")"
}
}
}
$assemblyFile = "VersionAssemblyInfo.cs"
$fileContent = Get-Content $assemblyFile
$fileContent = replaceNumericVersion 'AssemblyVersion' $fileContent
$fileContent = replaceNumericVersion 'AssemblyFileVersion' $fileContent
$fileContent = replaceFullVersion 'AssemblyInformationalVersion' $fileContent
if ($env:APPVEYOR_REPO_TAG -ne "true" -or ! $env:APPVEYOR_REPO_TAG_NAME) {
$fileContent = replaceAny 'AssemblyConfiguration' $env:APPVEYOR_REPO_COMMIT.Substring(0, 7) $fileContent
}
$fileContent | Set-Content "$assemblyFile"
Add-AppveyorMessage -Message "Patching $assemblyFile"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "https://github.com/freezy/dmd-extensions/files/4073824/VPinMAME31_Minimal.zip" -OutFile vpm.zip
Expand-Archive vpm.zip -DestinationPath vpm
cd vpm
regsvr32 /s VPinMAME.dll
cd ..
dir
nuget restore
.\DllExport -action Restore -sln-file DmdExtensions.sln
After build script:
$zipArchive = "$env:APPVEYOR_BUILD_FOLDER\Installer\Builds\dmdext-$env:APPVEYOR_BUILD_VERSION-$env:PLATFORM-$env:CONFIGURATION.zip"
New-Item -ItemType Directory -Force -Path "$env:APPVEYOR_BUILD_FOLDER\Installer\Builds"
Compress-Archive -Path "$env:APPVEYOR_BUILD_FOLDER\Console\bin\$env:PLATFORM\$env:CONFIGURATION\dmdext.exe" -Update -DestinationPath $zipArchive
Compress-Archive -Path "$env:APPVEYOR_BUILD_FOLDER\Console\bin\$env:PLATFORM\$env:CONFIGURATION\dmdext.log.config" -Update -DestinationPath $zipArchive
Compress-Archive -Path "$env:APPVEYOR_BUILD_FOLDER\Console\ProPinballSlave.bat" -Update -DestinationPath $zipArchive
if ($env:PLATFORM -eq "x64") {
$dllSuffix = "64"
} else {
$dllSuffix = ""
}
Compress-Archive -Path "$env:APPVEYOR_BUILD_FOLDER\PinMameDevice\bin\$env:PLATFORM\$env:CONFIGURATION\DmdDevice$dllSuffix.dll" -Update -DestinationPath $zipArchive
Compress-Archive -Path "$env:APPVEYOR_BUILD_FOLDER\PinMameDevice\bin\$env:PLATFORM\$env:CONFIGURATION\DmdDevice.log.config" -Update -DestinationPath $zipArchive
Compress-Archive -Path "$env:APPVEYOR_BUILD_FOLDER\PinMameDevice\DmdDevice.ini" -Update -DestinationPath $zipArchive
Rename-Item "$env:APPVEYOR_BUILD_FOLDER\PinMameDevice\data" "$env:APPVEYOR_BUILD_FOLDER\PinMameDevice\dmdext"
Compress-Archive -Path "$env:APPVEYOR_BUILD_FOLDER\PinMameDevice\dmdext" -Update -DestinationPath $zipArchive
New-Item -Path "$env:APPVEYOR_BUILD_FOLDER\LibDmd\Input\FutureDmd\" -Name "Future Pinball" -ItemType "directory"
Move-Item -Path "$env:APPVEYOR_BUILD_FOLDER\LibDmd\Input\FutureDmd\OpenGL32.dll" -Destination "$env:APPVEYOR_BUILD_FOLDER\LibDmd\Input\FutureDmd\Future Pinball\OpenGL32.dll"
Compress-Archive -Path "$env:APPVEYOR_BUILD_FOLDER\LibDmd\Input\FutureDmd\Future Pinball" -Update -DestinationPath $zipArchive
@ojacques if you're up to having a look at those two points that'd be great.
Sure!
Closing this PR in favor of a new implementation.
Cool, having a look now!