Skip to content

Commit 9ec93b4

Browse files
author
Vladimir Kotal
committed
add release script
1 parent b52a400 commit 9ec93b4

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,5 @@ The class home page is https://devnull-cz.github.io/unix-linux-prog-in-c/
1313
## Trigger new release
1414

1515
```
16-
# get the latest tag
17-
$ git tag | sed 's/^v//' | sort -n | tail -1
18-
# create new tag
19-
$ git tag v<XYZ>
20-
# push it to the repo
21-
$ git push origin v<XYZ>
16+
./dev/release.sh v<XYZ>
2217
```

dev/release.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
#
3+
# Trigger new release creation on Github.
4+
#
5+
6+
set -e
7+
8+
if (( $# > 1 )); then
9+
echo "usage: `basename $0` [version]"
10+
exit 1
11+
fi
12+
13+
# Get the latest version (needs curl + jq).
14+
if (( $# == 0 )); then
15+
curl -s https://api.github.com/repos/devnull-cz/unix-linux-prog-in-c/releases/latest | \
16+
jq .tag_name
17+
exit 0
18+
fi
19+
20+
VERSION=$1
21+
22+
if ! echo "$VERSION" | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' >/dev/null; then
23+
echo "version needs to be in the form of <num>.<num>.<num>"
24+
exit 1
25+
fi
26+
27+
ver=$( git tag -l "$VERSION" )
28+
if (( $? != 0 )); then
29+
echo "Cannot determine tag"
30+
exit 1
31+
fi
32+
if [[ $ver == $VERSION ]]; then
33+
echo "Tag $VERSION already exists"
34+
exit 1
35+
fi
36+
37+
git pull --ff-only
38+
git tag "$VERSION"
39+
git push origin tag "$VERSION"

0 commit comments

Comments
 (0)