Skip to content

Commit

Permalink
Change release script to update versions in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
martinburchell committed Jun 13, 2023
1 parent 4d9d7f3 commit 8760a61
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tools/release_new_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
DOCS_DIR = os.path.join(PROJECT_ROOT, "docs")
REBUILD_DOCS = os.path.join(DOCS_DIR, "rebuild_docs.py")
DOCS_SOURCE_DIR = os.path.join(DOCS_DIR, "source")
APACHE_CONFIG_FILE = os.path.join(
DOCS_SOURCE_DIR, "administrator", "_demo_apache_config.conf"
)
CPP_SOURCE_DIR = os.path.join(PROJECT_ROOT, "tablet_qt")
SERVER_SOURCE_DIR = os.path.join(PROJECT_ROOT, "server")
SERVER_TOOLS_DIR = os.path.join(SERVER_SOURCE_DIR, "tools")
Expand Down Expand Up @@ -144,6 +147,11 @@ class VersionReleaser:
r"\g<1>{major}\g<3>{minor}\g<5>{patch}\g<7>{extra}\g<9>"
)

apache_config_version_search = (
# ( 1 )( 2 )( 3)( 4 )( 5)( 6 )( 7)
r"(^# Created by CamCOPS version )(\d+)(\.)(\d+)(\.)(\d+)(\.)"
)

def __init__(
self,
new_client_version: Version,
Expand Down Expand Up @@ -688,7 +696,7 @@ def perform_checks(self) -> None:
self.check_ios_version()

if len(self.errors) == 0:
self.rebuild_docs()
self.check_docs()

self.check_uncommitted_changes()
self.check_unpushed_changes()
Expand All @@ -697,6 +705,23 @@ def perform_checks(self) -> None:
self.check_package_installed("wheel")
self.check_package_installed("twine")

def check_docs(self) -> None:
# The GitHub docs workflow will do a more thorough check. This
# will hopefully be enough.
if self.get_apache_config_file_version() != self.new_server_version:
self.rebuild_docs()

def get_apache_config_file_version(self) -> Version:
with open(APACHE_CONFIG_FILE, "r") as f:
for line in f.readlines():
m = re.match(self.apache_config_version_search, line)
if m is not None:
return Version(
major=int(m.group(2)),
minor=int(m.group(4)),
patch=int(m.group(6)),
)

def rebuild_docs(self) -> None:
self.run_with_check([REBUILD_DOCS])

Expand Down Expand Up @@ -803,6 +828,10 @@ def main() -> None:
log.error("release_new_version.py must be run inside virtualenv")
sys.exit(EXIT_FAILURE)

if sys.version_info < (3, 10):
log.error("You must run this script with Python 3.10 or later")
sys.exit(EXIT_FAILURE)

parser = argparse.ArgumentParser(
description="Release CamCOPS to various places",
formatter_class=ArgumentDefaultsRichHelpFormatter,
Expand Down

0 comments on commit 8760a61

Please sign in to comment.