-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.ps1
More file actions
58 lines (42 loc) · 1.79 KB
/
Copy pathrelease.ps1
File metadata and controls
58 lines (42 loc) · 1.79 KB
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
Write-Host "=== F1 Reaction Service - Release Manager ===" -ForegroundColor Cyan
# 1. Version abfragen
$version = Read-Host "Welche Version willst du releasen? (z.B. 0.1.5)"
if ([string]::IsNullOrWhiteSpace($version)) {
Write-Host "No version provided. Abort!" -ForegroundColor Red
exit
}
$csprojPath = "F1ReactionService\F1ReactionService.csproj"
# Security check
if (-Not (Test-Path $csprojPath)) {
Write-Host "Error: Could not finde $csprojPath." -ForegroundColor Red
exit
}
Write-Host "Executing unit tests..." -ForegroundColor Yellow
# Execute the unit tests
dotnet test -v m
if ($LASTEXITCODE -ne 0) {
Write-Host "Oops! Unit tests failed." -ForegroundColor Red
Write-Host "Cancelled release. Nothing has been pushed." -ForegroundColor Red
exit
}
Write-Host "All tests green! Releasing..." -ForegroundColor Green
# ---------------------------------------------
# update csproj file
$content = Get-Content $csprojPath -Raw
if ($content -match "<Version>.*</Version>") {
$content = $content -replace "<Version>.*</Version>", "<Version>$version</Version>"
} else {
$content = $content -replace "</PropertyGroup>", " <Version>$version</Version>`r`n </PropertyGroup>"
}
[System.IO.File]::WriteAllText("$PWD\$csprojPath", $content)
Write-Host "-> csproj has been updated to version $version." -ForegroundColor Green
# Commit, Tag, Push
Write-Host "-> Create commit and git tag v$version..." -ForegroundColor Yellow
git add $csprojPath
git commit -m "Release v$version"
git tag "v$version"
git push origin master
git push origin "v$version"
Write-Host "=============================================" -ForegroundColor Cyan
Write-Host "Success! Version v$version tagged and pusehd!" -ForegroundColor Green
Write-Host "GitHub will create a new docker image." -ForegroundColor Gray