From b6811d2d99da08c81418a9694bb558f7c26e6ec0 Mon Sep 17 00:00:00 2001 From: Tomas Jurasek Date: Tue, 19 Sep 2017 15:53:00 +0200 Subject: [PATCH 1/3] CI script --- Tools/build/publish.ps1 | 90 ++++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 29 deletions(-) diff --git a/Tools/build/publish.ps1 b/Tools/build/publish.ps1 index fa677cfa..1807a5ee 100644 --- a/Tools/build/publish.ps1 +++ b/Tools/build/publish.ps1 @@ -1,4 +1,4 @@ -param([String]$version, [String]$controlName, [String]$apiKey, [String]$server, [String]$branchName, [String]$repoUrl, [String]$nugetRestoreAltSource = "", [bool]$pushTag) +param([String]$version,[String]$dotVVMVersion, [String]$apiKey, [String]$server, [String]$branchName, [String]$repoUrl, [String]$nugetRestoreAltSource = "") ### Helper Functions @@ -35,45 +35,81 @@ $LASTEXITCODE function CleanOldGeneratedPackages() { foreach ($package in $packages) { - del .\$($package.Directory)\bin\debug\*.nupkg -ErrorAction SilentlyContinue + del .\$($package.Directory)\DotVVM.Contrib\bin\debug\*.nupkg -ErrorAction SilentlyContinue } } function SetVersion() { foreach ($package in $packages) { - $filePath = ".\$($package.Directory)\DotVVM.Contrib.csproj" - $file = [System.IO.File]::ReadAllText($filePath, [System.Text.Encoding]::UTF8) - $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\([^<]+)\", "" + $version + "") - $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\([^<]+)\", "" + $version + "") - [System.IO.File]::WriteAllText($filePath, $file, [System.Text.Encoding]::UTF8) + + $folders = Get-ChildItem $package.Directory -Directory | Where { $_.Name.Contains('DotVVM.Contrib') -and !$_.Name.Contains('DotVVM.Contrib.Tests') } | Foreach { [pscustomobject]@{ Package = $_.Name; Directory = $package.Directory +"\" + $_.Name}} ; + + foreach ($folder in $folders){ + + if($folder.Package -eq 'DotVVM.Contrib'){ + $filePath = ".\$($folder.Directory)\" + $folder.Package + ".csproj"; + $file = [System.IO.File]::ReadAllText($filePath, [System.Text.Encoding]::UTF8) + $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\([^<]+)\", "" + $version + "") + $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\([^<]+)\", "" + $version + "") + $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\([^<]+)\", "netcoreapp2.0;net451") + [System.IO.File]::WriteAllText($filePath, $file, [System.Text.Encoding]::UTF8) + + $filePath = ".\$($package.Directory)\DotVVM.Contrib\Properties\AssemblyInfo.cs" + $file = [System.IO.File]::ReadAllText($filePath, [System.Text.Encoding]::UTF8) + $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\[assembly: AssemblyVersion\(""([^""]+)""\)\]", "[assembly: AssemblyVersion(""" + $versionWithoutPre + """)]") + $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\[assembly: AssemblyFileVersion\(""([^""]+)""\)]", "[assembly: AssemblyFileVersion(""" + $versionWithoutPre + """)]") + [System.IO.File]::WriteAllText($filePath, $file, [System.Text.Encoding]::UTF8) + } + else{ + $filePath = ".\$($folder.Directory)\" + $folder.Package + ".csproj"; + $file = [System.IO.File]::ReadAllText($filePath, [System.Text.Encoding]::UTF8) + $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\([^<]+)\", "netcoreapp2.0") $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\", " ") $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\", " ") $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\", " ") [System.IO.File]::WriteAllText($filePath, $file, [System.Text.Encoding]::UTF8) + } + + + + } - $filePath = ".\$($package.Directory)\Properties\AssemblyInfo.cs" - $file = [System.IO.File]::ReadAllText($filePath, [System.Text.Encoding]::UTF8) - $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\[assembly: AssemblyVersion\(""([^""]+)""\)\]", "[assembly: AssemblyVersion(""" + $versionWithoutPre + """)]") - $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\[assembly: AssemblyFileVersion\(""([^""]+)""\)]", "[assembly: AssemblyFileVersion(""" + $versionWithoutPre + """)]") - [System.IO.File]::WriteAllText($filePath, $file, [System.Text.Encoding]::UTF8) } } function BuildPackages() { foreach ($package in $packages) { - cd .\$($package.Directory) + + $folders = Get-ChildItem $package.Directory -Directory | Where { $_.Name -eq 'DotVVM.Contrib'} | Foreach { [pscustomobject]@{ Package = $_.Name; Directory = $package.Directory +"\" + $_.Name}} ; + + foreach($folder in $folders){ + cd .\$($folder.Directory) - if ($nugetRestoreAltSource -eq "") { - & dotnet restore | Out-Host - } - else { - & dotnet restore --source $nugetRestoreAltSource --source https://nuget.org/api/v2/ | Out-Host - } + if ($nugetRestoreAltSource -eq "") { + & dotnet restore | Out-Host + } + else { + & dotnet restore --source $nugetRestoreAltSource --source https://nuget.org/api/v2/ | Out-Host + } - & dotnet pack | Out-Host - cd ..\..\..\.. + & dotnet pack | Out-Host + + cd ..\..\..\.. + } } } +function Build(){ + foreach ($package in $packages) { + $folders = Get-ChildItem $package.Directory -Directory | Where {$_.Name.Contains('DotVVM.Contrib')}| Foreach { [pscustomobject]@{ Package = $_.Name; Directory = $package.Directory +"\" + $_.Name}}; + + foreach($folder in $folders){ + cd .\$($folder.Directory) + dotnet build + cd ..\..\..\.. + } + } +} + function PushPackages() { foreach ($package in $packages) { - & .\Tools\nuget.exe push .\$($package.Directory)\bin\debug\$($package.Package).$version.nupkg -source $server -apiKey $apiKey | Out-Host + & .\Tools\nuget.exe push .\$($package.Directory)\DotVVM.Contrib\bin\debug\$($package.Package).$version.nupkg -source $server -apiKey $apiKey | Out-Host } } @@ -83,10 +119,7 @@ function GitCheckout() { } function GitPush() { - if ($pushTag) { - invoke-git tag "$($ControlName)-v$($version)" HEAD - } - invoke-git commit -am "$($ControlName): NuGet package version $version" + invoke-git commit -am "Controls: NuGet packages version $version" invoke-git rebase HEAD $branchName invoke-git push --follow-tags $repoUrl $branchName } @@ -95,9 +128,7 @@ function GitPush() { ### Configuration -$packages = @( - [pscustomobject]@{ Package = "DotVVM.Contrib." + $controlName; Directory = "Controls\" + $controlName + "\src\DotVVM.Contrib" } -) +$packages = Get-ChildItem .\Controls -Directory |Where {$_.Name -match '^(?!_)' } | Foreach { [pscustomobject]@{ Package = "DotVVM.Contrib." + $_.Name; Directory = "Controls\" + $_.Name + "\src"}} ### Publish Workflow @@ -110,5 +141,6 @@ CleanOldGeneratedPackages; GitCheckout; SetVersion; BuildPackages; +Build; PushPackages; GitPush; From 592d44f634bcecbf46ea15f63c0dc288cd8eb478 Mon Sep 17 00:00:00 2001 From: Tomas Jurasek Date: Wed, 20 Sep 2017 06:51:53 +0200 Subject: [PATCH 2/3] exludeControls parameter --- Tools/build/publish.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tools/build/publish.ps1 b/Tools/build/publish.ps1 index 1807a5ee..489b67d9 100644 --- a/Tools/build/publish.ps1 +++ b/Tools/build/publish.ps1 @@ -1,4 +1,4 @@ -param([String]$version,[String]$dotVVMVersion, [String]$apiKey, [String]$server, [String]$branchName, [String]$repoUrl, [String]$nugetRestoreAltSource = "") +param([String]$version,[String]$dotVVMVersion, [String]$apiKey, [String]$server, [String]$branchName, [String]$repoUrl, [String[]] $exludeControls = "", [String]$nugetRestoreAltSource = "") ### Helper Functions @@ -40,8 +40,8 @@ function CleanOldGeneratedPackages() { } function SetVersion() { - foreach ($package in $packages) { - + foreach ($package in $packages) { + $folders = Get-ChildItem $package.Directory -Directory | Where { $_.Name.Contains('DotVVM.Contrib') -and !$_.Name.Contains('DotVVM.Contrib.Tests') } | Foreach { [pscustomobject]@{ Package = $_.Name; Directory = $package.Directory +"\" + $_.Name}} ; foreach ($folder in $folders){ @@ -128,7 +128,7 @@ function GitPush() { ### Configuration -$packages = Get-ChildItem .\Controls -Directory |Where {$_.Name -match '^(?!_)' } | Foreach { [pscustomobject]@{ Package = "DotVVM.Contrib." + $_.Name; Directory = "Controls\" + $_.Name + "\src"}} +$packages = Get-ChildItem .\Controls -Directory |Where {$_.Name -match '^(?!_)' -and ($exludeControls.Count -gt 0 -and !$exludeControls.Contains($_.Name))} | Foreach { [pscustomobject]@{ Package = "DotVVM.Contrib." + $_.Name; Directory = "Controls\" + $_.Name + "\src"}} ### Publish Workflow From 31fd897c313aff37243ecc4dc2f6e6741b57a4fe Mon Sep 17 00:00:00 2001 From: Tomas Jurasek Date: Wed, 20 Sep 2017 06:54:30 +0200 Subject: [PATCH 3/3] tiny changes --- Tools/build/publish.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/build/publish.ps1 b/Tools/build/publish.ps1 index 489b67d9..34d98941 100644 --- a/Tools/build/publish.ps1 +++ b/Tools/build/publish.ps1 @@ -1,4 +1,4 @@ -param([String]$version,[String]$dotVVMVersion, [String]$apiKey, [String]$server, [String]$branchName, [String]$repoUrl, [String[]] $exludeControls = "", [String]$nugetRestoreAltSource = "") +param([String]$version,[String]$dotVVMVersion, [String]$apiKey, [String]$server, [String]$branchName, [String]$repoUrl, [String[]] $exludeControls, [String]$nugetRestoreAltSource = "") ### Helper Functions