-
Notifications
You must be signed in to change notification settings - Fork 286
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·167 lines (121 loc) · 3.64 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·167 lines (121 loc) · 3.64 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash
set -eu -o pipefail
# Check that we're not on the main branch
current_branch=$(git branch --show-current)
if [ "$current_branch" = "main" ]; then
echo "Error: Releases should not be done directly on the main branch."
echo "Please create a release branch and run this script from there."
exit 1
fi
phar='geoip2.phar'
changelog=$(cat CHANGELOG.md)
regex='
([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
-*
((.|
)*)
'
if [[ ! $changelog =~ $regex ]]; then
echo "Could not find date line in change log!"
exit 1
fi
version="${BASH_REMATCH[1]}"
date="${BASH_REMATCH[2]}"
notes="$(echo "${BASH_REMATCH[3]}" | sed -n -e '/^[0-9]\+\.[0-9]\+\.[0-9]\+/,$!p')"
if [[ "$date" != $(date +"%Y-%m-%d") ]]; then
echo "$date is not today!"
exit 1
fi
tag="v$version"
rm -f "$phar"
if [ -n "$(git status --porcelain)" ]; then
echo ". is not clean." >&2
exit 1
fi
rm -fr vendor
php composer.phar self-update
php composer.phar update --no-dev
perl -pi -e "s/(?<=const VERSION = ').+?(?=';)/$tag/g" src/WebService/Client.php
perl -pi -e "s{(?<=php composer\.phar require geoip2/geoip2:).+}{^$version}g" README.md
box_phar_hash='f98cf885a7c07c84df66e33888f1d93f063298598e0a5f41ca322aeb9683179b box.phar'
if ! echo "$box_phar_hash" | sha256sum -c; then
wget -O box.phar "https://github.com/box-project/box/releases/download/4.6.10/box.phar"
fi
echo "$box_phar_hash" | sha256sum -c
php box.phar compile
phar_test=$(./dev-bin/phar-test.php)
if [[ -n $phar_test ]]; then
echo "Phar test outputed non-empty string: $phar_test"
exit 1
fi
# Download test deps
php composer.phar update
./vendor/bin/phpunit
if [ ! -d .gh-pages ]; then
echo "Checking out gh-pages in .gh-pages"
git clone -b gh-pages git@github.com:maxmind/GeoIP2-php.git .gh-pages
pushd .gh-pages
else
echo "Updating .gh-pages"
pushd .gh-pages
git pull
fi
if [ ! -d .maxminddb ]; then
echo "Cloning MaxMind-DB for docs"
git clone git@github.com:maxmind/MaxMind-DB-Reader-php.git .maxminddb
else
echo "Updating MaxMind-DB for docs"
pushd .maxminddb
git pull
popd
fi
if [ -n "$(git status --porcelain)" ]; then
echo ".gh-pages is not clean" >&2
exit 1
fi
# Using Composer is possible, but they don't recommend it.
phpdocumentor_phar_hash='aa00973d88b278fe59fd8dce826d8d5419df589cb7563ac379856ec305d6b938 phpDocumentor.phar'
if ! echo "$phpdocumentor_phar_hash" | sha256sum -c; then
wget -O phpDocumentor.phar https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.8.1/phpDocumentor.phar
fi
echo "$phpdocumentor_phar_hash" | sha256sum -c
# Use cache dir in /tmp as otherwise cache files get into the output directory.
cachedir="/tmp/phpdoc-$$-$RANDOM"
rm -rf "$cachedir"
php phpDocumentor.phar \
--visibility=public \
--cache-folder="$cachedir" \
--title="GeoIP2 PHP API $tag" \
run \
-d "$PWD/../src" \
-t "doc/$tag"
# This used to work but doesn't as of 4.5.1. They say that they are working
# on fixing it. Neither the config file nor the relative path fix work as
# suggested either.
# -d "$PWD/.maxminddb/src" \
rm -rf "$cachedir"
page=index.md
cat <<EOF > $page
---
layout: default
title: MaxMind GeoIP2 PHP API
language: php
version: $tag
---
EOF
cat ../README.md >> $page
git add doc/
echo "Release notes for $tag:"
echo "$notes"
read -e -p "Commit changes and push to origin? " should_push
if [ "$should_push" != "y" ]; then
echo "Aborting"
exit 1
fi
git commit -m "Updated for $tag" -a
git push
popd
git commit -m "Update for $tag" -a
git push
gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$tag" "$phar"
git push --tags