-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbump_versions.py
47 lines (37 loc) · 1.17 KB
/
bump_versions.py
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
import oyaml
import sys
import io
IMAGE_BASENAME = 'ghcr.io/psu-oit-arc/oregoninvasiveshotline'
ENVIRONMENTS = ['cloud']
CONFIGS = [
'docker-compose.{}.yml',
'{}.yml',
'{}-bootstrap.yml'
]
def update_config(config, env, version):
path = config.format(env)
updated = False
obj = None
with io.open(path, 'r') as f:
obj = oyaml.safe_load(f)
if 'services' not in obj:
print("No services listed in '{}'".format(path))
return
for _, service in obj['services'].items():
for k, v in service.items():
if k == 'image' and v.startswith(IMAGE_BASENAME):
service['image'] = ':'.join([v.split(':')[0], version])
updated = True
if not updated:
print("No service images modified.")
return
with io.open(path, 'w') as f:
oyaml.safe_dump(obj, stream=f)
if __name__ == '__main__':
if len(sys.argv) != 1:
print("Usage: bump_version.py")
sys.exit(1)
from oregoninvasiveshotline import __version__
for env in ENVIRONMENTS:
for config in CONFIGS:
update_config(config, env, __version__)