Przeglądaj źródła

【新增,配置】添加 GitHub Actions 自动发布工作流和英文文档

添加 GitHub Actions 测试工作流,实现版本检查、字体编译和产物上传功能
创建英文版 README 文档,分离中英文内容以改善阅读体验
新增版本文件 VERSION 和版本检查脚本 scripts/is-newer-version.bash
优化构建脚本 build_font_from_bdf.py 的字符输出逻辑
更新 .gitignore 忽略 AI 辅助文件
PJ568 1 rok temu
rodzic
commit
1c3eb8c683

+ 85 - 0
.github/workflows/release.yml

@@ -0,0 +1,85 @@
+name: 自动发行版本
+
+on:
+  workflow_dispatch:
+  push:
+    branches:
+      - master
+
+jobs:
+  release:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      pages: write
+      id-token: write
+    name: 发行新版本
+    steps:
+      - name: 检出代码
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+
+      - name: 检查版本
+        id: version-check
+        run: |
+          VERSION=$(./scripts/is-newer-version.bash)
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
+          if [ "$VERSION" != "0" ]; then
+            echo "检测到新版本: $VERSION"
+          else
+            echo "没有新版本需要发行"
+          fi
+
+      - name: 推送标签
+        if: steps.version-check.outputs.version != '0'
+        id: push-tag
+        run: |
+          tag="v${{ steps.version-check.outputs.version }}"
+          git config user.name "${GITHUB_ACTOR}"
+          git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+          git tag -a "${tag}" -m "Release ${tag}"
+          git push origin "${tag}"
+          echo "tag_name=${tag}" >> $GITHUB_OUTPUT
+
+      - name: 配置环境
+        if: steps.version-check.outputs.version != '0'
+        run: |
+          # 安装 Python 依赖
+          python3 -m pip install --upgrade pip
+          pip3 install -r requirements.txt
+
+          # 安装构建依赖
+          sudo apt-get update
+          sudo apt-get install -y build-essential wget tar gzip
+
+      - name: 编译字体
+        if: steps.version-check.outputs.version != '0'
+        run: |
+          # 运行构建脚本
+          bash build.bash
+
+          # 验证输出文件
+          if [ ! -f "output/xibo.psfu.gz" ]; then
+            echo "错误:字体文件生成失败"
+            exit 1
+          fi
+
+          # 显示文件信息
+          ls -la output/xibo.psfu.gz
+
+      - name: 创建 GitHub Release
+        if: steps.version-check.outputs.version != '0'
+        uses: ncipollo/release-action@v1
+        with:
+          generateReleaseNotes: true
+          tag: "v${{ steps.version-check.outputs.version }}"
+          artifacts: "output/xibo.psfu.gz,output/xibo.psf,output/xibo.txt"
+
+      - name: 删除标签(如果失败)
+        if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
+        run: |
+          git config user.name "${GITHUB_ACTOR}"
+          git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+          git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
+          git tag -d "${{ steps.push-tag.outputs.tag_name }}"

+ 93 - 0
.github/workflows/test.yml

