2018-03-20 10:43:18 +01:00
|
|
|
|
Param(
|
|
|
|
|
|
[string]$GitHubPersonalAccessToken,
|
|
|
|
|
|
[string]$Directory
|
|
|
|
|
|
)
|
|
|
|
|
|
$workingDirectory = $Directory
|
2019-01-08 15:53:58 +01:00
|
|
|
|
CD "$($workingDirectory)"
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
# Clone repo
|
2019-01-08 15:53:58 +01:00
|
|
|
|
$fullGitUrl = "https://$($env:GIT_URL)/$($env:GIT_REPOSITORYNAME).git"
|
|
|
|
|
|
git clone $($fullGitUrl) $($env:GIT_REPOSITORYNAME) 2>&1 | % { $_.ToString() }
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
# Remove everything so that unzipping the release later will update everything
|
|
|
|
|
|
# Don't remove the readme file nor the git directory
|
|
|
|
|
|
Write-Host "Cleaning up git directory before adding new version"
|
2019-01-08 15:53:58 +01:00
|
|
|
|
Remove-Item -Recurse "$($workingDirectory)\$($env:GIT_REPOSITORYNAME)\*" -Exclude README.md,.git
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
# Find release zip
|
2019-01-08 15:53:58 +01:00
|
|
|
|
$zipsDir = "$($workingDirectory)\$($env:BUILD_DEFINITIONNAME)\zips"
|
2018-03-20 10:43:18 +01:00
|
|
|
|
$pattern = "UmbracoCms.([0-9]{1,2}.[0-9]{1,3}.[0-9]{1,3}).zip"
|
2019-01-08 15:53:58 +01:00
|
|
|
|
Write-Host "Searching for Umbraco release files in $($zipsDir) for a file with pattern $($pattern)"
|
|
|
|
|
|
$file = (Get-ChildItem "$($zipsDir)" | Where-Object { $_.Name -match "$($pattern)" })
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
if($file)
|
|
|
|
|
|
{
|
|
|
|
|
|
# Get release name
|
2019-01-08 15:53:58 +01:00
|
|
|
|
$version = [regex]::Match($($file.Name), $($pattern)).captures.groups[1].value
|
|
|
|
|
|
$releaseName = "Umbraco $($version)"
|
|
|
|
|
|
Write-Host "Found $($releaseName)"
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
# Unzip into repository to update release
|
|
|
|
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
2019-01-08 15:53:58 +01:00
|
|
|
|
Write-Host "Unzipping $($file.FullName) to $($workingDirectory)\$($env:GIT_REPOSITORYNAME)"
|
|
|
|
|
|
[System.IO.Compression.ZipFile]::ExtractToDirectory("$($file.FullName)", "$($workingDirectory)\$($env:GIT_REPOSITORYNAME)")
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
# Telling git who we are
|
|
|
|
|
|
git config --global user.email "coffee@umbraco.com" 2>&1 | % { $_.ToString() }
|
|
|
|
|
|
git config --global user.name "Umbraco HQ" 2>&1 | % { $_.ToString() }
|
|
|
|
|
|
|
|
|
|
|
|
# Commit
|
2019-01-08 15:53:58 +01:00
|
|
|
|
CD "$($workingDirectory)\$($env:GIT_REPOSITORYNAME)"
|
|
|
|
|
|
Write-Host "Committing Umbraco $($version) Release from Build Output"
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
git add . 2>&1 | % { $_.ToString() }
|
2019-01-08 15:53:58 +01:00
|
|
|
|
git commit -m " Release $($releaseName) from Build Output" 2>&1 | % { $_.ToString() }
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
# Tag the release
|
2019-01-08 15:53:58 +01:00
|
|
|
|
git tag -a "v$($version)" -m "v$($version)"
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
# Push release to master
|
2019-01-08 15:53:58 +01:00
|
|
|
|
$fullGitAuthUrl = "https://$($env:GIT_USERNAME):$($GitHubPersonalAccessToken)@$($env:GIT_URL)/$($env:GIT_REPOSITORYNAME).git"
|
|
|
|
|
|
git push $($fullGitAuthUrl) 2>&1 | % { $_.ToString() }
|
2018-03-20 10:43:18 +01:00
|
|
|
|
|
|
|
|
|
|
#Push tag to master
|
2019-01-08 15:53:58 +01:00
|
|
|
|
git push $($fullGitAuthUrl) --tags 2>&1 | % { $_.ToString() }
|
2018-03-20 10:43:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-01-08 15:53:58 +01:00
|
|
|
|
Write-Error "Umbraco release file not found, searched in $($workingDirectory)\$($zipsDir) for a file with pattern $($pattern) - canceling"
|
2018-03-20 10:43:18 +01:00
|
|
|
|
}
|