diff --git a/changelog.d/20241107_164816_kyle_tutor_version_parts.md b/changelog.d/20241107_164816_kyle_tutor_version_parts.md new file mode 100644 index 0000000000..10d6f22ca9 --- /dev/null +++ b/changelog.d/20241107_164816_kyle_tutor_version_parts.md @@ -0,0 +1 @@ +- [Feature] Add integer variables `TUTOR_VERSION_MAJOR`, `TUTOR_VERSION_MINOR`, and `TUTOR_VERSION_PATCH` to the template context. These are parsed from the existing `TUTOR_VERSION` string variable, which takes the format `"MAJOR.MINOR.PATCH"`. We add them as a convenience to developers who need to maintain version-agnostic Tutor plugins (by @michaelwheeler). diff --git a/tutor/env.py b/tutor/env.py index fef5f2cbed..75d1eac904 100644 --- a/tutor/env.py +++ b/tutor/env.py @@ -64,6 +64,9 @@ def _prepare_environment() -> None: ("HOST_USER_ID", utils.get_user_id()), ("TUTOR_APP", __app__.replace("-", "_")), ("TUTOR_VERSION", __version__), + ("TUTOR_VERSION_MAJOR", int(__version__.split('.')[0])), + ("TUTOR_VERSION_MINOR", int(__version__.split('.')[1])), + ("TUTOR_VERSION_PATCH", int(__version__.split('.')[2])), ("is_docker_rootless", utils.is_docker_rootless), ], )