forked from Futuremappermydud/Nya-quest
-
Notifications
You must be signed in to change notification settings - Fork 2
/
release.ps1
110 lines (81 loc) · 2.28 KB
/
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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Script to release a new version of the mod to github easily,
# you need to cherry-pick the commits to the branches first manually though
# 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 "New 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 "Continue? (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]
# Get version
$version = $versions[$i]
# Get branch
$branch = $branches[$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 already exists! skipping..."
continue
}
Write-Host "Created tag: $tag from branch: $branch for $version"
# Create tag
git tag $tag $branch -m "Release $modVersion for Beat Saber $version"
}
# Ask if we should push
Write-Host "Push tags? (y/n)"
$push = Read-Host
# If not then exit
if ($push -ne "y") {
exit
}
# Push tags
for ($i = 0; $i -lt $new_tags.Length; $i++) {
# Get tag
$tag = $new_tags[$i]
# Get version
$version = $versions[$i]
# Get branch
$branch = $branches[$i]
Write-Host "Pushing $tag"
# Push tag
git push origin $tag
}
Write-Host "Done! All tags pushed! Yaay! 🎉"