Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release version number to navbar #1083

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 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
5 changes: 5 additions & 0 deletions .github/scripts/release-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ VERSION_STRING_REPLACEMENT="version = \"${CHANNEL_VERSION}\""
awk -v REPLACEMENT="${VERSION_STRING_REPLACEMENT}" '{gsub(/version = \"edge\"/, REPLACEMENT); print}' docs/config.toml > docs/config.toml.tmp
mv docs/config.toml.tmp docs/config.toml

# In docs/config.toml, change version to CHANNEL_VERSION instead of latest or older version
DOC_VERSION_STRING_REPLACEMENT="version = \"${CHANNEL_VERSION}\""
awk -v REPLACEMENT="${DOC_VERSION_STRING_REPLACEMENT}" '{gsub(/^[ \t]*version = "(latest|v.*)"/, REPLACEMENT); print}' docs/config.toml > docs/config.toml.tmp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing this it looks like the indentation is off:
image

Copy link
Contributor Author

@jasonviviano jasonviviano Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the indentation is a stylistic choice here it doesn't affect the outcome, if you run the hugo server command the indentation has no effect on the variable value as it's just a text file. And looking at alternatives I can add an indentation to the awk command but that will end up indentation the other version variable above. So, it's just a stylistic choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the toml schema for more details: https://github.com/toml-lang/toml?tab=readme-ov-file#example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey i fixed it by changing the command!

Here's an explanation of the new one:
In this sed command:

-i.bak edits the file in place and creates a backup with the .bak extension.
-E enables extended regular expressions, which allow for more complex patterns.
The pattern ^( *)[ \t]version = "(latest|v.)" is used to match lines with version = "latest" or version = "v..."
^( )[ \t] captures leading spaces (or tabs) before version = and stores them in \1.
\1 in the replacement part puts the captured indentation back, ensuring the replacement line has the same leading whitespace as the original.
${DOC_VERSION_STRING_REPLACEMENT} is inserted after the captured whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a line after this to delete the tmp file created to pick up the whitespaces

mv docs/config.toml.tmp docs/config.toml

# In docs/config.toml, change github_branch to CHANNEL_VERSION instead of edge
GITHUB_BRANCH_STRING_REPLACEMENT="github_branch = \"${CHANNEL_VERSION}\""
awk -v REPLACEMENT="${GITHUB_BRANCH_STRING_REPLACEMENT}" '{gsub(/github_branch = \"edge\"/, REPLACEMENT); print}' docs/config.toml > docs/config.toml.tmp
Expand Down
4 changes: 2 additions & 2 deletions docs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ version_menu = "Releases"
url = "https://edge.docs.radapp.io"

[[params.versions]]
version = "latest"
url = "https://docs.radapp.io"
version = "v0.31"
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
url = "https://docs.radapp.io"
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

# Markdown Engine - Allow inline html
[markup]
Expand Down
Loading