forked from Sollumz/Sollumz
-
Notifications
You must be signed in to change notification settings - Fork 3
/
prepare_release.ps1
48 lines (39 loc) · 1.46 KB
/
prepare_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
param(
# The new version
[Parameter(Mandatory=$true)]
[string]
$Version
)
if ((Get-Command "git" -ErrorAction SilentlyContinue) -eq $null)
{
Throw "'git' not available in PATH!"
}
$Version = $Version.TrimStart("v")
$versionComponents = $Version.Split(".") -match "^\d+$"
if ($versionComponents.Length -ne 3) {
Throw "Version expected to have 3 numbers!"
}
$major = $versionComponents[0]
$minor = $versionComponents[1]
$patch = $versionComponents[2]
# Update version in __init__.py
(Get-Content -Raw __init__.py) -replace "`"version`": \(\d+, \d+, \d+\)", "`"version`": ($major, $minor, $patch)" |
Set-Content -NoNewline __init__.py
# Create commit and tag
& git add __init__.py
& git commit -m "chore: bump version to $Version"
& git tag "v$Version"
Write-Host "Add-on version updated and commited. When ready, push with ``git push && git push --tags``"
# Generate release notes from commit messages with git-cliff
if ((Get-Command "git-cliff" -ErrorAction SilentlyContinue) -eq $null)
{
Write-Warning "Cannot find 'git-cliff' in PATH. Release notes won't be generated. If desired, install with 'cargo install --git https://github.com/orhun/git-cliff'."
}
else
{
& git-cliff --current -c cliff.toml -o RELEASE_NOTES.md
Write-Host "Release notes written to 'RELEASE_NOTES.md'. Might need some clean up before publishing the GitHub release."
}
# Create archive
& git archive --prefix Sollumz/ -o Sollumz.zip "v$Version"
Write-Host "Archive created in 'Sollumz.zip'."