@@ -0,0 +1,93 @@
+name: 【测试】自动发行版本
+
+on:
+  workflow_dispatch:
+  # push:
+  #   branches:
+  #     - master
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      pages: write
+      id-token: write
+    name: 【测试】发行新版本的发行
+    steps:
+      - name: 检出代码
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+
+      - name: 检查版本
+        id: version-check
+        run: |
+          VERSION=$(./scripts/is-newer-version.bash)
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
+          if [ "$VERSION" != "0" ]; then
+            echo "检测到新版本: $VERSION"
+          else
+            echo "没有新版本需要发行"
+          fi
+
+      # - name: 推送标签
+      #   if: steps.version-check.outputs.version != '0'
+      #   id: push-tag
+      #   run: |
+      #     tag="v${{ steps.version-check.outputs.version }}"
+      #     git config user.name "${GITHUB_ACTOR}"
+      #     git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+      #     git tag -a "${tag}" -m "Release ${tag}"
+      #     git push origin "${tag}"
+      #     echo "tag_name=${tag}" >> $GITHUB_OUTPUT
+
+      - name: 配置环境
+        if: steps.version-check.outputs.version != '0'
+        run: |
+          # 安装 Python 依赖
+          python3 -m pip install --upgrade pip
+          pip3 install -r requirements.txt
+
+          # 安装构建依赖
+          sudo apt-get update
+          sudo apt-get install -y build-essential wget tar gzip
+
+      - name: 编译字体
+        if: steps.version-check.outputs.version != '0'
+        run: |
+          # 运行构建脚本
+          bash build.bash
+
+          # 验证输出文件
+          if [ ! -f "output/xibo.psfu.gz" ]; then
+            echo "错误:字体文件生成失败"
+            exit 1
+          fi
+
+          # 显示文件信息
+          ls -la output/xibo.psfu.gz
+
+      - name: Upload artifact
+        if: (cancelled() || failure() || success())
+        uses: actions/upload-artifact@v4
+        with:
+          path: output/*
+          compression-level: 9 # maximum compression
+          retention-days: 5
+
+      # - name: 创建 GitHub Release
+      #   if: steps.version-check.outputs.version != '0'
+      #   uses: ncipollo/release-action@v1
+      #   with:
+      #     generateReleaseNotes: true
+      #     tag: "v${{ steps.version-check.outputs.version }}"
+      #     artifacts: "output/xibo.psfu.gz"
+
+      # - name: 删除标签(如果失败)
+      #   if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
+      #   run: |
+      #     git config user.name "${GITHUB_ACTOR}"
+      #     git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+      #     git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
+      #     git tag -d "${{ steps.push-tag.outputs.tag_name }}"

+ 4 - 1
.gitignore

@@ -2,4 +2,7 @@
 /output/
 
 # 忽略临时文件夹
-/temp/
+/temp/
+
+QWEN.md
+CLAUDE.md

+ 63 - 0
README.en.md

@@ -0,0 +1,63 @@
+# ![Demo](assets/display.png)
+
+> [简体中文](README.md) | ENGLISH
+
+## font-xibo
+
+Xibo is a Chinese TTY font designed for Linux, aiming to provide Chinese display in TTY without installing kernel patches such as [cjktty](https://github.com/zhmars/cjktty-patches) or third-party software like [kmscon](http://www.freedesktop.org/wiki/Software/kmscon), [fbterm](https://salsa.debian.org/debian/fbterm), or [zhcon](https://zhcon.sourceforge.net/).
+
+The inspiration for this project comes from the [syllazh](https://github.com/oldherl/syllazh/) font.
+
+## Phonetic Characters
+
+When using this font, you may notice that characters with similar pronunciations are displayed as the same character. For example, any of the characters "用永勇拥擁涌湧咏詠蛹雍踊庸踴泳" will be uniformly displayed as "用".
+
+This is because fonts on Linux TTY are generally changed using the `setfont` tool from the kbd package, which supports a maximum of 512 glyphs. However, a single glyph can map to multiple Unicode code points.
+Therefore, Xibo maps all characters with the same pronunciation (ignoring tones) to the same glyph, allowing for Chinese character display within the limited number of glyphs.
+
+## Building the Font
+
+1. Clone the repository:
+
+   ```shellscript
+   git clone https://github.com/PJ-568/font-xibo.git
+   cd font-xibo
+   ```
+
+2. Install dependencies:
+
+   ```shellscript
+   pip install -r requirements.txt
+   ```
+
+3. Build the font:
+
+   ```shellscript
+   bash build.bash
+   ```
+
+   During the build process, the script will install `psftools`, which is used to generate the font.
+
+After building, a PSF2 font file named `xibo.psfu.gz` will be generated in the `output/` directory.
+
+## Using the Font
+
+> Ensure that the version of the `setfont` command is `2.6rc1` or higher.
+> Versions prior to `2.6rc1` do not support fonts larger than 65535 (approximately 64KB).
+> After `2.6rc1`, the limit has been relaxed to 4194304 (approximately 4MB).
+>
+> Run `setfont -V` to check the version.
+
+Place `xibo.psfu.gz` in the `consolefonts` directory (located at `/usr/share/consolefonts/` on Debian and `/usr/share/kbd/consolefonts/` on Arch Linux), then execute `setfont xibo` to change the font or `setfont -d xibo` to switch to a double-sized font.
+
+## License
+
+> Thanks to the **WenQuanYi** team for providing the `WenQuanYi Bitmap Song v1.0.0-RC1 Hero` font.
+
+The script files `build.bash` and `build_font_from_bdf.py` in this repository are licensed under the [GNU GENERAL PUBLIC LICENSE Version 3](LICENSE).
+All reference files in the `original/references/` directory are licensed under the [Unlicense](original/references/LICENSE).
+The generated font files in this project are licensed under the [Free Chinese Font License and GNU GENERAL PUBLIC LICENSE Version 2](FONT-LICENSE).
+
+## Contributing
+
+Refer to the [Contribution Guide](CONTRIBUTING.md).

+ 4 - 65
README.md

@@ -1,9 +1,8 @@
 # ![演示](assets/display.png)
 
-## font-xibo
+> 简体中文 | [ENGLISH](README.en.md)
 
-<div style="display: flex; flex-direction: row; justify-content: space-between;">
-  <div>
+## font-xibo
 
 xibo 是一个为 Linux 设计的中文 TTY 字体,旨在在不安装诸如 [cjktty](https://github.com/zhmars/cjktty-patches) 等内核补丁且不安装 [kmscon](http://www.freedesktop.org/wiki/Software/kmscon)、[fbterm](https://salsa.debian.org/debian/fbterm) 或 [zhcon](https://zhcon.sourceforge.net/) 等第三方软件的环境下提供 TTY 中文显示。
 
@@ -53,6 +52,8 @@ xibo 是一个为 Linux 设计的中文 TTY 字体,旨在在不安装诸如 [c
 
 ## 许可协议
 
+> 感谢**文泉驿**团队提供的`文泉驿点阵宋体 v1.0.0-RC1 英雄`字体。
+
 本仓库中的脚本文件 `build.bash` 和 `build_font_from_bdf.py` 遵循 [GNU GENERAL PUBLIC LICENSE Version 3 许可协议](LICENSE),
 `original/references/` 目录下的所有参照文件遵循 [Unlicense 许可协议](original/references/LICENSE),
 本项目生成的字体文件遵循[自由中文字体和 GNU GENERAL PUBLIC LICENSE Version 2 许可协议](FONT-LICENSE)。
@@ -60,65 +61,3 @@ xibo 是一个为 Linux 设计的中文 TTY 字体,旨在在不安装诸如 [c
 ## 做出贡献
 
 请参照[贡献指北](CONTRIBUTING.md)。
-
-  </div>
-  <div>
-
-Xibo is a Chinese TTY font designed for Linux, aiming to provide Chinese display in TTY without installing kernel patches such as [cjktty](https://github.com/zhmars/cjktty-patches) or third-party software like [kmscon](http://www.freedesktop.org/wiki/Software/kmscon), [fbterm](https://salsa.debian.org/debian/fbterm), or [zhcon](https://zhcon.sourceforge.net/).
-
-The inspiration for this project comes from the [syllazh](https://github.com/oldherl/syllazh/) font.
-
-## Phonetic Characters
-
-When using this font, you may notice that characters with similar pronunciations are displayed as the same character. For example, any of the characters “用永勇拥擁涌湧咏詠蛹雍踊庸踴泳” will be uniformly displayed as “用”.
-
-This is because fonts on Linux TTY are generally changed using the `setfont` tool from the kbd package, which supports a maximum of 512 glyphs. However, a single glyph can map to multiple Unicode code points.
-Therefore, Xibo maps all characters with the same pronunciation (ignoring tones) to the same glyph, allowing for Chinese character display within the limited number of glyphs.
-
-## Building the Font
-
-1. Clone the repository:
-
-   ```shellscript
-   git clone https://github.com/PJ-568/font-xibo.git
-   cd font-xibo
-   ```
-
-2. Install dependencies:
-
-   ```shellscript
-   pip install -r requirements.txt
-   ```
-
-3. Build the font:
-
-   ```shellscript
-   bash build.bash
-   ```
-
-   During the build process, the script will install `psftools`, which is used to generate the font.
-
-After building, a PSF2 font file named `xibo.psfu.gz` will be generated in the `output/` directory.
-
-## Using the Font
-
-> Ensure that the version of the `setfont` command is `2.6rc1` or higher.
-> Versions prior to `2.6rc1` do not support fonts larger than 65535 (approximately 64KB).
-> After `2.6rc1`, the limit has been relaxed to 4194304 (approximately 4MB).
->
-> Run `setfont -V` to check the version.
-
-Place `xibo.psfu.gz` in the `consolefonts` directory (located at `/usr/share/consolefonts/` on Debian and `/usr/share/kbd/consolefonts/` on Arch Linux), then execute `setfont xibo` to change the font or `setfont -d xibo` to switch to a double-sized font.
-
-## License
-
-The script files `build.bash` and `build_font_from_bdf.py` in this repository are licensed under the [GNU GENERAL PUBLIC LICENSE Version 3](LICENSE).
-All reference files in the `original/references/` directory are licensed under the [Unlicense](original/references/LICENSE).
-The generated font files in this project are licensed under the [Free Chinese Font License and GNU GENERAL PUBLIC LICENSE Version 2](FONT-LICENSE).
-
-## Contributing
-
-Refer to the [Contribution Guide](CONTRIBUTING.md).
-
-  </div>
-</div>

+ 1 - 0
VERSION

@@ -0,0 +1 @@
+0.1.0

+ 14 - 10
build.bash

@@ -26,18 +26,21 @@ Length: 512
 Width: {width}
 Height: {height}''', end='')
 
-def PrintNonChineseCharacter():
+def PrintNonChineseCharacter(index):
+    count = index
     # 输出空格
-    PrintCharacters('               ')
+    PrintCharacters('               ', count)
+    count += 1
 
     # 打开包含其他字符的参考文件
     with open("original/references/other_characters", encoding="utf-8") as f:
         for lines in f:
             line = lines.split()
-            PrintCharacters(line[0])
+            PrintCharacters(line[0], count)
+            count += 1
+    return count
 
-def PrintCharacters(Characters):
-    global count
+def PrintCharacters(Characters, count):
     Character = Characters[0]
     try:
         # 将汉字编码为对应编码
@@ -52,7 +55,6 @@ def PrintCharacters(Characters):
 
         print("\n%")
         print("//", count, Character)
-        count += 1
 
         # 打印字形的位图表示
         print("Bitmap: ", end="")
@@ -81,20 +83,22 @@ def PrintCharacters(Characters):
             if h == "#":
                 break
             print("[{0:08x}];".format(ord(h)), end="")
-        
-        if count == 32:
-            PrintNonChineseCharacter()
+
     except UnicodeError:
         # 捕获并处理 Unicode 错误
         pass
 
 # 打开包含拼音和对应汉字的参考文件
 with open("original/references/pinyin_hanzi", encoding="utf-8") as f:
+    count = 0
     for line in f:
+        if count == 32:
+            count = PrintNonChineseCharacter(count)
         # 跳过注释行
         if line.startswith("#"):
             continue
         s = line.split()
         if len(s) >= 2:
             hanzis = s[1]
-            PrintCharacters(hanzis)
+            PrintCharacters(hanzis, count)
+            count += 1

+ 1 - 1
original/references/pinyin_hanzi

@@ -94,7 +94,7 @@ fang 放方防房访訪仿芳坊纺紡妨匚肪鲂魴舫钫鈁昉邡牥汸趽鰟
 fei 非飞飛费費废廢肺肥沸菲匪镄鐨吠妃绯緋诽誹扉斐啡霏榧蜚腓紼芾翡砩淝痱鲱鯡屝篚悱棐婓廃朏狒癈飝騑蕡櫠柹剕蕜厞笰暃馡婔胐蜰曊胏靟奜陫裶萉昲鼣俷餥渄橨濷猆騛靅䑔䕁㥱㩌䠊䉬䰁䨽䨾䆏䕠䚨䛍䤵疿㫵䩁㐟
 fen 分粉坟墳纷焚紛份粪糞芬奋奮酚愤憤氛汾吩偾僨忿瀵衯雰濆棼瞓鲼鱝棻枌帉蒶錀昐蚡鼢豶葐豮朆饙燓羵坆翂妢轒膹弅鈖幩餴魵兝兺馚黂梤躮羒鼖隫秎竕哛蚠黺馩㖹䴅㥹㿎㤋䭻㷊㸮䩿䯨䫞㬟
 feng 风風封逢奉缝縫冯馮凤鳳疯瘋峰峯丰豐蜂枫锋鋒鵬讽諷俸烽酆葑砜碸鎽豊沣灃唪鳯沨偑綘夆覂闏赗捀賵寷蠭仹凨鄷凮溄犎鏠凬崶浲堼摓篈蘴煈湗琒桻堸妦靊盽檒舽莑飌炐鴌猦麷僼艂焨霻㐽㠦㛔㦀㵯䀱㷭䒠㜂䏎䙜䩼㡝㒥
-fiao 覅
+# fiao 覅
 fo 佛仏仸坲梻
 fou 否缶紑炰垺妚缹缻鴀雬䳕㓡
 fu 副赴附复復複负負付彿服赋賦富扶父福浮覆敷伏腹夫符抚撫府弗辅輔甫拂傅缚縛妇婦氟俯幅斧腐肤膚釜阜孵讣訃俘呒嘸鍑凫鳧鳬腑辐輻咐孚馥绂紱芙趺脯跗拊罘芣蝠阝绋菔鲋鮒祓涪麸祔麩黼茯蝮桴蚨呋匐袱鍢苻赙簠賻滏乀蜉巿莩俛綍錇鄜郛黻冨怫幞褔驸洑箙駙鳆茀鰒粰鈇稃袝捊椨虙襆怤蝜泭紨咈鵩坿柎栿姇偩沕頫胕豧艴旉綒刜棴甶諨韨琈抙釡韍鬴荂葍痡邚筟襥乶砆圑俌癁邞澓罦蕧烰纀璷衭岪郍禣玞弣郙媍酻緮枎蚹荴鳺盙峊鉘柫嬔絥鴔稪妋懯椱汱髴垘蚥陚蓲玸軵撨炥艀鮄蜅酜娐糐蛗哹鉜焤詂畉鮲覄竎颫麱麬翇䓛㕮䩉㳇䘠䔰㐢㚆㵗㽬䎅䨱䃽䕎㙏㬼䧞㭪䱐㜑䌿䑧䞞䵾䋨㾈䘀䝾䠵䦣䯱䞤㕊䄮䴸䋹伕㟊㠅㤔㪄㫙䍖䡍䨗䪙䌗䗄䫍䫝䂤䒇䘄䞜䞯䞸䭸䮛㩤㲗䃿䎔䓏䓵

+ 51 - 0
scripts/is-newer-version.bash

@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+# 判断是否需要发行新版本 | Checking for a Newer Version
+
+# 设置定量 | Quantities
+## 当前脚本所在目录 | Current Script Directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+## 仓库目录 | Repository Directory
+REPO_DIR="$(dirname "$SCRIPT_DIR")"
+## 当前语言 | Current Language
+CURRENT_LANG=0 ### 0: en-US, 1: zh-Hans-CN
+
+# 语言检测 | Language Detection
+if [ $(echo ${LANG/_/-} | grep -Ei "\b(zh|cn)\b") ]; then CURRENT_LANG=1;  fi
+
+# 本地化 | Localization
+recho() {
+  if [ "$CURRENT_LANG" == "1" ]; then
+    ## zh-Hans-CN
+    echo "$1";
+  else
+    ## en-US
+    echo "$2";
+  fi
+}
+
+# 获取当前版本号 | Get current version number
+CURRENT_VERSION=$(cat "$REPO_DIR/VERSION")
+if [ -z "$CURRENT_VERSION" ]; then
+  recho "错误:无法从 VERSION 获取版本号" "Error: Cannot get version from VERSION"
+  exit 1
+fi
+
+# 获取最新的 git 标签版本 | Get the latest git tag version
+LATEST_TAG=$(git -C "$REPO_DIR" tag -l 'v*' --sort=-v:refname | head -1)
+if [ -z "$LATEST_TAG" ]; then
+  # 没有标签时默认为需要发布 | No tags, assume it needs to be released
+  echo "$CURRENT_VERSION"
+  exit 0
+fi
+
+# 去除标签中的 v 前缀 | Remove the v prefix from the tag
+LATEST_VERSION=${LATEST_TAG#v}
+
+# 比较版本号 | Compare version numbers
+if [ "$(printf "%s\n%s" "$CURRENT_VERSION" "$LATEST_VERSION" | sort -V | head -n1)" != "$CURRENT_VERSION" ]; then
+  # 当前版本较新,需要发布 | The current version is newer, needs to be released
+  echo "$CURRENT_VERSION"
+else
+  # 已经是最新版本 | Already the latest version
+  echo "0"
+fi