You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
import urllib.request
|
|
import subprocess
|
|
import json
|
|
import yaml
|
|
|
|
def is_release_candidate(version):
|
|
return '-rc' in version
|
|
|
|
# print the latest tags so we don't have to google our own
|
|
# image to check :P
|
|
r = urllib.request.urlopen('https://registry.hub.docker.com/v2/repositories/place1/wg-access-server/tags?page_size=10') \
|
|
.read() \
|
|
.decode('utf-8')
|
|
tags = json.loads(r).get('results', [])
|
|
print('current docker tags:', sorted([t.get('name') for t in tags], reverse=True))
|
|
|
|
# tag the new image
|
|
version = input('Version: ')
|
|
docker_tag = f"place1/wg-access-server:{version}"
|
|
subprocess.run(['docker', 'build', '-t', docker_tag, '.'])
|
|
|
|
# update the helm chart and quickstart manifest
|
|
if not is_release_candidate(version):
|
|
with open('deploy/helm/wg-access-server/Chart.yaml', 'r+') as f:
|
|
chart = yaml.load(f)
|
|
chart['version'] = version
|
|
chart['appVersion'] = version
|
|
f.seek(0)
|
|
yaml.dump(chart, f, default_flow_style=False)
|
|
f.truncate()
|
|
with open('deploy/k8s/quickstart.yaml', 'w') as f:
|
|
subprocess.run(['helm', 'template', '--name-template',
|
|
'quickstart', 'deploy/helm/wg-access-server/'], stdout=f)
|
|
subprocess.run(['helm', 'package', 'deploy/helm/wg-access-server/',
|
|
'--destination', 'docs/charts/'])
|
|
subprocess.run(['helm', 'repo', 'index', 'docs/', '--url',
|
|
'https://place1.github.io/wg-access-server'])
|
|
|
|
# commit changes
|
|
if not is_release_candidate(version):
|
|
subprocess.run(['git', 'add', 'deploy'])
|
|
|
|
# tag the current commit
|
|
if not is_release_candidate(version):
|
|
subprocess.run(['git', 'tag', '-a', f'v{version}', '-m', f'v{version}'])
|
|
|
|
# push everything
|
|
subprocess.run(['git', 'push'])
|
|
subprocess.run(['git', 'push', '--tags'])
|
|
subprocess.run(['docker', 'push', docker_tag])
|