Skip to content

Commit 69e5579

Browse files
authored
Add release script (#19)
1 parent d0467f3 commit 69e5579

File tree

2 files changed

+80
-8
lines changed

2 files changed

+80
-8
lines changed

.buildkite/check-latest-tag.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,10 @@ cd "$(dirname "${BASH_SOURCE[0]}")"/..
1313
get_latest() {
1414
git fetch --tags
1515

16-
git tag |
16+
git describe --tags --abbrev=0 |
1717
# drop `v` prefix
18-
grep "^v" |
1918
cut -c2- |
2019

21-
# sort by semantic version
22-
sort -t "." -k1,1n -k2,2n -k3,3n |
23-
24-
# last
25-
tail -n 1 |
26-
2720
# drop newline
2821
tr -d '\n'
2922
}

release.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "${BASH_SOURCE[0]}")"
6+
7+
get_latest() {
8+
git fetch
9+
10+
git tag |
11+
# drop `v` prefix
12+
grep "^v" |
13+
cut -c2- |
14+
15+
# sort by semantic version
16+
sort -t "." -k1,1n -k2,2n -k3,3n |
17+
18+
# last
19+
tail -n 1 |
20+
21+
# drop newline
22+
tr -d '\n'
23+
}
24+
25+
NEW="$1"
26+
27+
if [ -z "$NEW" ]; then
28+
echo "Usage : bash release.sh <version>"
29+
echo "Example: bash release.sh 1.2.3"
30+
echo ""
31+
echo "Fetching tags..."
32+
latest="$(get_latest)"
33+
echo -n "The current version is: $latest"
34+
35+
exit 1
36+
fi
37+
38+
if [[ "$NEW" == v* ]]; then
39+
echo "<version> must not start with \"v\""
40+
exit 1
41+
fi
42+
43+
echo "Checking for clean working tree..."
44+
if [[ "$(git diff --stat)" != "" ]]; then
45+
echo "❌ Dirty working tree (try git stash)"
46+
exit 1
47+
fi
48+
49+
echo "Checking that we're on master..."
50+
if [[ "$(git symbolic-ref HEAD | tr -d '\n')" != "refs/heads/master" ]]; then
51+
echo "❌ Not on master (try git checkout master)"
52+
exit 1
53+
fi
54+
55+
echo "Checking that master is up to date..."
56+
git fetch
57+
if [[ "$(git rev-parse master)" != "$(git rev-parse origin/master)" ]]; then
58+
echo "❌ master is out of sync with origin/master (try git pull)"
59+
exit 1
60+
fi
61+
62+
git ls-tree -r HEAD --name-only -z examples | xargs -0 sed -i.sedbak "s/\"[0-9]*\.[0-9]*\.[0-9]*\" # LATEST/\"$NEW\" # LATEST/g"
63+
find . -name "*.sedbak" -print0 | xargs -0 rm
64+
65+
git commit --all --message "release $NEW"
66+
git tag "v$NEW"
67+
git push --tags
68+
git push
69+
70+
echo ""
71+
echo "✅ Released $NEW"
72+
echo ""
73+
echo "- Tags : https://github.com/sourcegraph/terraform-aws-executors/tags"
74+
echo "- Commits: https://github.com/sourcegraph/terraform-aws-executors/commits/master"
75+
echo ""
76+
echo "Make sure CI goes green 🟢:"
77+
echo ""
78+
echo "- https://buildkite.com/sourcegraph/terraform-aws-executors/builds?branch=master"
79+
echo "- https://buildkite.com/sourcegraph/terraform-aws-executors/builds?branch=v$NEW"

0 commit comments

Comments
 (0)