diff --git a/.autocorrectrc b/.autocorrectrc new file mode 100644 index 00000000..ca936bcd --- /dev/null +++ b/.autocorrectrc @@ -0,0 +1,3 @@ +# yaml-language-server: $schema=https://huacnlee.github.io/autocorrect/schema.json +textRules: + 哆啦A梦: 0 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..f1c58023 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +/.github @Cryolitia diff --git a/.github/workflows/build-ebook.yaml b/.github/workflows/build-ebook.yaml new file mode 100644 index 00000000..3870bec5 --- /dev/null +++ b/.github/workflows/build-ebook.yaml @@ -0,0 +1,46 @@ +name: Build ebook + +on: + workflow_dispatch: + workflow_call: + pull_request: + +concurrency: + group: ebook-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: DeterminateSystems/flake-checker-action@main + + - name: Setup cachix + uses: cachix/cachix-action@v14 + with: + name: cryolitia + extraPullNames: nix-community + + - name: Print flake metadata + run: nix flake metadata --accept-flake-config + + - name: Build + run: | + sed -e "s/BUILD_TIME/$(TZ=Asia/Shanghai date -Isecond)/" -e "s/COMMIT_SHA/${{ github.sha }}/" -i src/about.md + NIXPKGS_ALLOW_UNFREE=1 nix build .# --impure + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ebook + path: | + result/share/transky-book/book/epub/药娘的天空.epub + result/share/transky-book/book/mobi/药娘的天空.mobi + result/share/transky-book/book/typst-pdf/药娘的天空.pdf diff --git a/.github/workflows/build-web.yaml b/.github/workflows/build-web.yaml new file mode 100644 index 00000000..f9e442f4 --- /dev/null +++ b/.github/workflows/build-web.yaml @@ -0,0 +1,44 @@ +name: Build website + +on: + workflow_dispatch: + workflow_call: + pull_request: + +concurrency: + group: web-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup pnpm + uses: pnpm/action-setup@v3 + with: + version: latest + run_install: true + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + cache: pnpm + node-version: current + + - name: Build + env: + NODE_OPTIONS: --max_old_space_size=4096 + run: | + sed -e "s/BUILD_TIME/$(TZ=Asia/Shanghai date -Isecond)/" -e "s/COMMIT_SHA/${{ github.sha }}/" -i src/about.md + pnpm run build + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: website + path: .vitepress/dist/ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 1788e8a0..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Build and deploy - -on: - push: - branches: - - 'main' - paths: - - ".github/**" - - ".vitepress/**" - - "src/**" - - "theme/**" - - "book.toml" - - "package-lock.json" - - "package.json" - -permissions: - pages: write - id-token: write - -concurrency: - group: "pages" - cancel-in-progress: true - -jobs: - build: - name: Build and deploy - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Pages - uses: actions/configure-pages@v4 - - name: Setup Node.js environment - uses: actions/setup-node@v4 - with: - node-version: current - - name: Install node packages - run: npm ci - - name: Install mdBook - uses: baptiste0928/cargo-install@v2 - with: - crate: mdbook - git: https://github.com/rust-lang/mdBook - - name: Install mdbook-epub - uses: baptiste0928/cargo-install@v2 - with: - crate: mdbook-epub - git: https://github.com/Michael-F-Bryan/mdbook-epub - - name: Install mdbook-typst-pdf - uses: baptiste0928/cargo-install@v2 - with: - crate: mdbook-typst-pdf - git: https://github.com/KaiserY/mdbook-typst-pdf - - name: Install fonts - run: | - mkdir -p ~/.local/share/fonts/ - curl -sL -o Noto_Sans.zip https://fonts.google.com/download?family=Noto%20Sans - unzip Noto_Sans.zip -d ~/.local/share/fonts/Noto_Sans - curl -sL -o Noto_Sans_SC.zip https://fonts.google.com/download?family=Noto%20Sans%20SC - unzip Noto_Sans_SC.zip -d ~/.local/share/fonts/Noto_Sans_SC - curl -sL -o Noto_Sans_Mono.zip https://fonts.google.com/download?family=Noto%20Sans%20Mono - unzip Noto_Sans_Mono.zip -d ~/.local/share/fonts/Noto_Sans_Mono - rm -fv ~/.local/share/fonts/Noto_Sans_Mono/NotoSansMono-VariableFont_wdth,wght.ttf - curl -sL -o Noto_Sans_KR.zip https://fonts.google.com/download?family=Noto%20Sans%20KR - unzip Noto_Sans_KR.zip -d ~/.local/share/fonts/Noto_Sans_KR - curl -sL -o Noto_Sans_Thai.zip https://fonts.google.com/download?family=Noto%20Sans%20Thai - unzip Noto_Sans_Thai.zip -d ~/.local/share/fonts/Noto_Sans_Thai - rm -fv ~/.local/share/fonts/Noto_Sans_Thai/NotoSansThai-VariableFont_wdth,wght.ttf - curl -sL -o Noto_Sans_Arabic.zip https://fonts.google.com/download?family=Noto%20Sans%20Arabic - unzip Noto_Sans_Arabic.zip -d ~/.local/share/fonts/Noto_Sans_Arabic - curl -sL -o Noto_Sans_Hebrew.zip https://fonts.google.com/download?family=Noto%20Sans%20Hebrew - unzip Noto_Sans_Hebrew.zip -d ~/.local/share/fonts/Noto_Sans_Hebrew - curl -sL -o Noto_Sans_Devanagari.zip https://fonts.google.com/download?family=Noto%20Sans%20Devanagari - unzip Noto_Sans_Devanagari.zip -d ~/.local/share/fonts/Noto_Sans_Devanagari - rm -fv ~/.local/share/fonts/Noto_Sans_Devanagari/NotoSansDevanagari-VariableFont_wdth,wght.ttf - curl -sL -o Noto_Emoji.zip https://fonts.google.com/download?family=Noto%20Emoji - unzip Noto_Emoji.zip -d ~/.local/share/fonts/Noto_Emoji - curl -sL -o times_sans_serif.zip https://dl.dafont.com/dl/?f=times_sans_serif - unzip times_sans_serif.zip -d ~/.local/share/fonts/times_sans_serif - fc-cache -rv - - name: Install Calibre - run: | - sudo apt install -y libegl1 libopengl0 libxcb-cursor0 - sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin - - name: Build - run: | - sed -e "s/BUILD_TIME/$(TZ=Asia/Shanghai date -Isecond)/" -e "s/COMMIT_SHA/${{ github.sha }}/" -i src/about.md - npm run build - ebook-convert .vitepress/dist/药娘的天空.epub .vitepress/dist/药娘的天空.mobi diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..c43c0c84 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,27 @@ +name: Lint + +on: + pull_request: + +permissions: + pull-requests: write + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: AutoCorrect + uses: huacnlee/autocorrect-action@main + + - name: Report ReviewDog + if: failure() + uses: huacnlee/autocorrect-action@main + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + reviewdog: true diff --git a/.github/workflows/publish-cloudflare.yaml b/.github/workflows/publish-cloudflare.yaml new file mode 100644 index 00000000..33c077cd --- /dev/null +++ b/.github/workflows/publish-cloudflare.yaml @@ -0,0 +1,43 @@ +name: Publish website to cloudflare + +on: + workflow_dispatch: + push: + branches: + - "main" + paths: + - ".github/workflows/build-web.yaml" + - ".github/workflows/publish-cloudflare.yaml" + - ".vitepress/**" + - "src/**" + - "package.json" + - "pnpm-lock.yaml" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + uses: ./.github/workflows/build-web.yaml + + publish: + needs: build + runs-on: ubuntu-latest + environment: cloudflare-pages + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: website + path: website + + - name: Publish to Cloudflare Pages + uses: cloudflare/pages-action@v1 + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + with: + apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} + projectName: transky-book + directory: website + wranglerVersion: 3 diff --git a/.github/workflows/publish-release.yaml b/.github/workflows/publish-release.yaml new file mode 100644 index 00000000..e22e1389 --- /dev/null +++ b/.github/workflows/publish-release.yaml @@ -0,0 +1,62 @@ +name: Publish ebook to release + +on: + workflow_dispatch: + push: + branches: + - "main" + - "stable" + paths: + - ".github/workflows/build-ebook.yaml" + - ".github/workflows/publish-release.yaml" + - ".releaserc" + - "src/**" + - "theme/**" + - "book.toml" + - "package.json" + - "pnpm-lock.yaml" + - "flake.nix" + - "flake.lock" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + uses: ./.github/workflows/build-ebook.yaml + + publish: + permissions: + contents: write + needs: build + if: ${{ !(github.event_name == 'push' && contains(github.event.head_commit.message, '[skip release]')) }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup pnpm + uses: pnpm/action-setup@v3 + with: + version: latest + run_install: true + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + cache: pnpm + node-version: current + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ebook + path: ebook + + - name: Release ebook + env: + GITHUB_TOKEN: ${{ github.token }} + run: pnpm exec semantic-release diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 87f6f718..00000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: Publish Cloudflare Pages - -on: - push: - branches: - - 'main' - -jobs: - build: - name: Build and deploy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: pnpm/action-setup@v3 - with: - version: latest - - uses: actions/setup-node@v4 - with: - cache: npm - - name: Install - run: npm ci - - name: Build - run: | - sed -e "s/BUILD_TIME/$(TZ=Asia/Shanghai date -Isecond)/" -e "s/COMMIT_SHA/${{ github.sha }}/" -i src/about.md - npm run docs:build - env: - NODE_OPTIONS: --max_old_space_size=4096 - - name: Publish to Cloudflare Pages - uses: cloudflare/pages-action@v1 - with: - apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} - projectName: proskynova-github-io - directory: .vitepress/dist - wranglerVersion: '3' diff --git a/.github/workflows/update-flake.yaml b/.github/workflows/update-flake.yaml new file mode 100644 index 00000000..3b6cae9d --- /dev/null +++ b/.github/workflows/update-flake.yaml @@ -0,0 +1,48 @@ +name: "Update flake" + +on: + workflow_dispatch: + push: + branches: + - "main" + paths: + - ".github/workflows/update-flake.yaml" + schedule: + - cron: '31 2 * * 5' + +permissions: + contents: write + +jobs: + sync-flake: + runs-on: ubuntu-latest + environment: flake + steps: + - uses: DeterminateSystems/nix-installer-action@main + + - name: Checkout + uses: actions/checkout@v4 + with: + show-progress: false + token: ${{ secrets.PAT }} + + - name: Setup Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git show -s + + - name: Update flake + run: | + set +e + + nix flake update --accept-flake-config + nix flake info --accept-flake-config + + # suppress inactive repo update weekly + git log --pretty=format:"%s" -1 HEAD | grep "dep: flake update" || exit 0 + + git add . + git status + git commit -m "dep: flake update $(date +'%Y-%m-%dT%H:%M:%S')" || exit 0 + git push diff --git a/.gitignore b/.gitignore index 4d87cfa4..c1732e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ book .vitepress/cache .vitepress/dist node_modules +result diff --git a/.releaserc b/.releaserc new file mode 100644 index 00000000..63c5dbe5 --- /dev/null +++ b/.releaserc @@ -0,0 +1,70 @@ +{ + "branches": [ + { + "name": "main", + "prerelease": true + }, + "stable" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { "breaking": true, "release": "major" }, + { "revert": true, "release": "patch" }, + { "type": "feat", "release": "minor" }, + { "type": "fix", "release": "patch" }, + { "type": "rfct", "release": "patch" }, + { "type": "style", "release": "patch" }, + { "type": "typo", "release": "patch" }, + { "type": "grammar", "release": "patch" }, + { "type": "ambig", "release": "patch" }, + { "type": "punctua", "release": "patch" }, + { "type": "chore", "release": "patch" }, + { "type": "ci", "release": "patch" } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { "type": "feat", "section": "Features", "hidden": false }, + { "type": "fix", "section": "Bug Fixes", "hidden": false }, + { "type": "rfct", "section": "Refactors", "hidden": false }, + { "type": "style", "section": "Style Improves", "hidden": false }, + { "type": "typo", "section": "Typo Fixes", "hidden": false }, + { "type": "grammar", "section": "Grammar Fixes",vv "hidden": false }, + { "type": "ambig", "section": "Ambiguity Fixes", "hidden": false }, + { "type": "punctua", "section": "Punctuation Fixes", "hidden": false }, + { "type": "chore", "section": "Chores", "hidden": false }, + { "type": "ci", "section": "CI", "hidden": true } + ] + } + } + ], + [ + "@semantic-release/github", + { + "assets": [ + { "path": "ebook/epub/药娘的天空.epub", "name": "transky-${nextRelease.version}.epub" }, + { "path": "ebook/mobi/药娘的天空.mobi", "name": "transky-${nextRelease.version}.mobi" }, + { "path": "ebook/typst-pdf/药娘的天空.pdf", "name": "transky-${nextRelease.version}.pdf" } + ], + "successComment": false, + "failComment": false + } + ], + [ + "@saithodev/semantic-release-backmerge", + { + "backmergeBranches": [{ "from": "stable", "to": "main" }], + "clearWorkspace": true + } + ] + ] +} diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 3f243c10..91f4a6d4 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -45,16 +45,16 @@ export default defineConfig({ excludeFiles: ["about.md", "SUMMARY.md"], }), outline: false, - socialLinks: [{ icon: "github", link: "https://github.com/proskynova" }], + socialLinks: [{ icon: "github", link: "https://github.com/transky-book/transky" }], footer: { message: '基于 CC BY-NC-SA 4.0 许可发布', copyright: - '版权所有 © 2023 Zh40Le1ZOOB', + '版权所有 © 2016-2024 乱世银娘Transky 全体贡献者', }, editLink: { pattern: - "https://github.com/proskynova/proskynova.github.io/edit/main/src/:path", + "https://github.com/transky-book/transky/edit/main/src/:path", text: "在 GitHub 上编辑此页面", }, lastUpdated: { diff --git a/.vitepress/theme/comment.vue b/.vitepress/theme/comment.vue new file mode 100644 index 00000000..3aae5754 --- /dev/null +++ b/.vitepress/theme/comment.vue @@ -0,0 +1,13 @@ + + + diff --git a/.vitepress/theme/index.js b/.vitepress/theme/index.js index 1e2a666e..48159419 100644 --- a/.vitepress/theme/index.js +++ b/.vitepress/theme/index.js @@ -1,36 +1,14 @@ -import { useData, useRoute } from "vitepress"; +import { useRoute } from "vitepress"; import DefaultTheme from "vitepress/theme"; -import giscusTalk from "vitepress-plugin-comment-with-giscus"; +import comment from "./comment.vue"; import imageViewer from "vitepress-plugin-image-viewer"; import "viewerjs/dist/viewer.min.css"; import "./indent.css"; export default { ...DefaultTheme, + Layout: comment, setup() { - const { frontmatter } = useData(); - const route = useRoute(); - imageViewer(route); - giscusTalk( - { - repo: "proskynova/proskynova.github.io", - repoId: "R_kgDOLEtJ4A", - category: "评论区", - categoryId: "DIC_kwDOLEtJ4M4Cch85", - mapping: "title", - strict: 1, - reactionsEnabled: 1, - emitaMetadata: 1, - inputPosition: "top", - theme: "preferred_color_scheme", - lang: "zh-CN", - loading: "lazy", - }, - { - frontmatter, - route, - }, - true, - ); + imageViewer(useRoute()); }, }; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72f37de4..6ec861c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,100 +1,138 @@ # 贡献指南 -## 用语规范 +## 用语规范 本项目贡献者包括跨性别者等多元文化群体,请在贡献时尊重 ta 人,使用友善礼貌的词语。 -## 提交规范 +## 提交规范 -### 单个提交更改量 +> 提交说明中所有字段均应在 CJK 字符与非 CJK 字符间插入空格。 -每一个提交只做一件事,即只适用一个 [Type 字段](#type)和一个 [Scope 字段](#scope)。过多更改堆积在一个提交时应当按类型拆分成多个提交。 - -### 提交说明 - -> 提交说明的所有格式部分均使用英文半角标点,只有字段内容视使用语言使用全角标点,所有 CJK 字符与英文之间应插入空格。 +提交说明格式: ``` -(): +[()]: <空行> - + <空行> -