Skip to content

Commit 3c699a3

Browse files
committed
update.py should print versions to build for build.sh
This resolves #167 (comment).
1 parent adcbdf5 commit 3c699a3

2 files changed

Lines changed: 30 additions & 34 deletions

File tree

build.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,29 @@
22

33
set -e
44

5+
IMAGE=wiktorn/overpass-api
6+
57
case "$1" in
68
"build")
7-
python update.py
9+
versions=$(python update.py)
810

9-
# docker build
10-
find . -maxdepth 1 -type d -name '0.*' -exec sh -c 'docker build -t wiktorn/overpass-api:$(basename "$1") -f "$1"/Dockerfile .' sh {} \;
11+
for version in $versions; do
12+
docker build --build-arg "OVERPASS_VERSION=${version}" -t "${IMAGE}:${version}" .
13+
done
1114

12-
# docker tag
13-
while IFS= read -r -d '' file; do
14-
docker tag "wiktorn/overpass-api:$(basename "$file")" wiktorn/overpass-api:latest
15-
done < <(find . -maxdepth 1 -type d -regex '\./[0-9]\.[0-9]\.[0-9]*' -print0 | sort -nz | tail -z -n 1)
15+
latest=$(echo "$versions" | sort -V | tail -n 1)
16+
docker tag "${IMAGE}:${latest}" "${IMAGE}:latest"
1617
;;
18+
1719
"push")
18-
# docker push
19-
find . -maxdepth 1 -type d -name '0.*' -exec sh -c 'docker push "wiktorn/overpass-api:$(basename "$1")"' sh {} \;
20-
docker push wiktorn/overpass-api:latest
20+
versions=$(python update.py)
21+
22+
for version in $versions; do
23+
docker push "${IMAGE}:${version}"
24+
done
25+
docker push "${IMAGE}:latest"
2126
;;
27+
2228
"$1")
2329
echo "Invalid argument $1"
2430
echo "Valid arguments:"

update.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import html.parser
2-
import os
3-
import pathlib
4-
import shutil
52
import urllib.request
63

74
url = "http://dev.overpass-api.de/releases/"
5+
skip_prefixes = (
6+
'0.6', 'eta', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.50', '0.7.52',
7+
'0.7.54.11', # invalid CRC in archive
8+
'0.7.51', # no autoconf
9+
)
810

911

1012
class VersionFinder(html.parser.HTMLParser):
@@ -23,31 +25,19 @@ def handle_starttag(self, tag, attrs):
2325
self.versions.append(version)
2426

2527

26-
def main():
28+
def versions_to_build():
2729
parser = VersionFinder()
2830
response = urllib.request.urlopen(url)
2931
data = response.read().decode(response.headers.get_content_charset())
3032
parser.feed(data)
31-
with open("Dockerfile") as f:
32-
template = f.read()
33-
for ver in parser.versions:
34-
if any((ver.startswith(x) for x in ('0.6', 'eta', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.50', '0.7.52',
35-
'0.7.54.11', # invalid CRC in archive
36-
'0.7.51', # no autoconf
37-
))) or \
38-
ver == '0.7':
39-
# ignore old releases
40-
continue
41-
if os.path.exists(ver):
42-
shutil.rmtree(ver)
43-
os.mkdir(ver)
44-
with open(pathlib.Path(ver) / "Dockerfile", "w+") as f:
45-
f.write(template.replace("${OVERPASS_VERSION}", ver))
46-
#for i in ("etc", "bin"):
47-
# shutil.copytree(i, pathlib.Path(ver) / i)
48-
#shutil.copyfile("docker-entrypoint.sh", pathlib.Path(ver) / "docker-entrypoint.sh")
49-
#shutil.copyfile("requirements.txt", pathlib.Path(ver) / "requirements.txt")
33+
34+
return [
35+
version for version in parser.versions
36+
if version != '0.7'
37+
and not any(version.startswith(skip_prefix) for skip_prefix in skip_prefixes)
38+
]
5039

5140

5241
if __name__ == '__main__':
53-
main()
42+
for version_to_build in versions_to_build():
43+
print(version_to_build)

0 commit comments

Comments
 (0)