|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 |
| -set -e |
| 3 | +set -eu -o pipefail |
4 | 4 |
|
5 |
| -VERSION=$(perl -MFile::Slurp::Tiny=read_file -MDateTime <<EOF |
6 |
| -use v5.16; |
7 |
| -my \$log = read_file(q{ChangeLog.md}); |
8 |
| -\$log =~ /\n(\d+\.\d+\.\d+) \((\d{4}-\d{2}-\d{2})\)\n/; |
9 |
| -die 'Release time is not today!' unless DateTime->now->ymd eq \$2; |
10 |
| -say \$1; |
11 |
| -EOF |
12 |
| -) |
| 5 | +changelog=$(cat ChangeLog.md) |
13 | 6 |
|
14 |
| -TAG="v$VERSION" |
| 7 | +regex=' |
| 8 | +([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\) |
| 9 | +-* |
15 | 10 |
|
16 |
| -git pull |
| 11 | +((.| |
| 12 | +)*) |
| 13 | +' |
| 14 | + |
| 15 | +if [[ ! $changelog =~ $regex ]]; then |
| 16 | + echo "Could not find date line in change log!" |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +version="${BASH_REMATCH[1]}" |
| 21 | +date="${BASH_REMATCH[2]}" |
| 22 | +notes="$(echo "${BASH_REMATCH[3]}" | sed -n -e '/^[0-9]\+\.[0-9]\+\.[0-9]\+/,$!p')" |
| 23 | +dist="geoipupdate-$version.tar.gz" |
| 24 | + |
| 25 | +if [[ "$date" != $(date +"%Y-%m-%d") ]]; then |
| 26 | + echo "$date is not today!" |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +tag="v$version" |
17 | 31 |
|
18 | 32 | if [ -n "$(git status --porcelain)" ]; then
|
19 | 33 | echo ". is not clean." >&2
|
20 | 34 | exit 1
|
21 | 35 | fi
|
22 | 36 |
|
23 |
| -export VERSION |
24 |
| -perl -pi -e "s/(?<=^AC_INIT\(\[geoipupdate\], \[).+?(?=\])/$VERSION/g" configure.ac |
| 37 | +git pull |
| 38 | + |
| 39 | +perl -pi -e "s/(?<=^AC_INIT\(\[geoipupdate\], \[).+?(?=\])/$version/g" configure.ac |
25 | 40 |
|
26 | 41 | ./bootstrap
|
27 | 42 | ./configure
|
28 | 43 | make clean
|
29 | 44 | make dist
|
30 | 45 |
|
| 46 | +echo "Diff:" |
| 47 | + |
31 | 48 | git diff
|
32 | 49 |
|
33 |
| -read -e -p "Push to origin? " SHOULD_PUSH |
| 50 | +echo "Release notes:" |
| 51 | +echo "$notes" |
| 52 | + |
| 53 | +read -e -r -p "Push to origin? " SHOULD_PUSH |
34 | 54 |
|
35 | 55 | if [ "$SHOULD_PUSH" != "y" ]; then
|
36 | 56 | echo "Aborting"
|
37 | 57 | exit 1
|
38 | 58 | fi
|
39 | 59 |
|
40 |
| -git commit -m "Update version number for $TAG" -a |
| 60 | +git commit -m "Bump version to $version" -a |
41 | 61 |
|
42 |
| -git tag -a "$TAG" |
43 | 62 | git push
|
44 |
| -git push --tags |
| 63 | + |
| 64 | +message="$version |
| 65 | +
|
| 66 | +$notes" |
| 67 | + |
| 68 | +hub release create -a "$dist" -m "$message" "$tag" |
45 | 69 |
|
46 | 70 | echo "Release to PPA and Homebrew"
|
0 commit comments