...
1#!/usr/bin/env python3
2
3import fileinput
4import os.path
5import sys
6from os import getenv
7
8from lib import get_gh_repo, re_ga
9from lib.uiutil import run, run_txtcapture
10
11def main() -> int:
12 chart_version = getenv("CHART_VERSION")
13 if not (chart_version and chart_version.startswith("v") and re_ga.match(chart_version[1:])):
14 sys.stderr.write(f'Usage: CHART_VERSION=v7.Y.Z {os.path.basename(sys.argv[0])}\n')
15 return 2
16
17 content_gittag = f"chart/{chart_version}"
18
19 content_title = f"Emissary Ingress Chart {chart_version[1:]}"
20
21 content_body = f"""
22## :tada: Emissary Ingress Chart {chart_version[1:]} :tada:
23
24Upgrade Emissary - https://www.getambassador.io/reference/upgrading#helm.html
25View changelog - https://github.com/emissary-ingress/emissary/blob/master/charts/emissary-ingress/CHANGELOG.md
26
27---
28"""
29 in_changelog = False
30 for line in fileinput.FileInput("charts/emissary-ingress/CHANGELOG.md"):
31 if in_changelog:
32 if line.startswith("## v"):
33 break
34 content_body += line
35 if line == f"## {chart_version}\n":
36 in_changelog = True
37 content_body = content_body.strip()
38
39 run([
40 "gh", "release", "create",
41 "--repo="+get_gh_repo(),
42 "--title="+content_title,
43 "--notes="+content_body,
44 content_gittag])
45
46 url = run_txtcapture([
47 "gh", "release", "view",
48 "--json=url",
49 "--jq=.url",
50 "--repo="+get_gh_repo(),
51 content_gittag])
52 print(f'echo "url={url}" >> $GITHUB_OUTPUT')
53
54
55if __name__ == '__main__':
56 sys.exit(main())
View as plain text