-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRelease-Project.ps1
More file actions
53 lines (43 loc) · 1.69 KB
/
Release-Project.ps1
File metadata and controls
53 lines (43 loc) · 1.69 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
<#
.SYNOPSIS
Bump version, tag a release and push to origin.
.DESCRIPTION
Bump the project version, tag a release, and push to remotes/origin.
A CI pipeline will then build, test, and release.
.EXAMPLE
PS> .\scripts\Release-Project.ps1 -Bump patch
.NOTES
Requires bump-my-version <https://github.com/callowayproject/bump-my-version>.
#>
Param (
# What version component to bump, either "major", "minor", or "patch".
[Parameter(Mandatory, HelpMessage = "What version component to bump.")]
[ValidateSet("major", "minor", "patch")]
[string]$Bump,
# Show what would be done, but do not do it.
[switch]$DryRun,
# Do not abort if the working direcotry is dirty. Useful in CI, to allow changes in uv.lock.
[switch]$AllowDirty
)
#Requires -Version 7.4
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
Import-Module -Name "$PSScriptRoot\Utils.psm1"
git fetch --all --tags
$CurrentBranch = git branch --show-current
if ($CurrentBranch -ne "master") {
throw "Release invoked, but not on master branch.`n" `
+ "You probably want to merge your work into master. Quitting."
}
# https://stackoverflow.com/a/50737015
# https://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git/17192101#comment23385634_3258271
$UpToDate = git rev-list HEAD..origin/master --count
if (-Not $UpToDate) {
throw "Local repository is not up-to-date. Run git pull. Quitting."
}
$DryRunOption = ($DryRun) ? "--dry-run" : $null
$AllowDirtyOption = ($AllowDirty) ? "--allow-dirty" : $null
uv run $(Get-UvRunOptions) bump-my-version bump $Bump $DryRunOption $AllowDirtyOption --verbose
if (-not ($DryRun)) {
git push --follow-tags
}