forked from navikt/github-app-token-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·45 lines (34 loc) · 924 Bytes
/
release.sh
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
#!/bin/bash
if [[ "$#" -ne 1 ]] || [[ ! $1 =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "Usage: $0 vX.Y.Z"
exit 1
fi
branch=$(git branch --show-current)
if [[ "$branch" != "main" ]]; then
echo "You're in the \"${branch}\" branch, you need to switch to main"
exit 1
fi
major=v${BASH_REMATCH[1]}
minor=${major}.${BASH_REMATCH[2]}
patch=${minor}.${BASH_REMATCH[3]}
echo "HEAD is $(git log -1 --pretty="%h: %B")"
read -p "You are about to create the following tags: ${major}, ${minor} and ${patch}, continue? [y/n] " -r -n 1
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborting..."
exit 1
fi
echo "Creating tag ${major}"
git tag -f ${major}
echo "Creating tag ${minor}"
git tag -f ${minor}
echo "Creating tag ${patch}"
git tag -f ${patch}
read -p "Tags created, push? [y/n] " -r -n 1
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborting..."
exit 1
fi
git push
git push --tags -f