From 8fe849dee0c49331c2915ff870546f4b0f764bc4 Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 11:57:37 +0800 Subject: [PATCH 01/12] Update deploy.yaml --- .github/workflows/deploy.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 40e960433a8..06989d20c91 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,11 +1,11 @@ name: Publish docs via GitHub Pages env: - ACTIONTEST: community + ACTIONTEST: pdf # branch name, like master, 2.4 on: push: branches: # hard code branch name - - community + - pdf jobs: prepare: @@ -69,7 +69,7 @@ jobs: mkdocs = yaml.safe_load(file) database_edition = mkdocs.get('database_edition', '') shell: python - + - name: Git Config run: git config user.name whitewum && git config user.email min.wu@vesoft.com @@ -82,6 +82,7 @@ jobs: run: | python ./scripts/conditional_render.py python ./scripts/conditional_yml.py + python ./scripts/conditional_pdf.py git fetch origin gh-pages --depth=1 # fix mike's CI update mike deploy ${{ env.ACTIONTEST }} -p --rebase mike list From 7fa7bd42e5a33895d5b70db5dbdbdbe15b0ebd54 Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 11:58:10 +0800 Subject: [PATCH 02/12] Update pdf.yml --- pdf.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/pdf.yml b/pdf.yml index 59fbbb0747e..0df1765332f 100644 --- a/pdf.yml +++ b/pdf.yml @@ -1,12 +1,2 @@ -# modify when release: - - PDF: ./pdf/NebulaGraph-CN.pdf - -plugins: - - with-pdf: - copyright: 2023 vesoft Inc. - cover_subtitle: master - author: 吴敏,周瑶,梁振亚,黄凤仙 - cover: true - back_cover: true - cover_logo: 'https://cloud-cdn.nebula-graph.com.cn/nebula-for-pdf.png' - output_path: pdf/NebulaGraph-CN.pdf +withpdf: False +# True or False. case sensitive From 885f739a558f6eb3784d491983bcc5a062820307 Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 11:58:45 +0800 Subject: [PATCH 03/12] Create conditional_pdf.py --- scripts/conditional_pdf.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/conditional_pdf.py diff --git a/scripts/conditional_pdf.py b/scripts/conditional_pdf.py new file mode 100644 index 00000000000..26b3e78f7a1 --- /dev/null +++ b/scripts/conditional_pdf.py @@ -0,0 +1,28 @@ +import re +import yaml + +def process_mkdocs_yml(mkdocs_yml_path, withpdf): + with open(mkdocs_yml_path, 'r', encoding='utf-8') as f: + content = f.read() + if withpdf == True: + content = re.sub( + r'#\s*nav\.pdf\.begin(.*?)#\s*nav\.pdf\.end', + '\\1', content, flags=re.DOTALL) + elif withpdf == False: + print("remove pdf") + content = re.sub( + r'#\s*nav\.pdf\.begin(.*?)#\s*nav\.pdf\.end', + '', content, flags=re.DOTALL) + with open(mkdocs_yml_path, 'w', encoding='utf-8') as f: + f.write(content) + print(content) + +if __name__ == '__main__': + pdf_yml_path = 'pdf.yml' + with open(pdf_yml_path, 'r', encoding='utf-8') as f: + config = yaml.safe_load(f) + withpdf = config.get("withpdf", "") + print(withpdf) + if (withpdf != True) and (withpdf != False): + raise ValueError("Invalid value for pdf parameter: {}".format(withpdf)) + process_mkdocs_yml('mkdocs.yml', withpdf) From 87d21a741dd1cd8175b4dd57b922bb763dec7c1d Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 12:53:19 +0800 Subject: [PATCH 04/12] Update mkdocs.yml --- mkdocs.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index a3a55b3c013..b95554c0f39 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -131,17 +131,16 @@ plugins: # Exclude files with regular expressions (regexes) # regex: # - '.*\.(tmp|bin|tar)$' - -# modify when release: -# - with-pdf: -# copyright: 2023 vesoft Inc. -# cover_subtitle: master -# author: 吴敏,梁振亚,黄凤仙,李泓臻 -# cover: true -# back_cover: true -# cover_logo: 'https://cloud-cdn.nebula-graph.com.cn/nebula-for-pdf.png' -# output_path: pdf/NebulaGraph-CN.pdf - +# nav.pdf.begin + - with-pdf: + copyright: 2023 vesoft Inc. + cover_subtitle: master + author: 吴敏,梁振亚,黄凤仙,李泓臻 + cover: true + back_cover: true + cover_logo: 'https://cloud-cdn.nebula-graph.com.cn/nebula-for-pdf.png' + output_path: pdf/NebulaGraph-CN.pdf +# nav.pdf.end extra_javascript: - js/version-select.js - js/config.js @@ -893,5 +892,6 @@ nav: - 年表: 20.appendix/history.md - 思维导图: 20.appendix/mind-map.md - 错误码: 20.appendix/error-code.md - -# - PDF: ./pdf/NebulaGraph-CN.pdf +# nav.pdf.begin + - PDF: ./pdf/NebulaGraph-CN.pdf +# nav.pdf.end From ae9e54c25cc14469d88d5bbc8d9e84aea76adae4 Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 12:54:31 +0800 Subject: [PATCH 05/12] WIP Update deploy.yaml --- .github/workflows/deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 06989d20c91..638f86057af 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,11 +1,11 @@ name: Publish docs via GitHub Pages env: - ACTIONTEST: pdf + ACTIONTEST: master # branch name, like master, 2.4 on: push: branches: # hard code branch name - - pdf + - master jobs: prepare: From 5caa89e1d8689a9d2f9922d07bbb1f550f56546b Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 13:00:33 +0800 Subject: [PATCH 06/12] Update database_edition.yml --- database_edition.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/database_edition.yml b/database_edition.yml index a3c4e1ff935..851b07fbbda 100644 --- a/database_edition.yml +++ b/database_edition.yml @@ -1 +1,5 @@ -database_edition: community +database_edition: both +# Copy from the folowing words. Not write the word by your self +# community +# enterprise +# both From 17f7979b4622919b0b18349313d0f08e443e4e4e Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 13:01:23 +0800 Subject: [PATCH 07/12] Update deploy.yaml --- .github/workflows/deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 638f86057af..06989d20c91 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,11 +1,11 @@ name: Publish docs via GitHub Pages env: - ACTIONTEST: master + ACTIONTEST: pdf # branch name, like master, 2.4 on: push: branches: # hard code branch name - - master + - pdf jobs: prepare: From c9881adb043cccb736ed82da3246c2d31be0c3d8 Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 13:17:09 +0800 Subject: [PATCH 08/12] Update deploy.yaml --- .github/workflows/deploy.yaml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 06989d20c91..2e606d6d85a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -27,7 +27,7 @@ jobs: id: set-matrix run: | import yaml, os, json - with open('database_edition.yml', 'r') as file: + with open('./database_edition.yml', 'r') as file: mkdocs = yaml.safe_load(file) database_edition = mkdocs.get('database_edition', '') print(f"database_edition: {database_edition}") # Print the variable for debugging @@ -61,13 +61,15 @@ jobs: - name : prepare run: sh ./prepare.sh - + # if 'both', set each file 'community' and 'enterprise' seperately. - name: Update database_edition.yml run: | - import yaml - with open('database_edition.yml', 'r') as file: - mkdocs = yaml.safe_load(file) - database_edition = mkdocs.get('database_edition', '') + import yaml + with open('./database_edition.yml', 'r') as file: + content = yaml.safe_load(file) + content['database_edition'] = f"${{ matrix.database_edition }}" + with open('./database_edition.yml', 'w') as file: + yaml.dump(content, file) shell: python - name: Git Config @@ -75,8 +77,8 @@ jobs: - name: save tmp files run: | - cp -f *.json /tmp/ - cp -f *.yml /tmp/ + mv *.json /tmp/ # f"${{ matrix.database_edition }}"_versions.json + mv *.yml /tmp/ ls /tmp/ -ltr - name: mike run: | @@ -95,10 +97,7 @@ jobs: run: | import yaml, json new_content = {"version": "${{ env.ACTIONTEST }}", "title": "${{ env.ACTIONTEST }}", "aliases": []} - with open('/tmp/database_edition.yml', 'r') as file: - mkdocs = yaml.safe_load(file) - database_edition = mkdocs.get('database_edition', '') - filename = "/tmp/" + database_edition + "_versions.json" + filename = "/tmp/" + f"${{ matrix.database_edition }}" + "_versions.json" with open(filename, 'r') as infile: json_data = json.load(infile) found = False @@ -108,7 +107,7 @@ jobs: break if not found: json_data.append(new_content) - with open('versions.json', 'w') as outfile: + with open('./versions.json', 'w') as outfile: json.dump(json_data, outfile, indent=2) shell: python - name: Compress From db8f70aec8195135a9c68a25c693f15db11b9036 Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 13:20:59 +0800 Subject: [PATCH 09/12] Update deploy.yaml --- .github/workflows/deploy.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 2e606d6d85a..8afa84e82e2 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -77,8 +77,8 @@ jobs: - name: save tmp files run: | - mv *.json /tmp/ # f"${{ matrix.database_edition }}"_versions.json - mv *.yml /tmp/ + cp -f *.json /tmp/ # f"${{ matrix.database_edition }}"_versions.json + cp -f *.yml /tmp/ ls /tmp/ -ltr - name: mike run: | @@ -97,6 +97,7 @@ jobs: run: | import yaml, json new_content = {"version": "${{ env.ACTIONTEST }}", "title": "${{ env.ACTIONTEST }}", "aliases": []} + # the only place read from /tmp/ filename = "/tmp/" + f"${{ matrix.database_edition }}" + "_versions.json" with open(filename, 'r') as infile: json_data = json.load(infile) From 1fc4fe9c5d6f255efd61cbe6aa63add87ffe7ce7 Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 13:35:15 +0800 Subject: [PATCH 10/12] Update deploy.yaml --- .github/workflows/deploy.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 8afa84e82e2..dda1a5232b7 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -77,8 +77,7 @@ jobs: - name: save tmp files run: | - cp -f *.json /tmp/ # f"${{ matrix.database_edition }}"_versions.json - cp -f *.yml /tmp/ + cp -f *versions.json /tmp/ # f"${{ matrix.database_edition }}"_versions.json ls /tmp/ -ltr - name: mike run: | From 257012271bcd044654ef392d9f5db93becfc894d Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 13:42:56 +0800 Subject: [PATCH 11/12] Update deploy.yaml --- .github/workflows/deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index dda1a5232b7..d28d90ce101 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,11 +1,11 @@ name: Publish docs via GitHub Pages env: - ACTIONTEST: pdf + ACTIONTEST: master # branch name, like master, 2.4 on: push: branches: # hard code branch name - - pdf + - master jobs: prepare: From b238b9b00eb8190fedeb8fb8d30a158c5cc1fa85 Mon Sep 17 00:00:00 2001 From: "min.wu" <50101159+whitewum@users.noreply.github.com> Date: Tue, 9 May 2023 14:03:53 +0800 Subject: [PATCH 12/12] Delete auto_release.py --- scripts/auto_release.py | 42 ----------------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 scripts/auto_release.py diff --git a/scripts/auto_release.py b/scripts/auto_release.py deleted file mode 100644 index 6ef2ffc4ad2..00000000000 --- a/scripts/auto_release.py +++ /dev/null @@ -1,42 +0,0 @@ -import re - -def replace_line(file_path, search_text, new_line): - with open(file_path, 'r', encoding='utf-8') as f: - file_content = f.read() - new_content = re.sub(search_text, new_line, file_content) - - with open(file_path, 'w', encoding='utf-8') as f: - f.write(new_content) - -def update_github_actions(doc_version): - if doc_version == 'master': - replace_line('.github/workflows/deploy.yaml', r'branches:\s+-.*', f'branches:\n - {doc_version}') - replace_line('.github/workflows/deploy.yaml', r'mike deploy .* -p --rebase\n mike set-default .* -p --rebase', f'mike deploy {doc_version} -p --rebase') - replace_line('.github/workflows/deploy.yaml', r'tar -vczf nebula-docs.tar.gz.*', f'tar -vczf nebula-docs.tar.gz {doc_version} versions.json *.html') - replace_line('.github/workflows/deploy.yaml', r'cp -f /usr/web/nebula-docs/.*/pdf/NebulaGraph-CN.pdf', f'cp -f /usr/web/nebula-docs/{doc_version}/pdf/NebulaGraph-CN.pdf') - else: - replace_line('.github/workflows/deploy.yaml', r'branches:\s+-.*', f'branches:\n - v{doc_version}') - replace_line('.github/workflows/deploy.yaml', r'mike deploy .* -p --rebase', f'mike deploy {doc_version} -p --rebase\n mike set-default {doc_version} -p --rebase') - replace_line('.github/workflows/deploy.yaml', r'tar -vczf nebula-docs.tar.gz.*', f'tar -vczf nebula-docs.tar.gz {doc_version} versions.json *.html') - replace_line('.github/workflows/deploy.yaml', r'cp -f /usr/web/nebula-docs/.*/pdf/NebulaGraph-CN.pdf', f'cp -f /usr/web/nebula-docs/{doc_version}/pdf/NebulaGraph-CN.pdf') - -def update_mkdocs_yml(doc_version): - if doc_version == 'master': - replace_line('./mkdocs.yml', r'cover_subtitle:.*', f'cover_subtitle: {doc_version}') - replace_line('./mkdocs.yml', r'https://github.com/vesoft-inc/nebula-docs-cn/edit/.*/docs-2.0/', f'https://github.com/vesoft-inc/nebula-docs-cn/edit/{doc_version}/docs-2.0/') - else: - replace_line('./mkdocs.yml', r'cover_subtitle:.*', f'cover_subtitle: v{doc_version}') - replace_line('./mkdocs.yml', r'https://github.com/vesoft-inc/nebula-docs-cn/edit/.*/docs-2.0/', f'https://github.com/vesoft-inc/nebula-docs-cn/edit/v{doc_version}/docs-2.0/') - -if __name__ == "__main__": - with open('./mkdocs.yml', 'r', encoding='utf-8') as f: - file_content = f.read() - doc_version_match = re.search(r'doc_version:.*', file_content) - if doc_version_match: - doc_version = doc_version_match.group().split(':')[1].strip() - if not isinstance(doc_version, str): - raise TypeError("The value of doc_version should be a string") - else: - raise Exception("The value of doc_version is not found in mkdocs.yml") - update_github_actions(doc_version) - update_mkdocs_yml(doc_version) \ No newline at end of file