generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_release-prod.sh
executable file
·56 lines (46 loc) · 1.78 KB
/
_release-prod.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
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
#### Goto repository root
cd "$(git rev-parse --show-toplevel)" >/dev/null
#### CHECK IF ON A HOTFIX BRANCH, EXTRACT BRANCH NAME
if [ -n "$(git branch --list hotfix/*)" ]; then
flow=hotfix
name=$(git branch --list hotfix/* | sed 's/.*hotfix\///')
npx --yes chalk-cli -t "{green ✔} Hotfix branch found: {yellow $name}"
fi
#### CHECK IF ON A RELEASE BRANCH, EXTRACT BRANCH NAME
if [ -n "$(git branch --list release/*)" ]; then
flow=release
name=$(git branch --list release/* | sed 's/.*release\///')
npx --yes chalk-cli -t "{green ✔} Release branch found: {blue $name}"
fi
#### CHECK IF A FLOW BRANCH IS FOUND
if [ -z "$flow" ] && [ -f .git/RELEASE ]; then
flow=release
name=$(cat .git/RELEASE)
npx --yes chalk-cli -t "{green ✔} Release branch found: {blue $name}"
git checkout $flow/$name
fi
#### EXIT IF NO FLOW BRANCH IS FOUND
if [ -z "$flow" ] || [ -z "$name" ]; then
npx --yes chalk-cli -t "{red ✘} No flow branch found"
exit 1
fi
#### GET BUMP VERSION
GBV=$(gitversion -config .gitversion -showvariable MajorMinorPatch)
npx --yes chalk-cli -t "{green ✔} Bump version: {green $GBV}"
#### PREVENT GIT EDITOR PROMPT
GIT_EDITOR=:
#### UPDATE VERSION & CHANGELOG & FINISH RELEASE
if npx --yes json --validate -q -f package.json && npx --yes commit-and-tag-version --skip.tag --no-verify --release-as $GBV; then
if git flow $flow finish $name --tagname $GBV --message $GBV --push; then
npx --yes chalk-cli -t "{green ✔} Release finished: {blue $name -> $GBV}"
rm -f .git/RELEASE
else
git undo
npx --yes chalk-cli -t "{red ✘} Cannot finish release. CHANGELOG & VERSION are not updated."
fi
else
npx --yes chalk-cli -t "{red ✘} Cannot update version & finish release"
fi
#### BACK
cd - >/dev/null