~exprez135/taliaferro

ref: 8b6e0f7c019f532841af40b950c4048422232234 taliaferro/node_modules/lunr/build/release.sh -rwxr-xr-x 1.7 KiB
8b6e0f7c — Nate rebuilding site Sun Feb 9 13:47:19 CST 2020: Fix navbar symbols showing up first. 2 years ago
                                                                                
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
#!/usr/bin/env bash

file_has_changed () {
  if [ ! -f $1 ]; then
    return 1
  fi

  for f in `git ls-files --modified`; do
    [[ "$f" == "$1" ]] && return 0
  done

  return 1
}

version_is_unique () {
  for v in `git tag -l`; do
    [[ "$v" == "v$1" ]] && return 1
  done

  return 0
}

on_master_branch () {
  [[ $(git symbolic-ref --short -q HEAD) == "master" ]] && return 0
  return 1
}

version=$(cat VERSION)
previous_version=$(git describe --abbrev=0)

if ! on_master_branch; then
  echo -e "\033[0;31mRefusing to release from non master branch.\033[0m"
  exit 1
fi

if ! file_has_changed "VERSION"; then
  echo -e "\033[0;31mRefusing to release because VERSION has not changed.\033[0m"
  exit 1
fi

if ! file_has_changed "CHANGELOG.md"; then
  echo -e "\033[0;31mRefusing to release because CHANGELOG.md has not been updated.\033[0m"
  exit 1
fi

if ! file_has_changed "package.json"; then
  echo -e "\033[0;31mRefusing to release because package.json has not been updated.\033[0m"
  exit 1
fi

if ! version_is_unique $version; then
  echo -e "\033[0;31mRefusing to release because VERSION is not unique.\033[0m"
  exit 1
fi

echo -e "\033[1mAbout to release v$version with the following changes:\033[0m"
git log --date=short --pretty=format:"%ad %h%x09%an%x09%s" $previous_version..HEAD

echo

echo -e "\033[1mThe following files will be part of the release commit:\033[0m"
git ls-files --modified

echo

read -e -p "Are you sure you want to release? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
  echo -e "\033[0;32mReleasing...\033[0m"
  echo
  git commit -a -m "Build version $version"
  git tag -a v$version -m "Version $version"
  git push origin master
  git push --tags

  npm publish
else
  echo -e "\033[0;31mCancelling...\033[0m"
fi