This repository was archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.ps1
67 lines (52 loc) · 1.7 KB
/
release.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
67
# Get current version
$versionFilePath = 'idfy_sdk/version.py'
$versionFileContent = Get-Content $versionFilePath
$currentVersion = $versionFileContent|%{$_.split('"')[1]}
if ([String]::IsNullOrWhiteSpace($currentVersion)) {
Write-Host "Current version not found." -ForegroundColor Red
exit 1
}
$versionParts = $currentVersion.TrimEnd("*-").Split(".")
$currentMajor = [Convert]::ToInt32($versionParts[0])
$currentMinor = [Convert]::ToInt32($versionParts[1])
$currentPatch = [Convert]::ToInt32($versionParts[2])
Write-Host "Current version: $currentVersion" -ForegroundColor Yellow
# Bump version
Write-Host "Which part of the version to bump (major|minor|patch)?"
$toBump = Read-Host
if ($toBump -eq "major") {
$currentMajor++
$currentMinor = 0
$currentPatch = 0
}
elseif ($toBump -eq "minor") {
$currentMinor++
$currentPatch = 0
}
elseif($toBump -eq "patch") {
$currentPatch++
}
else {
Write-Host "$toBump is not a valid part of the version number." -ForegroundColor Red
exit 1
}
$newVersion = "$currentMajor.$currentMinor.$currentPatch";
Write-Host "New version: $newVersion" -ForegroundColor Yellow
# Update version.py
$versionFileContent = $versionFileContent -replace $currentVersion, $newVersion
$versionFileContent | Set-Content $versionFilePath
Write-Host "Version updated in $versionFilePath. Enter the new version to confirm release."
$confirmedVersion = Read-Host
if ($confirmedVersion -ne $newVersion) {
Write-Host "Incorrect version. Release canceled" -ForegroundColor Red
exit 1
}
# Git commit version bump
Write-Host "Committing new version"
git add $versionFilePath
git commit -m "Release $newVersion"
git push origin master
# Create and push tag
$tag = "v$newVersion"
git tag $tag
git push origin $tag