- 
                Notifications
    
You must be signed in to change notification settings  - Fork 76
 
Fix: Get Version string from the releaseRegistry #676
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
Fix: Get Version string from the releaseRegistry #676
Conversation
Mostly CHOP garbage
Any Cody block which has {CURRENT_VERSION} will be replaced by the
latest release from the ReleaseRegistry.
This PR also fixes the PreCodeBlock component, which previously didn't
really work at all. The copy function was broken, and the children check
didn't do anything (child is never of type string in react)
Up next is cleaning up the Versions file (it'll be removed)
And then replacing all hard coded versions with the same process is the
POC. Then we'll also need some automation which deploys / builds the
website at release time since the release version gets determined at
compile time rather than client time.
    Also add {CURRENT_VERSION_STRING} (it doesn't work yet)
    | 
           The latest updates on your projects. Learn more about Vercel for Git ↗︎ 
  | 
    
| 
           Hey @Chickensoupwithrice the Vercel build is failing. Looks like a   | 
    
| 
           Yes   | 
    
outside of code blocks
…m:sourcegraph/docs into al/REL-404/version-number-releaseregistry
| 
           We still need automation to build the docs again on new release, which I think is a better solution than moving the current_version to client side  | 
    
          
 They get rebuilt during our release process when we merge the changelog anyhow, I believe. While I agree automation is the way to go, we can probably split that into another PR down the line. wdyt?  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 🙏
| FeatureParity, | ||
| ResourceEstimator, | ||
| AWSOneClickLaunchForm, | ||
| Accordion, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentations 🤦🏼♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I blame vstls
          
 Yes absolutely. I forgot we already have some (?) automation around the changelog, so we may not actually need the extra automation at all?  | 
    
| 
               | 
          ||
| const version = await getLatestVersion() | ||
| const version_no_v = trimPrefix(version, "v") | ||
| codeContent = codeContent.replace(/{CURRENT_VERSION}/g, version) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice so no special release just whenever the docsite builds this parent component it'll get the info from the release registry 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yessir! We have 2 components, and 2 replacements in each of them. One for inline code blocks, and one for entire 
codeblocks. Then there's one replacement for the version with the
v, and one for without the v
    | let codeContent = props?.raw || '' | ||
| 
               | 
          ||
| // If raw prop is not available, try to extract content from children | ||
| if (!codeContent && children) { | ||
| React.Children.forEach(children, (child) => { | ||
| if (React.isValidElement(child) && child.props.children) { | ||
| codeContent += child.props.children | ||
| } | ||
| }) | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only use children here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(aka can remove this bit)
| // Only apply styles to inline code | ||
| const codeClasses = isCodeBlock | ||
| ? 'bg-transparent' | ||
| : 'border font-medium bg-slate-100 dark:bg-slate-900 px-1 py-0.5 rounded-md border-slate-300 dark:border-slate-700'; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lives in the PreCode component now, can also be removed
| 
           This change is probably worth a note somewhere in the doc writing handbook, inquiring about that here: https://sourcegraph.slack.com/archives/C01DXLN3D0T/p1727460257629219  | 
    
Our version strings are always out of date because we don't have any automation to update them. This PR resolves that problem by reaching out to the ReleaseRegistry at build time to get the latest version string. It then replaces that string in any code block using the PreCodeBlock component (which was previously broken and is now fixed).
It also adds an exported const
CURRENT_VERSION_STRINGwhich can be used outside of Code Blocks and is similarly populated at build time.The final stage of this PR is automation that kicks off a build and releases the docs from the release pipeline itself so nobody has to go in and do that manually.
Pull Request approval
Although pull request approval is not enforced for this repository in order to reduce friction, merging without a review will generate a ticket for the docs team to review your changes. So if possible, have your pull request approved before merging.