-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease
executable file
·86 lines (66 loc) · 1.81 KB
/
release
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
#!/bin/bash
# This script creates and pushes a release
# It takes one parameter: the version number of the release
# The current version number is in ih-core/bin/VERSION
# This command will fail if the repo is dirty, or if the release already exists.
# It will cause a commit with the new version updates
THIS_DIR=$(dirname "$(realpath "$0")")
ROOT_DIR=$(dirname "$THIS_DIR")
function usage() {
cat <<USAGE
release
Publishes a release. Must be run on the master branch,
unless the '-p' flag is set.
Flags
-p Create a pre-release version
USAGE
exit 1
}
PRERELEASE=""
while getopts "p" arg; do
case $arg in
p) PRERELEASE="-p" ;;
*)
ih::help
exit 1
;;
esac
done
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $BRANCH != "master" && -z $PRERELEASE ]]; then
usage
fi
if [[ $(git status --short) != '' ]]; then
echo 'Working directory is dirty, are you missing something?'
exit 1
fi
VERSION=$(cat "$ROOT_DIR/VERSION")
if gh release list | cut -f1 | grep -q "$VERSION"; then
echo "A release already exists for version $VERSION"
exit 0
fi
echo "Creating a release for version $VERSION"
# We want to abort if any of the following commands fail
set -e
git pull
if [[ $(git tag --list) =~ ^$VERSION$ ]]; then
echo "Tag for $VERSION already exists..."
if [[ $(git rev-parse "$VERSION") == $(git rev-parse HEAD) ]]; then
echo "Tag for $VERSION already points to HEAD, not re-tagging."
else
echo "Tag for $VERSION points to something other than HEAD, create a new version using the ./meta/bump script."
return 1
fi
else
git tag -a "$VERSION" -m "Release version $VERSION"
git push --tags
fi
gh release create \
"$VERSION" \
$PRERELEASE \
-t "$VERSION" \
--notes "Release version $VERSION" \
--target "$BRANCH" \
./bootstrap \
./formula/ih-core.rb
set +e