Skip to content

Commit cddc266

Browse files
authored
Replace old CI script (#79)
`get_current_api_spec_version` was a standalone script because it was used in multiple places. Move it into `update_api_spec_version.py` since now it's only used there.
1 parent 891e755 commit cddc266

File tree

3 files changed

+20
-56
lines changed

3 files changed

+20
-56
lines changed

.github/scripts/read_current_api_spec_version.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/scripts/test_read_current_api_spec_version.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/scripts/update_api_spec_version.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,30 @@
44
import re
55
import fileinput
66
import sys
7-
from read_current_api_spec_version import get_current_api_spec_version
87

98
VERSIONS_URL = "https://docs.gradle.com/enterprise/api-manual/"
109
LATEST_VERSION_REGEX = r'<a [^>]*href="ref/gradle-enterprise-([\d.]+)-api\.yaml">Specification</a>'
1110

1211

12+
def main(properties_file='gradle.properties'):
13+
current = get_current_api_spec_version(properties_file)
14+
latest = extract_latest_version()
15+
if current == latest:
16+
exit(1)
17+
update_version(properties_file, latest)
18+
print(latest)
19+
20+
21+
def get_current_api_spec_version(properties_file) -> str:
22+
with open(properties_file, mode='r') as file:
23+
for line in file.readlines():
24+
if '=' not in line:
25+
continue
26+
k, v = line.strip().split('=', maxsplit=2)
27+
if k == 'gradle.enterprise.version':
28+
return v
29+
30+
1331
def extract_latest_version():
1432
resp = requests.get(VERSIONS_URL)
1533
resp.raise_for_status()
@@ -28,14 +46,5 @@ def update_version(properties_file, new_version):
2846
sys.stdout.write(line)
2947

3048

31-
def main(properties_file):
32-
current = get_current_api_spec_version(properties_file)
33-
latest = extract_latest_version()
34-
if current == latest:
35-
exit(1)
36-
update_version(properties_file, latest)
37-
print(latest)
38-
39-
4049
if __name__ == '__main__':
41-
main(properties_file='gradle.properties')
50+
main()

0 commit comments

Comments
 (0)