Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/templates/yearly-releases.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
# TITLE-MARKER
title: "0000 Releases"
date: last-modified
categories: ["releases by year"]
# REMOVE THIS `FALSE` FLAG AFTER YEARLY RELEASES HAVE ALL BEEN GATHERED ONTO THIS LANDING
search: false
listing:
# LISTING-MARKER
- id: 0000-releases
type: grid
max-description-length: 250
sort: false
fields: [title, description]
sort: "date desc"
fields: [title, subtitle, description]
contents:
# RELEASE-FILES-MARKER
- ./**/**.qmd
---

<!-- EMBED-MARKER -->
Expand Down
29 changes: 25 additions & 4 deletions release-scripts/generate-release-notes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
" - [Create categories from labels](#toc2_3_) \n",
" - [Collect GitHub URLs](#toc2_4_) \n",
" - [Set the release date](#toc2_5_) \n",
" - [Define the unified version](#toc2_6_) \n",
"- [Extracting PR information](#toc3_) \n",
" - [Create release folder and file](#toc3_1_) \n",
" - [Add the date to release notes ](#toc3_2_) \n",
Expand Down Expand Up @@ -205,6 +206,26 @@
"gro.original_release_date = gro.release_datetime.strftime(\"%B %-d, %Y\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id='toc2_6_'></a>\n",
"\n",
"### Define the unified version\n",
"\n",
"This cell will prompt you to enter the unified ValidMind version here associated with the release in accordance with our [customer-managed release versioning conventions](https://github.com/validmind/installation/blob/main/site/installation/Customer-managed-releases.qmd), for example `25.03.06`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"unified_version = f\"Unified version `{gro.input_version()}`\""
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -243,7 +264,7 @@
"<a id='toc3_2_'></a>\n",
"\n",
"### Add the date to release notes \n",
"This block writes the specified date as the title of the new release notes file.\n",
"This block writes the specified date as the title (for display) and date (for listing sorting) of the new release notes file.\n",
"\n",
"**It will also open up the newly created `release-notes.qmd` file for you so you don't have to go looking for it.**"
]
Expand All @@ -254,7 +275,7 @@
"metadata": {},
"outputs": [],
"source": [
"gro.create_release_qmd(output_file, gro.original_release_date)"
"gro.create_release_qmd(output_file, gro.original_release_date, gro.release_datetime.strftime(\"%Y-%m-%d\"), unified_version)"
]
},
{
Expand Down Expand Up @@ -558,7 +579,7 @@
"<a id='toc5_2_'></a>\n",
"\n",
"### Update sidebar \n",
"This block will go into our `_quarto.yml` file and add the new release notes so it shows up on the sidebar of the docsite under the \"About\" section. "
"This block will go into our releases `_sidebar.yaml` file and add the new release notes so it shows up on the sidenav of the docsite under the \"Releases\" section. "
]
},
{
Expand All @@ -567,7 +588,7 @@
"metadata": {},
"outputs": [],
"source": [
"gro.update_quarto_yaml(gro.release_datetime, year)"
"gro.update_release_sidebar(gro.release_datetime, year)"
]
},
{
Expand Down
114 changes: 100 additions & 14 deletions release-scripts/generate_release_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,27 @@ def get_release_date():
print("Invalid date format, please try again using the format Month Day, Year (e.g., January 1, 2020)")
return get_release_date()


unified_version = ""

def input_version():
"""Prompts the user to enter a version number in one of the formats:
00.00.00, 00.00.0, or 00.00

Returns:
str: The validated version string.
"""
import re
version_pattern = re.compile(r"^\d{2}\.\d{2}(\.\d{1,2})?$")

while True:
version_input = input("Enter the version number (format: 00.00.00, 00.00.0, or 00.00): ")
if version_pattern.match(version_input):
print(f"Unified version: {version_input}\n")
return version_input
else:
print("Invalid version format. Please use one of the following: 00.00.00, 00.00.0, or 00.00")

def create_release_folder(formatted_release_date):
"""
Creates a directory for the release notes based on the provided release date
Expand Down Expand Up @@ -462,18 +483,26 @@ def create_release_folder(formatted_release_date):

return output_file, year

def create_release_qmd(output_file, original_release_date):
def create_release_qmd(output_file, original_release_date, release_date_iso, unified_version):
"""
Writes metadata to a file with a title set to the original release date.
Writes metadata to a file with a title set to the original release date,
and includes the release date in ISO format as the date field.

Args:
output_file (str): The path to the file to write.
original_release_date (str): The title to include in the metadata.
release_date_iso (str): The date in YYYY-MM-DD format for metadata.
"""

print(f"{original_release_date} added to {output_file} as title")
print(f"- {original_release_date} added to {output_file} as title")
print(f" {release_date_iso} added to {output_file} as date")
print(f" {unified_version} added to {output_file} as subtitle")
with open(output_file, "w") as file:
file.write(f"---\ntitle: \"{original_release_date}\"\n---\n\n")
file.write(f"---\n")
file.write(f"title: \"{original_release_date}\"\n")
file.write(f"date: {release_date_iso}\n")
file.write(f"subtitle: \"{unified_version}\"\n")
file.write(f"---\n\n")

try:
subprocess.run(["code", output_file], check=True)
Expand Down Expand Up @@ -733,16 +762,65 @@ def upgrade_info(output_file):
except Exception as e:
print(f"Failed to include _how-to-upgrade.qmd to {output_file}: {e}")

def update_quarto_yaml(release_date, year):
"""Updates the _quarto.yml file to include the release notes file so it can be accessed on the website.
# def update_quarto_yaml(release_date, year):
# """Updates the _quarto.yml file to include the release notes file so it can be accessed on the website.

# Params:
# release_date - release notes use the release date as the file name.

# Modifies:
# _quarto.yml file
# """
# yaml_filename = "../site/_quarto.yml"

# # Format the release date for insertion into the YAML file
# formatted_release_date = release_date.strftime("%Y-%b-%d").lower()
# target_line = f' - releases/{year}/{formatted_release_date}/release-notes.qmd\n'

# # Check if the target line already exists in the YAML file
# with open(yaml_filename, 'r') as file:
# if target_line in file.readlines():
# print(f"Release notes for {formatted_release_date} already exist in {yaml_filename}, skipping update")
# return

# temp_yaml_filename = "../site/_quarto_temp.yml"

# # Copy the original YAML file to a temporary file
# shutil.copyfile(yaml_filename, temp_yaml_filename)

# with open(temp_yaml_filename, 'r') as file:
# lines = file.readlines()

# with open(yaml_filename, 'w') as file:
# add_release_content = False
# insert_index = -1

# for i, line in enumerate(lines):
# file.write(line)
# if line.strip() == "# MAKE-RELEASE-NOTES-EMBED-MARKER":
# add_release_content = True
# insert_index = i

# if add_release_content and i == insert_index:
# file.write(target_line)
# add_release_content = False

# # Remove the temporary file
# os.remove(temp_yaml_filename)

# print(f"Added new release notes to _quarto.yml, line {insert_index + 2}")

def update_release_sidebar(release_date, year):
"""Updates the releases _sidebar.yaml file to include the new yearly release folder.

Params:
release_date - release notes use the release date as the file name.
year - the year to be used for the folder.

Modifies:
_quarto.yml file
~/site/releases/_sidebar.yaml file
"""
yaml_filename = "../site/_quarto.yml"
yaml_filename = "../site/releases/_sidebar.yaml"
temp_yaml_filename = "../site/releases/_sidebar_temp.yaml"

# Format the release date for insertion into the YAML file
formatted_release_date = release_date.strftime("%Y-%b-%d").lower()
Expand All @@ -754,8 +832,6 @@ def update_quarto_yaml(release_date, year):
print(f"Release notes for {formatted_release_date} already exist in {yaml_filename}, skipping update")
return

temp_yaml_filename = "../site/_quarto_temp.yml"

# Copy the original YAML file to a temporary file
shutil.copyfile(yaml_filename, temp_yaml_filename)

Expand All @@ -779,7 +855,7 @@ def update_quarto_yaml(release_date, year):
# Remove the temporary file
os.remove(temp_yaml_filename)

print(f"Added new release notes to _quarto.yml, line {insert_index + 2}")
print(f"Added new release notes to releases _sidebar.yaml, line {insert_index + 2}")

def update_index_qmd(release_date, year):
"""Updates the index.qmd file to include the new releases in `Latest Releases` and removes the oldest release from the list.
Expand Down Expand Up @@ -897,8 +973,11 @@ def main():
Calls all the same functions as the generate-release-notes.ipynb when you run make release-notes.
"""
try:
from dotenv import load_dotenv

env_location = get_env_location()
setup_openai_api(env_location)
load_dotenv(dotenv_path=env_location)
print()

label_hierarchy = ["highlight", "enhancement", "breaking-change", "deprecation", "bug", "documentation"]
Expand All @@ -916,13 +995,17 @@ def main():
original_release_date = release_datetime.strftime("%B %-d, %Y")
print()

unified_version = ""
# Declare and initialize unified_version so it's available globally
unified_version = f"Unified version `{input_version()}`"

# Handle potential failure in create_release_folder
output_file, year = create_release_folder(formatted_release_date)
if not output_file: # Ensure the function returns something valid
raise RuntimeError("Failed to create release folder.")
print()

create_release_qmd(output_file, original_release_date)
create_release_qmd(output_file, original_release_date, release_datetime.strftime("%Y-%m-%d"), unified_version)
print()

update_release_components(release_components, categories)
Expand Down Expand Up @@ -971,7 +1054,10 @@ def main():
upgrade_info(output_file)
print()

update_quarto_yaml(release_datetime, year)
# update_quarto_yaml(release_datetime, year)
# print()

update_release_sidebar(release_datetime, year)
print()

update_index_qmd(release_datetime, year)
Expand Down
47 changes: 2 additions & 45 deletions release-scripts/year-end-cleanup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
" - [Retrieve the yearly folder](#toc3_1_) \n",
" - [Create yearly listing page](#toc3_2_) \n",
" - [Edit the yearly listing page](#toc3_3_) \n",
" - [Retrieve yearly release pages](#toc3_4_) \n",
" - [Add releases to yearly listing page](#toc3_5_) \n",
"- [Updating sidebar and links](#toc4_) \n",
" - [Add yearly release folder to sidebar](#toc4_1_) \n",
" - [Move year end marker](#toc4_2_) \n",
Expand Down Expand Up @@ -221,47 +219,6 @@
" yc.update_template(yearly_release, year)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id='toc3_4_'></a>\n",
"\n",
"### Retrieve yearly release pages\n",
"\n",
"This cell returns the `release-notes.qmd` filepaths for all the release folders in our matching yearly subdirectory."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"release_listings = yc.get_release_listings(yearly_path)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id='toc3_5_'></a>\n",
"\n",
"### Add releases to yearly listing page \n",
"\n",
"Next, we'll insert that year's release pages into the listing for the yearly roundup page sorted by the release dates in descending order (newest first)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if release_listings:\n",
" yc.update_listing(yearly_release, release_listings)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -279,7 +236,7 @@
"\n",
"### Add yearly release folder to sidebar \n",
"\n",
"Now that we've created the yearly listing page, we need to update the sidebar in `_quarto.yml` to accomodate.\n",
"Now that we've created the yearly listing page, we need to update the releases `_sidebar.yaml` to accomodate.\n",
"\n",
"**This cell takes all the release filepaths matching our year and shoves them into a `contents:` accordion menu with the new `{year}-.releases.qmd` listing page as the landing page.** \n"
]
Expand All @@ -290,7 +247,7 @@
"metadata": {},
"outputs": [],
"source": [
"yc.update_quarto_yaml(year)"
"yc.update_release_sidebar(year)"
]
},
{
Expand Down
Loading