forked from Kipper-Lang/Kipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump.ps1
84 lines (70 loc) · 1.98 KB
/
bump.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env pwsh
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction']='Stop'
function ExitOnFailure {
if ($LastExitCode -ne 0)
{
Write-Output ""
Write-Error "Unexpected error during operation"
Exit 1
}
}
# Check whether there is a version argument
if ( $args.Count -lt 1 ) {
Write-Output "ERR: No version identifier supplied"
Exit 1
}
elseif ($args.Count -gt 1)
{
Write-Error "ERR: Too many arguments!"
Exit 1
}
else
{
Write-Output ("-- Bumping version {0}" -f $args[0])
# Fetching tags to make sure unknown tags are not re-created
Write-Output "-- Fetching tags and releases from remote"
$null = $(git fetch --all --tags)
# Make sure the tag doesn't exist already
$tag = $(git tag -l ("v{0}" -f $args[0]))
if ($tag -eq ("v{0}" -f $args[0]))
{
Write-Error ("ERR: Git tag v{0} already exists!" -f $args[0])
Exit 1
}
# Build all files
Write-Output "-- Building files"
$(pnpm run build)
ExitOnFailure
# Run the version command for the root package
Write-Output "-- Updating root project"
$null = $(pnpm version ("{0}" -f $args[0]))
ExitOnFailure
# Revert the auto-generated commit
Write-Output "-- Removed auto-generated commit from pnpm version"
$null = $(git reset --soft HEAD~1)
ExitOnFailure
# Delete the auto generated tag
Write-Output "-- Remove generated tag from pnpm version"
$(git tag -d ("v{0}" -f $args[0]))
ExitOnFailure
# Run the version command for every package
Write-Output "-- Updating child projects"
$(pnpm -r version ("{0}" -f $args[0]))
ExitOnFailure
# Commit changes
Write-Output "-- Committing changes"
$(git commit -a -m ("Release {0}" -f $args[0]))
$(git tag -a ("v{0}" -f $args[0]) -m ("Release {0}" -f $args[0]))
ExitOnFailure
# Update lock files
Write-Output "-- Updating lock files"
$null = $(pnpm install)
ExitOnFailure
# Push tags
Write-Output "-- Pushing to remote"
$(git push origin ("v{0}" -f $args[0]))
ExitOnFailure
# Exit
Exit 0
}