forked from influxdata/flux-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·81 lines (68 loc) · 2.52 KB
/
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
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
#!/bin/bash
# This script will check the state of the main branch of flux-lsp for
# conditions that would allow for a release to occur. If those conditions
# are met, a signed tag is created and *pushed to github* where the CI
# will take over and publish the extension.
#
# WARNING: This script will *push directly to master*. Please make sure
# you understand the contents of this script and the consequences of its
# execution before running it.
set -e
if [[ "${DEBUG:-0}" == "1" ]]; then
set -x
fi
# Controls how the version is bumped.
# Set INCREMENT to one of: major, minor or patch
# Defaults to patch if unset.
INCREMENT=${INCREMENT:-patch}
if [[ ! $INCREMENT =~ (patch)|(minor)|(major) ]]
then
echo "Increment must be one of major, minor or patch"
exit 1
fi
if [[ ! $(command -v hub) ]]; then
echo "Please install the hub tool and re-run."
exit 1
fi
if [[ ! -f $HOME/.config/hub && "${GITHUB_TOKEN}" == "" ]]; then
echo "Please authenticate your hub command. See https://github.com/github/hub/issues/2655#issuecomment-735836048"
exit 1
fi
if [[ ! $(cargo bump -v) ]]; then
echo "Please install cargo bump and re-run: `cargo install cargo-bump`"
exit 1
fi
TEMPDIR=$(mktemp -d -t flux-release.XXXX)
echo "Using fresh install in $TEMPDIR"
cd $TEMPDIR
if [[ $(ssh -T [email protected] 2>&1 > /dev/null) ]]; then
git clone [email protected]:influxdata/flux-lsp.git > /dev/null 2>&1
else
git clone https://github.com/influxdata/flux-lsp.git > /dev/null 2>&1
fi
cd $TEMPDIR/flux-lsp
if [[ ! $(hub ci-status HEAD) ]]; then
echo "Build status on master is either incomplete or failing. Please try ag ain after build status is complete."
exit 1
fi
# Bump version
cargo bump $INCREMENT
cargo check
new_version=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
# Commit and tag release
git add Cargo.toml
git add Cargo.lock
git commit -m "release: $new_version"
# Note: Using an annotated tag (-a) is important so that we can reliably find
# the previous version tag.
git tag -a -m "$new_version" "$new_version"
git push
previous_version=`git tag --sort=-creatordate | sed -n '2 p'`
# The tail step here ignores the commit that is the release, so we don't have a changelog that also
# contains, e.g. "release: 0.10.55". We already know it's a release, that's why we're constructing release
# notes.
commits=`git log --pretty=oneline ${previous_version}..${new_version} | tail -n +2 | awk '{$1="-"; print }'`
hub release create $new_version -m "Release $new_version
${commits}"
echo "$new_version tagged and released"
rm -rf $TEMPDIR