-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-production.ps1
66 lines (55 loc) · 1.68 KB
/
update-production.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Param(
[Parameter()]
[string]
$env='prod'
)
if ($env -eq $null) {
$env = read-host -Prompt "Please enter an environment (local, dev, or prod)"
}
function Menu ($object, $prompt) {
if (!$object) { Throw 'Must provide an object.' }
$ok = $false
Write-Host ''
do {
if ($prompt) { Write-Host $prompt }
for ($i = 0; $i -lt $object.count; $i++) {
Write-Host $i`. $object[$i]
}
Write-Host ''
$answer = Read-Host
if ($answer -in 0..($object.count-1)) {
$object[$answer]
$ok = $true
} else {
Write-Host 'Not an option!' -ForegroundColor Red
Write-Host ''
}
} while (!$ok)
}
Write-Host "git pull"
git pull
Write-Host "`nMost Recent Tags:"
$recentTags = git tag --sort=version:refname | select -Last 5
$tag = menu -object $recentTags -prompt 'Which tag do you want to check out?'
Write-Host "git checkout tags/$tag"
git checkout tags/$tag
Write-Host "git submodule sync"
git submodule sync
Write-Host "git submodule update"
git submodule update
Write-Host "update environment files"
Copy-Item -Path app/config/environment-$env.json -Destination app/config/environment.json
Copy-Item -Path composer-$env.json -Destination composer.json
Copy-Item -Path www/web-$env.config -Destination www/web.config
#UPDATE VERSION
Write-Host "Set versions"
$status = git status | Select -first 1
$statusWords = -split $status
$apiVersion = $statusWords[-1]
Write-Host "Version: $apiVersion"
$jsonBase = @{}
$jsonBase.Add("version",$apiVersion)
$jsonBase.Add("inherit",$true)
$jsonBase | ConvertTo-Json | Out-File "version.json"
Write-Host "composer update"
composer update