|
23 | 23 | sys.exit("Version must be formatted like so <major>.<minor>") |
24 | 24 |
|
25 | 25 | target_version = f"{args.version}" # e.g., "2.20" - the target release version |
26 | | - major, minor = args.version.split(".") |
27 | 26 |
|
28 | 27 | target_unstable = f"{target_version}-unstable" # e.g., "2.20-unstable" |
29 | | - previous_stable = f"{major}.{int(minor) - 1}" # e.g., "2.19" - previous stable release |
30 | 28 |
|
31 | 29 | versions = [ |
32 | 30 | folder.replace("version-", "") |
|
83 | 81 | with open("docs-website/reference_versions.json", "w") as f: |
84 | 82 | json.dump(reference_versions_list, f) |
85 | 83 |
|
86 | | - # in docusaurus.config.js, replace previous stable version with the target version |
| 84 | + # in docusaurus.config.js, replace the current stable version (lastVersion) with the target version |
87 | 85 | with open("docs-website/docusaurus.config.js") as f: |
88 | 86 | config = f.read() |
| 87 | + last_version_matches = set(re.findall(r"lastVersion: '([^']+)'", config)) |
| 88 | + if not last_version_matches: |
| 89 | + sys.exit("Could not find any lastVersion entry in docusaurus.config.js") |
| 90 | + if len(last_version_matches) > 1: |
| 91 | + sys.exit(f"Found inconsistent lastVersion entries in docusaurus.config.js: {last_version_matches}") |
| 92 | + previous_stable = last_version_matches.pop() # e.g., "2.19" - previous stable release |
89 | 93 | config = config.replace(f"lastVersion: '{previous_stable}'", f"lastVersion: '{target_version}'") # "2.19" -> "2.20" |
90 | 94 | with open("docs-website/docusaurus.config.js", "w") as f: |
91 | 95 | f.write(config) |
|
0 commit comments