Skip to content

Conversation

@Chickensoupwithrice
Copy link
Contributor

  • Hackathon attempt to get latest version into docs
  • POC for Versions being updated from the ReleaseRegistry
  • Remove Versions.tsx, it's no longer required
  • Update all instances of "v5.6.2535" to be {CURRENT_VERSION}
  • remove flake.nix whoops

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_STRING which 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.

jdpleiness and others added 5 commits September 24, 2024 16:48
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)
@vercel
Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sourcegraph-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 1:08am

@MaedahBatool
Copy link
Contributor

Hey @Chickensoupwithrice the Vercel build is failing. Looks like a type issue. You can run pnpm run build to view build errors locally.

@Chickensoupwithrice Chickensoupwithrice marked this pull request as draft September 26, 2024 21:58
@Chickensoupwithrice
Copy link
Contributor Author

Yes CURRENT_VERSION_STRING currently doesn't work, I still need to fix that. Converted to draft to avoid confusion for the time being.

@Chickensoupwithrice
Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor

@jdpleiness jdpleiness left a 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentations 🤦🏼‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I blame vstls

@Chickensoupwithrice
Copy link
Contributor Author

Chickensoupwithrice commented Sep 27, 2024

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

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)
Copy link
Contributor

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 🚀

Copy link
Contributor Author

@Chickensoupwithrice Chickensoupwithrice Sep 27, 2024

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

 code  
blocks. Then there's one replacement for the version with the v, and one for without the v

Comment on lines +95 to +104
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
}
})
}
Copy link
Contributor Author

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

Copy link
Contributor Author

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)

Comment on lines +41 to +44
// 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';
Copy link
Contributor Author

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

@DaedalusG
Copy link
Contributor

This change is probably worth a note somewhere in the doc writing handbook, inquiring about that here: https://sourcegraph.slack.com/archives/C01DXLN3D0T/p1727460257629219

@Chickensoupwithrice Chickensoupwithrice merged commit f698968 into main Oct 1, 2024
7 checks passed
@Chickensoupwithrice Chickensoupwithrice deleted the al/REL-404/version-number-releaseregistry branch October 1, 2024 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants