Update documentation to use dynamic versioning - #593
Conversation
…date script to fetch latest release from GitHub
There was a problem hiding this comment.
Pull Request Overview
This PR introduces dynamic versioning in the documentation by centralizing the version value in a JSON file and automating its updates.
- Added
src/version.jsonto store the current version. - Updated MDX docs (
installation.mdx,get-started/index.mdx,client-apis/c.mdx) to importversionand replace static snippets with<Code>components driven by dynamic code blocks. - Added
scripts/update-version.cjsand an NPM script to fetch the latest GitHub release and updateversion.json; removed the old GitHub Actions workflow.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/version.json | Introduce a new JSON file to hold the version value. |
| src/content/docs/installation.mdx | Import version.json, define DOWNLOAD_LINKS, and swap out hard-coded snippets for <Code> components. |
| src/content/docs/get-started/index.mdx | Import version.json, define CODE_BLOCKS, and replace static Java/Swift snippets with <Code>. |
| src/content/docs/client-apis/c.mdx | Import version.json, define CMAKE_CONTENT, and use <Code> in place of static CMake example. |
| scripts/update-version.cjs | New script to fetch latest GitHub release and write version.json. |
| package.json | Add update-version to the scripts section. |
| .github/workflows/update-kuzu-version.yml | Removed obsolete workflow in favor of the update script. |
Comments suppressed due to low confidence (4)
scripts/update-version.cjs:13
- The log message refers to
LatestVersion.jsonbut the file being written isversion.json. Update the message toUpdating version.json...for clarity and consistency.
console.log("Updating LatestVersion.json...");
scripts/update-version.cjs:1
- There are no tests for the version update script. Consider adding unit or integration tests (e.g., mocking the GitHub API response and verifying
version.jsonis updated correctly) to catch regressions.
const GITHUB_API_URL = "https://api.github.com/repos/kuzudb/kuzu/releases/latest";
scripts/update-version.cjs:7
- Ensure
fetchis available in the target Node environment (Node v18+ or via a polyfill likenode-fetch); otherwise import or require it explicitly to avoid runtime errors.
const response = await fetch(GITHUB_API_URL);
src/content/docs/client-apis/c.mdx:9
- The CMake snippet no longer includes a
URL_HASHfor the download. Re-adding a SHA256 hash inExternalProject_Addhelps verify the integrity of the archive and prevents tampering.
export const CMAKE_CONTENT =`cmake_minimum_required(VERSION 3.11)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ng application files
sdht0
left a comment
There was a problem hiding this comment.
Nice work. I like it, except for the bad indentation in the code blocks.
|
|
||
| (async () => { | ||
| console.log("Fetching latest version from GitHub..."); | ||
| const response = await fetch(GITHUB_API_URL); |
There was a problem hiding this comment.
We should have a way to manually specify the version, as this script should be run as part of the dev to main release merge, which could be before the actual version has been released.
There was a problem hiding this comment.
I have changed the behavior:
- For the deployment pipeline, there is a way to skip version updating, so that the build process uses the version specified in JSON directly.
- For dev docker deployment, always use the manually specified version (not doing auto version update).
Since now it is just a JSON file that can easily be edited directly. Using the script or workflow to do version update is mainly for automatically version maintaining but not necessary.
| run: npm i | ||
| - name: Update version | ||
| if: ${{ inputs.skipVersionUpdate != true }} | ||
| run: npm run update-version |
There was a problem hiding this comment.
Thinking some more, instead of auto updating on deploy, how about we just check for changes and fail the build. This way, there won't ever me a mismatch between what we see locally on npm run dev vs what is actually deployed.
There was a problem hiding this comment.
I personally do not mind too much about the mismatching. I would prefer to just keep the JSON as a placeholder and allow the script to automatically do it. For https://github.com/kuzudb/kuzudb.github.io I do not update LatestVersion.json at all and solely rely on the script to maintain it during the deployment.
There was a problem hiding this comment.
Although auto check won't really work for a new release.
I don't really like the magical version rewrite during deploy. I think the better way is to add a commit with the new version, like the auto format CI job.
There was a problem hiding this comment.
I think it will work for new release though. We usually build the binaries first and then push the docs. Anyway, feel free to change the behavior to allow manual triggering or committing to the branch. I just personally do not care about it.
No description provided.