-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.ps1
More file actions
69 lines (50 loc) · 2.04 KB
/
release.ps1
File metadata and controls
69 lines (50 loc) · 2.04 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
59
60
61
62
63
64
65
66
67
68
69
<#
.SYNOPSIS
Create a tag and release on GitHub
.DESCRIPTION
Create a tag on the repo and a release to that tag on GitHub remote repo.
This script works very well with GitHub Actions workflow that run on release creation.
Check the following workflow as an example:
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/.github/workflows/deploy_module_on_release.yml
.PARAMETER VersionTag
Tag to create (Sample: v10.0.01-alpha). This is the same tag that will be used for the release.
.PARAMETER Force
Force the script to run without confirmation.
.PARAMETER CreateTag
Create the tag on the repo. If not specified, the script will only create the release.
.EXAMPLE
.\release.ps1 -VersionTag v10.0.01-alpha
Create a release on the existing tag v10.0.01-alpha.
.EXAMPLE
.\release.ps1 -VersionTag v10.0.01-alpha -CreateTag
Create a release on the existing tag v10.0.01-alpha and create the tag on the repo.
.EXAMPLE
.\release.ps1 -VersionTag v10.0.01-alpha -CreateTag -Force
Create tag and create release without confirmation.
.LINK
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/release.ps1
#>
[cmdletbinding(SupportsShouldProcess, ConfirmImpact='High')]
param(
# Update the module manifest with the version tag (Sample: v10.0.01-alpha)
[Parameter(Mandatory)] [string]$VersionTag,
[Parameter()] [switch]$Force,
[Parameter()] [switch]$CreateTag,
[Parameter()] [switch]$NotPreRelease
)
# Confirm if not forced
if ($Force -and -not $Confirm){
$ConfirmPreference = 'None'
}
if ($CreateTag) {
if ($PSCmdlet.ShouldProcess($VersionTag, "git tag creation")) {
git tag -a $VersionTag -m "Release tag" -s ; git push --tags
}
}
if ($PSCmdlet.ShouldProcess($VersionTag, "gh release create")) {
if ($NotPreRelease) {
gh release create $VersionTag --generate-notes --verify-tag --title "Release $VersionTag"
} else {
gh release create $VersionTag --generate-notes --verify-tag --title "Release $VersionTag (PreRelease)" --prerelease
}
}