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

ci: initial commit for versioned docs action #1429

Merged
merged 7 commits into from
Jan 8, 2025
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
34 changes: 34 additions & 0 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## this script is to update for major/minor updates
## the input version format should be like: 1.0 or 0.12
VERSION=$1

echo "Processing variables"
cp variables/variables-nightly.ts variables/variables-$VERSION.ts
sed -i "s/greptimedbVersion: 'v[^']*'/greptimedbVersion: 'v$VERSION.0'/" variables/variables-$VERSION.ts
sed -i "s/greptimedbVersion: 'v[^']*'/greptimedbVersion: 'v$VERSION.0'/" variables/variables-nightly.ts

echo "Processing localized sidebars"
cp i18n/zh/docusaurus-plugin-content-docs/current.json i18n/zh/docusaurus-plugin-content-docs/version-$VERSION.json
jq 'del(.["version.label"])' i18n/zh/docusaurus-plugin-content-docs/version-$VERSION.json > temp.json && mv temp.json i18n/zh/docusaurus-plugin-content-docs/version-$VERSION.json

echo "Removing greptimecloud content from current version"
CURRENT_VERSION=$(jq -r '.[0]' versions.json)
rm -rf versioned_docs/version-$CURRENT_VERSION/greptimecloud
rm -rf i18n/zh/docusaurus-plugin-content-docs/version-$CURRENT_VERSION/greptimecloud
jq 'del(.docs[] | select(.label == "GreptimeCloud"))' versioned_sidebars/version-$CURRENT_VERSION-sidebars.json > temp.json && mv temp.json versioned_sidebars/version-$CURRENT_VERSION-sidebars.json
sed -i '/^- \[GreptimeCloud\]/d' versioned_docs/version-$CURRENT_VERSION/index.md
sed -i '/^- \[GreptimeCloud\]/d' i18n/zh/docusaurus-plugin-content-docs/version-$CURRENT_VERSION/index.md

echo "Generating new version"
npm run docusaurus docs:version $VERSION

# echo "Removing oldest version"
# OLDEST_VERSION=$(jq -r '.[-1]' versions.json)
# rm -rf versioned_docs/version-$OLDEST_VERSION
# rm -rf i18n/zh/docusaurus-plugin-content-docs/version-$OLDEST_VERSION/
# rm i18n/zh/docusaurus-plugin-content-docs/version-$OLDEST_VERSION.json
# rm versioned_sidebars/version-$OLDEST_VERSION-sidebars.json
# jq '.[:-1]' versions.json > temp.json && mv temp.json versions.json

# echo "Set new default"
# npm run docusaurus docs:use-version $VERSION
39 changes: 39 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Version Docs

on:
workflow_dispatch:
inputs:
version:
description: 'Version number without patch (e.g., 1.0 or 0.12)'
required: true
type: string

jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22

- name: Install dependencies
run: npm install

- name: Call update scripts
run: |
VERSION=${{ github.event.inputs.version }}
.github/scripts/release.sh $VERSION

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "Version docs to ${{ github.event.inputs.version }}"
title: "Version docs to ${{ github.event.inputs.version }}"
body: "This PR updates the docs to version ${{ github.event.inputs.version }}."
branch: "version-docs-${{ github.event.inputs.version }}"
base: main
delete-branch: true
6 changes: 0 additions & 6 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,6 @@ const config: Config = {
current: {
label: 'nightly',
path: 'nightly',
},
'0.8': {
path: 'v0.8'
},
'0.7': {
path: 'v0.7'
}
},
remarkPlugins: [
Expand Down
Loading
Loading