Skip to content

Commit 18c9f0e

Browse files
committed
add script
2 parents 94745be + 9e2cbb9 commit 18c9f0e

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

bin/Publish.ps1

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<#
2+
.DESCRIPTION
3+
Publishes to 'master' after deleting dev files.
4+
#>
5+
6+
param([string]$Tag)
7+
8+
function AbortIfProcessFailed {
9+
param([string]$message)
10+
if ($LASTEXITCODE) { throw $message }
11+
exit $LASTEXITCODE
12+
}
13+
14+
function AbortIfDirtyWorkingDirectory {
15+
if (@(git status --short).Count -ne 0) {
16+
throw "uncommited changes "
17+
exit 1
18+
}
19+
}
20+
21+
function AbortIfGitNotAvailable {
22+
get-command git -erroraction stop > $null
23+
}
24+
25+
function AbortIfNotOnMaster {
26+
if (@(git branch | select-string "* master" -simplematch).Count -eq 0) {
27+
throw "not on 'master' branch"
28+
exit 1
29+
}
30+
}
31+
32+
$toDelete = @(
33+
"manifest.json",
34+
"tests",
35+
"bin"
36+
)
37+
38+
AbortIfGitNotAvailable
39+
AbortIfDirtyWorkingDirectory
40+
AbortIfNotOnMaster
41+
42+
try {
43+
push-location $PSScriptRoot\..
44+
45+
remove-item -recurse $toDelete -exclude "Publish.ps1" -whatif
46+
47+
write-warning "commit the files, tag and push upstream"
48+
}
49+
finally {
50+
pop-location
51+
}
52+

0 commit comments

Comments
 (0)