forked from Futuremappermydud/Nya-quest
-
Notifications
You must be signed in to change notification settings - Fork 2
/
releasedelete.ps1
91 lines (62 loc) · 1.86 KB
/
releasedelete.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
85
86
87
88
89
90
91
# Script to delete tags from remote and local if they failed to build
# import variables from versions.ps1
. ./versions.ps1
# Get version from cli argument
$modVersion = $args[0]
# Check if the input is empty
if ($modVersion -eq "") {
Write-Host "No version given! (example: 0.2.12)"
exit
}
# Check if version is in format x.x.x and have no other characters
if ($modVersion -notmatch '^\d+\.\d+\.\d+$') {
Write-Host "Version is not in format x.x.x (example: 0.2.12) or have other characters! it's the first argument"
exit
}
# Print version
Write-Host "Gonna do version: $modVersion"
# Create new tags array
$new_tags = @()
Write-Host "Tags are:"
Write-Host "-----------------"
# Loop through versions and tags 1:1
for ($i = 0; $i -lt $versions.Length; $i++) {
# Get version
$v = $versions[$i]
# Print tag
Write-Host "v$modVersion-bs-$v"
# v0.2.12-bs-1.24.0
$new_tags += "v$modVersion-bs-$v"
}
Write-Host "-----------------"
# Ask if we should continue
Write-Host "Delete these tags? (y/n)"
$continue = Read-Host
# If not then exit
if ($continue -ne "y") {
exit
}
Write-Host "Fetching tags from remote..."
# Fetch tags from remote
git fetch --tags
Write-Host "Done!"
# Loop through tags
for ($i = 0; $i -lt $new_tags.Length; $i++) {
# Get tag
$tag = $new_tags[$i]
# Check if the tag already exists, if it does then skip it
$tagExists = git tag | Select-String -Pattern $tag
if (!$tagExists) {
Write-Host "Tag $tag does not exist! skipping..."
continue
}
# Remove tag from remote
Write-Host "Removing tag $tag from remote..."
# Delete tag from remote
git push origin --delete $tag
# Delete tag from local
git tag -d $tag
Write-Host "Done!"
Write-Host "Remove tag $tag from local and remote..."
}
Write-Host "Done! All tags are deleted! Yaay! 🎉"