mirror of
https://github.com/d0zingcat/rime_wanxiang.git
synced 2026-05-13 15:10:03 +00:00
chore:新的根节点
This commit is contained in:
36
.github/workflows/release-build.yml
vendored
Normal file
36
.github/workflows/release-build.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Wanxiang Schema Builds
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
tag:
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
release-build:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Release build
|
||||
run: bash .github/workflows/scripts/release-build.sh
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rime-wanxiang-dist-${{ github.ref_name }}
|
||||
if-no-files-found: error
|
||||
path: dist/rime-wanxiang-*.zip
|
||||
73
.github/workflows/release.yml
vendored
Normal file
73
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- wanxiang
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
name: Release
|
||||
|
||||
jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: googleapis/release-please-action@v4
|
||||
id: release
|
||||
|
||||
- name: Checkout repository
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Release edit to draft
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
run: |
|
||||
gh release edit ${TAG_VERSION} --draft
|
||||
env:
|
||||
TAG_VERSION: ${{ steps.release.outputs.tag_name }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
outputs:
|
||||
release_created: ${{ steps.release.outputs.release_created }}
|
||||
release_tag_name: ${{ steps.release.outputs.tag_name }}
|
||||
|
||||
release-build:
|
||||
needs: [release-please]
|
||||
if: needs.release-please.outputs.release_created == 'true'
|
||||
name: Release build
|
||||
uses: ./.github/workflows/release-build.yml
|
||||
permissions:
|
||||
contents: write
|
||||
secrets: inherit
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: [release-please, release-build]
|
||||
name: Release
|
||||
env:
|
||||
TAG_VERSION: ${{ needs.release-please.outputs.release_tag_name }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download build
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: rime-wanxiang-dist-${{ github.ref_name }}
|
||||
path: ~/artifact
|
||||
|
||||
- name: Update release
|
||||
run: |
|
||||
# 更新 release title
|
||||
gh release edit ${TAG_VERSION} --title "${TAG_VERSION} Rime万象拼音输入方案"
|
||||
# 更新 release note
|
||||
bash .github/workflows/scripts/generate-release-note.sh
|
||||
gh release edit ${TAG_VERSION} --notes-file ./release_notes.md
|
||||
# 更新 Assets
|
||||
gh release upload ${TAG_VERSION} ~/artifact/rime-wanxiang-*.zip
|
||||
# 正式发布
|
||||
gh release edit ${TAG_VERSION} --draft=false --latest
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
295
.github/workflows/releases-napshot.yml
vendored
Normal file
295
.github/workflows/releases-napshot.yml
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
name: Build release branch snapshot
|
||||
|
||||
on:
|
||||
workflow_dispatch: # 手动触发
|
||||
push:
|
||||
branches:
|
||||
- wanxiang
|
||||
|
||||
concurrency:
|
||||
group: release-branch
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-release:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Release build
|
||||
run: bash .github/workflows/scripts/release-build.sh
|
||||
|
||||
# 1. 用 dist/ 里的产物拼出 snapshot 目录
|
||||
- name: Prepare snapshot tree from dist
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
rm -rf snapshot
|
||||
mkdir -p snapshot
|
||||
|
||||
# 使用 dist/ 里的目录构建 snapshot
|
||||
if ls dist/rime-wanxiang-* 1> /dev/null 2>&1; then
|
||||
for d in dist/rime-wanxiang-*; do
|
||||
[ -d "$d" ] || continue
|
||||
name="$(basename "$d")"
|
||||
echo "Copying directory $d -> snapshot/$name"
|
||||
mkdir -p "snapshot/$name"
|
||||
cp -a "$d"/. "snapshot/$name"/
|
||||
done
|
||||
else
|
||||
echo "Error: no dist/rime-wanxiang-* directories found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Snapshot tree after prepare:"
|
||||
ls -R snapshot || true
|
||||
|
||||
# 2. 检查这次提交是否修改了 dicts 相关文件(控制 3/4/5 是否执行)
|
||||
- name: Check if dicts changed
|
||||
id: dicts_changed
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# 手动触发(workflow_dispatch)直接视为「有变动」,强制跑
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 找到上一条提交(第一次提交可能没有 HEAD^,单独处理)
|
||||
if git rev-parse HEAD^ >/dev/null 2>&1; then
|
||||
RANGE="HEAD^ HEAD"
|
||||
else
|
||||
echo "Only one commit, treat as changed."
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 检查本次改动的文件里有没有命中 dicts 目录
|
||||
if git diff --name-only $RANGE | grep -E '(^dicts/|^rime-wanxiang-.*/dicts/)' >/dev/null 2>&1; then
|
||||
echo "dicts changed."
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "dicts not changed."
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# 3. 从 dist 中打出每夜词库 zip(不套文件夹,只打 dicts/**)
|
||||
- name: Pack nightly dict zips
|
||||
if: steps.dicts_changed.outputs.changed == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
mkdir -p dist
|
||||
|
||||
pack_dict() {
|
||||
local src="$1"
|
||||
local zip_name="$2"
|
||||
if [[ -d "$src" ]]; then
|
||||
echo "Packing $src -> dist/${zip_name}"
|
||||
(cd "$src" && zip -r -q "../../${zip_name}" .)
|
||||
else
|
||||
echo "Warning: $src does not exist, skipped."
|
||||
fi
|
||||
}
|
||||
|
||||
pack_dict "dist/rime-wanxiang-moqi-fuzhu/dicts" "pro-moqi-fuzhu-dicts.zip"
|
||||
pack_dict "dist/rime-wanxiang-flypy-fuzhu/dicts" "pro-flypy-fuzhu-dicts.zip"
|
||||
pack_dict "dist/rime-wanxiang-zrm-fuzhu/dicts" "pro-zrm-fuzhu-dicts.zip"
|
||||
pack_dict "dist/rime-wanxiang-tiger-fuzhu/dicts" "pro-tiger-fuzhu-dicts.zip"
|
||||
pack_dict "dist/rime-wanxiang-wubi-fuzhu/dicts" "pro-wubi-fuzhu-dicts.zip"
|
||||
pack_dict "dist/rime-wanxiang-hanxin-fuzhu/dicts" "pro-hanxin-fuzhu-dicts.zip"
|
||||
pack_dict "dist/rime-wanxiang-shouyou-fuzhu/dicts" "pro-shouyou-fuzhu-dicts.zip"
|
||||
pack_dict "dist/rime-wanxiang-base/dicts" "base-dicts.zip"
|
||||
|
||||
echo "Nightly dict zips in dist/:"
|
||||
ls -1 dist/*.zip || true
|
||||
|
||||
# 4. 删除旧的 Nightly Release 和 Tag
|
||||
- name: Delete existing Nightly Release and Tag
|
||||
if: steps.dicts_changed.outputs.changed == 'true'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const tag = "dict-nightly";
|
||||
try {
|
||||
const releases = await github.rest.repos.listReleases({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo
|
||||
});
|
||||
const existingRelease = releases.data.find(r => r.tag_name === tag);
|
||||
if (existingRelease) {
|
||||
console.log(`Deleting existing Release with ID: ${existingRelease.id}`);
|
||||
await github.rest.repos.deleteRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
release_id: existingRelease.id
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`Deleting tag: ${tag}`);
|
||||
await github.rest.git.deleteRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `tags/${tag}`
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(`Error deleting Release or Tag: ${error.message}`);
|
||||
}
|
||||
|
||||
- name: Wait for cleanup
|
||||
if: steps.dicts_changed.outputs.changed == 'true'
|
||||
run: sleep 10
|
||||
|
||||
# 5. 创建新的 Nightly Release,上传词库 zips
|
||||
- name: Create dict-nightly Release
|
||||
if: steps.dicts_changed.outputs.changed == 'true'
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag_name: dict-nightly
|
||||
name: "实时提交的词库更新"
|
||||
body: |
|
||||
- **base-dicts.zip**:最新的标准版原始中文词库文件
|
||||
- **pro-moqi-fuzhu-dicts.zip**:携带了墨奇辅助码的词库文件
|
||||
- **pro-flypy-fuzhu-dicts.zip**:携带了小鹤辅助码的词库文件
|
||||
- **pro-zrm-fuzhu-dicts.zip**:携带了自然码辅助码的词库文件
|
||||
- **pro-tiger-fuzhu-dicts.zip**:携带了虎码辅助码的词库文件
|
||||
- **pro-wubi-fuzhu-dicts.zip**:携带了五笔辅助码的词库文件
|
||||
- **pro-hanxin-fuzhu-dicts.zip**:携带了汉心辅助码的词库文件
|
||||
- **pro-shouyou-fuzhu-dicts.zip**:携带了首右辅助码的词库文件
|
||||
- **[wanxiang-lts-zh-hans.gram](https://github.com/amzxyz/RIME-LMDG/releases/download/LTS/wanxiang-lts-zh-hans.gram)**:与词库同步更新的语法模型
|
||||
files: |
|
||||
dist/pro-moqi-fuzhu-dicts.zip
|
||||
dist/pro-flypy-fuzhu-dicts.zip
|
||||
dist/pro-zrm-fuzhu-dicts.zip
|
||||
dist/pro-tiger-fuzhu-dicts.zip
|
||||
dist/pro-wubi-fuzhu-dicts.zip
|
||||
dist/pro-hanxin-fuzhu-dicts.zip
|
||||
dist/pro-shouyou-fuzhu-dicts.zip
|
||||
dist/base-dicts.zip
|
||||
draft: false
|
||||
prerelease: false
|
||||
make_latest: true
|
||||
|
||||
# 6. 为每个方案生成独立分支:wanxiang-base / wanxiang-moqi-fuzhu / ...
|
||||
- name: Commit and force push per-scheme snapshots
|
||||
env:
|
||||
GIT_AUTHOR_NAME: ci-bot
|
||||
GIT_AUTHOR_EMAIL: ci@example.com
|
||||
GIT_COMMITTER_NAME: ci-bot
|
||||
GIT_COMMITTER_EMAIL: ci@example.com
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# 当前开发分支(通常是 wanxiang)
|
||||
ORIG_BRANCH="$(git rev-parse --abbrev-ref HEAD || echo 'wanxiang')"
|
||||
|
||||
# 方案列表
|
||||
schemes=("base" "shouyou-fuzhu" "zrm-fuzhu" "tiger-fuzhu" "moqi-fuzhu" "flypy-fuzhu" "wubi-fuzhu" "hanxin-fuzhu")
|
||||
|
||||
# 每个方案公共文件清单(在分支根目录使用)
|
||||
COMMON_FILES=(
|
||||
"dicts/*.*"
|
||||
"opencc/*.*"
|
||||
"custom/*.*"
|
||||
"lua/*.*"
|
||||
"lua/lib/*.*"
|
||||
"lua/tips/*.*"
|
||||
"default.yaml"
|
||||
"weasel.yaml"
|
||||
"wanxiang*.*yaml"
|
||||
"README.md"
|
||||
"简纯+.trime.yaml"
|
||||
"custom_phrase.txt"
|
||||
)
|
||||
|
||||
TAG_NAME="${{ github.event_name == 'release' && github.event.release.tag_name || 'manual-build' }}"
|
||||
|
||||
for scheme in "${schemes[@]}"; do
|
||||
branch="wanxiang-${scheme}" # 分支名:wanxiang-moqi-fuzhu
|
||||
src_dir="snapshot/rime-wanxiang-${scheme}" # 每个方案的源码目录(来自 snapshot)
|
||||
|
||||
echo "=== Building branch ${branch} from ${src_dir} ==="
|
||||
|
||||
if [ ! -d "${src_dir}" ]; then
|
||||
echo "Warning: ${src_dir} not found, skip ${branch}."
|
||||
continue
|
||||
fi
|
||||
|
||||
# 切换/创建分支
|
||||
if git show-ref --verify --quiet "refs/heads/${branch}"; then
|
||||
git checkout "${branch}"
|
||||
else
|
||||
git checkout --orphan "${branch}"
|
||||
fi
|
||||
|
||||
# 清空当前工作区(仅保留 .git 和 snapshot)
|
||||
find . -mindepth 1 -maxdepth 1 ! -name ".git" ! -name "snapshot" -exec rm -rf {} +
|
||||
|
||||
# 把这个方案的内容「拍扁」到分支根目录(不保留 rime-wanxiang-xxx 那一层)
|
||||
cp -a "${src_dir}"/. .
|
||||
|
||||
# 在这个分支里生成自己的 plum 配方
|
||||
mkdir -p plum
|
||||
|
||||
#################################
|
||||
# 生成 plum/full.recipe.yaml
|
||||
#################################
|
||||
{
|
||||
echo "# encoding: utf-8"
|
||||
echo "---"
|
||||
echo "recipe:"
|
||||
echo " Rx: plum/full"
|
||||
echo " args:"
|
||||
echo " description: >-"
|
||||
echo " 万象拼音 ${scheme} 版(整个方案目录)- 分支 ${branch}"
|
||||
echo "install_files: >-"
|
||||
for path in "${COMMON_FILES[@]}"; do
|
||||
echo " ${path}"
|
||||
done
|
||||
} > "plum/full.recipe.yaml"
|
||||
|
||||
#################################
|
||||
# 生成 plum/dicts.recipe.yaml
|
||||
#################################
|
||||
{
|
||||
echo "# encoding: utf-8"
|
||||
echo "---"
|
||||
echo "recipe:"
|
||||
echo " Rx: plum/dicts"
|
||||
echo " args:"
|
||||
echo " description: >-"
|
||||
echo " 万象拼音 ${scheme} 版,仅词库(dicts-only)- 分支 ${branch}"
|
||||
echo "install_files: >-"
|
||||
echo " dicts/*.*"
|
||||
} > "plum/dicts.recipe.yaml"
|
||||
|
||||
git status
|
||||
|
||||
# 注意:不要把 snapshot/ 提交进去
|
||||
git add .
|
||||
git reset snapshot || true
|
||||
git rm -r --cached snapshot 2>/dev/null || true
|
||||
|
||||
git commit -m "chore(${branch}): snapshot for ${TAG_NAME}" \
|
||||
|| echo "Nothing to commit for ${branch}."
|
||||
|
||||
git push -f origin "${branch}"
|
||||
done
|
||||
|
||||
# 回到原来的开发分支,并清掉 snapshot(只删 CI 本地)
|
||||
git checkout "${ORIG_BRANCH}" || true
|
||||
rm -rf snapshot
|
||||
197
.github/workflows/scripts/aux_go.py
vendored
Normal file
197
.github/workflows/scripts/aux_go.py
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
# ---------- 在第一个点前插入后缀(例:base.dict.yaml -> base.pro.dict.yaml) ----------
|
||||
def add_suffix_before_extensions(filename: str, suffix: str) -> str:
|
||||
if not suffix:
|
||||
return filename
|
||||
i = filename.find('.')
|
||||
return (filename + suffix) if i == -1 else (filename[:i] + suffix + filename[i:])
|
||||
|
||||
# ========== 1) 从“单个 aux 文件”加载 字 -> 辅助码段列表 ==========
|
||||
# 行格式:字<TAB>;段1;段2;... (保留空段,不偏移;段内逗号原样保留)
|
||||
def load_aux_table(aux_file_path):
|
||||
if not os.path.isfile(aux_file_path):
|
||||
raise FileNotFoundError(f"aux 文件不存在:{aux_file_path}")
|
||||
aux_map = {}
|
||||
print(f'加载辅助码表文件: {os.path.basename(aux_file_path)}')
|
||||
with open(aux_file_path, 'r', encoding='utf-8') as f:
|
||||
for raw in f:
|
||||
line = raw.strip()
|
||||
if not line or line.startswith('#'):
|
||||
continue
|
||||
parts = line.split('\t')
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
ch = parts[0]
|
||||
aux_list = parts[1].split(';') # 保留空串占位(分号才是边界)
|
||||
aux_map[ch] = aux_list
|
||||
return aux_map
|
||||
|
||||
# ========== 2) 区间选择(严格:第 N 段 = aux_list[N];N 从 1 起)==========
|
||||
# 不处理逗号:分号窗口原样拼接
|
||||
def select_aux_segment(aux_list, start_idx, end_idx=None):
|
||||
if not aux_list:
|
||||
return ''
|
||||
s = max(1, start_idx)
|
||||
e = end_idx if end_idx is not None else len(aux_list)
|
||||
e = max(s, min(e, len(aux_list)))
|
||||
window = aux_list[s:e] # 允许空段
|
||||
return ''.join(window) if window else ''
|
||||
|
||||
DIGIT_RE = re.compile(r'^\d+$')
|
||||
|
||||
# ========== 3) 处理单个词库(流式;空也占位“拼音;”)==========
|
||||
def process_file_for_range_streaming(in_file, out_file, aux_map, start_idx, end_idx, sep=';'):
|
||||
os.makedirs(os.path.dirname(out_file), exist_ok=True)
|
||||
try:
|
||||
fin = open(in_file, 'r', encoding='utf-8')
|
||||
except Exception as e:
|
||||
print(f'读取失败 {in_file}: {e}')
|
||||
return
|
||||
try:
|
||||
fout = open(out_file, 'w', encoding='utf-8')
|
||||
except Exception as e:
|
||||
fin.close()
|
||||
print(f'写入失败 {out_file}: {e}')
|
||||
return
|
||||
|
||||
passthrough_set = {
|
||||
"的\td\t1000",
|
||||
"了\tl\t999",
|
||||
"吗\tm\t999",
|
||||
"吧\tb\t999",
|
||||
}
|
||||
|
||||
processing = False
|
||||
for line in fin:
|
||||
if not processing:
|
||||
fout.write(line)
|
||||
if '...' in line:
|
||||
processing = True
|
||||
continue
|
||||
|
||||
raw = line.rstrip('\n')
|
||||
if (not raw) or raw.lstrip().startswith('#'):
|
||||
fout.write(line)
|
||||
continue
|
||||
|
||||
parts = raw.split('\t')
|
||||
if len(parts) == 1:
|
||||
fout.write(line)
|
||||
continue
|
||||
|
||||
han = parts[0]
|
||||
col2 = parts[1] if len(parts) > 1 else ''
|
||||
col3 = parts[2] if len(parts) > 2 else ''
|
||||
col4 = parts[3] if len(parts) > 3 else ''
|
||||
|
||||
# 第二列若是频率(全数字),挪到第三列
|
||||
if DIGIT_RE.fullmatch(col2 or ''):
|
||||
col3, col2 = col2, ''
|
||||
|
||||
# 特定行直通
|
||||
if raw.strip() in passthrough_set:
|
||||
fout.write(raw + '\n')
|
||||
continue
|
||||
|
||||
pinyins = col2.split(' ') if col2 else []
|
||||
if len(pinyins) != len(han):
|
||||
warn = f"# 警告: 拼音数与字数不匹配({in_file}) => {raw}"
|
||||
print(warn)
|
||||
fout.write(warn + '\n')
|
||||
continue
|
||||
|
||||
_get = aux_map.get
|
||||
new_cols = []
|
||||
for i, ch in enumerate(han):
|
||||
aux_list = _get(ch)
|
||||
piece = select_aux_segment(aux_list, start_idx, end_idx) if aux_list is not None else ''
|
||||
new_cols.append(pinyins[i] + sep + piece) # 空也占位:拼音;片段
|
||||
|
||||
new_col2 = ' '.join(new_cols)
|
||||
if col4:
|
||||
fout.write(f"{han}\t{new_col2}\t{col3}\t{col4}\n" if col3 else f"{han}\t{new_col2}\t\t{col4}\n")
|
||||
else:
|
||||
fout.write(f"{han}\t{new_col2}\t{col3}\n" if col3 else f"{han}\t{new_col2}\n")
|
||||
|
||||
fin.close()
|
||||
fout.close()
|
||||
print(f'已处理: {out_file}')
|
||||
|
||||
# ========== 4) 扫目录 + 六套区间(按白名单)==========
|
||||
def process_batch(input_dir, aux_file_path, base_out_dir, index_mapping, files_whitelist=None,
|
||||
sep=';', output_suffix=""):
|
||||
aux_map = load_aux_table(aux_file_path)
|
||||
print(f'已加载辅助码条目:{len(aux_map)}')
|
||||
|
||||
# 收集要处理的文件
|
||||
to_process = []
|
||||
for entry in os.scandir(input_dir):
|
||||
if not entry.is_file():
|
||||
continue
|
||||
name = entry.name
|
||||
if files_whitelist and name not in files_whitelist:
|
||||
continue
|
||||
if not (name.endswith('.yaml') or name.endswith('.yml') or name.endswith('.txt')):
|
||||
continue
|
||||
to_process.append(entry.path)
|
||||
|
||||
if not to_process:
|
||||
print("输入目录内没有匹配文件")
|
||||
return
|
||||
|
||||
for s_idx, e_idx, subdir in index_mapping:
|
||||
out_dir = os.path.join(base_out_dir, subdir)
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
print(f'\n=== 区间 ({s_idx}, {e_idx}) → {subdir} ===')
|
||||
for in_file in to_process:
|
||||
fn = os.path.basename(in_file)
|
||||
out_name = add_suffix_before_extensions(fn, output_suffix)
|
||||
out_file = os.path.join(out_dir, out_name)
|
||||
process_file_for_range_streaming(in_file, out_file, aux_map, s_idx, e_idx, sep=sep)
|
||||
|
||||
# ========== 5) 入口 ==========
|
||||
if __name__ == '__main__':
|
||||
# 六套区间(第 N 段,从 1 起)
|
||||
index_mapping = [
|
||||
(1, 2, "pro-moqi-fuzhu-dicts"),
|
||||
(2, 3, "pro-flypy-fuzhu-dicts"),
|
||||
(3, 4, "pro-zrm-fuzhu-dicts"),
|
||||
(4, 5, "pro-tiger-fuzhu-dicts"),
|
||||
(5, 6, "pro-wubi-fuzhu-dicts"),
|
||||
(6, 7, "pro-hanxin-fuzhu-dicts"),
|
||||
(7, None, "pro-shouyou-fuzhu-dicts"),
|
||||
]
|
||||
|
||||
# 路径
|
||||
AUX_FILE = "custom/aux_code.txt" # ← 单个 aux 文件
|
||||
INPUT_DIR = "dicts" # ← 词库文件夹
|
||||
OUT_ROOT = "." # ← 输出根目录
|
||||
|
||||
# 仅处理这些文件
|
||||
FILES = [
|
||||
"jichu.dict.yaml",
|
||||
"zi.dict.yaml",
|
||||
"duoyin.dict.yaml",
|
||||
"cuoyin.dict.yaml",
|
||||
"diming.dict.yaml",
|
||||
"shici.dict.yaml",
|
||||
"lianxiang.dict.yaml",
|
||||
"renming.dict.yaml",
|
||||
"wuzhong.dict.yaml",
|
||||
"shuxue.dict.yaml",
|
||||
"dikuang.dict.yaml",
|
||||
"wu-hua-sheng-yi-yao.dict.yaml",
|
||||
]
|
||||
|
||||
# 输出文件在第一个点前插这个后缀(如 ".pro";设为空串则不加)
|
||||
OUTPUT_SUFFIX = ".pro"
|
||||
|
||||
process_batch(
|
||||
INPUT_DIR, AUX_FILE, OUT_ROOT,
|
||||
index_mapping,
|
||||
files_whitelist=FILES,
|
||||
sep=';',
|
||||
output_suffix=OUTPUT_SUFFIX
|
||||
)
|
||||
78
.github/workflows/scripts/generate-release-note.sh
vendored
Normal file
78
.github/workflows/scripts/generate-release-note.sh
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# 声明辅助码 zip 包类型显示名
|
||||
declare -A display_names=(
|
||||
[zrm]="自然码"
|
||||
[moqi]="墨奇"
|
||||
[flypy]="小鹤"
|
||||
[hanxin]="汉心"
|
||||
[wubi]="五笔前2"
|
||||
[tiger]="虎码首末"
|
||||
[shouyou]="首右"
|
||||
)
|
||||
|
||||
# 仓库和下载地址定义
|
||||
REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
|
||||
DOWNLOAD_URL=${REPO_URL}/releases/download/${TAG_VERSION}
|
||||
|
||||
# 获取 changelog(标题相同的 commit 合并链接)
|
||||
CHANGES=$(
|
||||
gh release view --json body -t "{{.body}}" "${TAG_VERSION}" | sed '1d; /./,$!d'
|
||||
)
|
||||
|
||||
{
|
||||
echo "## 📝 更新日志"
|
||||
echo ""
|
||||
echo "${CHANGES}"
|
||||
echo ""
|
||||
echo "## 🚀 下载引导"
|
||||
echo ""
|
||||
echo "### 1. 标准版输入方案"
|
||||
echo ""
|
||||
echo "✨**适用类型:** 支持全拼、各种双拼"
|
||||
echo ""
|
||||
echo "✨**下载地址:** [rime-wanxiang-base.zip](${DOWNLOAD_URL}/rime-wanxiang-base.zip)"
|
||||
echo ""
|
||||
echo "### 2. 双拼辅助码增强版输入方案"
|
||||
echo ""
|
||||
echo "✨**适用类型:** 支持各种双拼+辅助码的自由组合"
|
||||
|
||||
for type in "${!display_names[@]}"; do
|
||||
name="${display_names[$type]}"
|
||||
echo " - **${name}辅助版本:** [rime-wanxiang-${type}-fuzhu.zip](${DOWNLOAD_URL}/rime-wanxiang-${type}-fuzhu.zip)"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "### 3. 语法模型"
|
||||
echo ""
|
||||
echo "✨**适用类型:** 所有版本皆可用"
|
||||
echo ""
|
||||
echo "✨**下载地址:** [wanxiang-lts-zh-hans.gram](https://github.com/amzxyz/RIME-LMDG/releases/download/LTS/wanxiang-lts-zh-hans.gram)"
|
||||
echo ""
|
||||
echo "## 📘 使用说明(QQ群:11033572 参与讨论)"
|
||||
echo ""
|
||||
echo "1. **不使用辅助码的用户:**"
|
||||
echo ""
|
||||
echo " 请直接下载标准版,按仓库中的 [README.md](${REPO_URL}/blob/wanxiang/README.md) 配置使用。"
|
||||
echo ""
|
||||
echo "2. **使用增强版的用户:**"
|
||||
echo " - PRO 每一个 zip 是**完整独立配置包**,其差异仅在于词库是否带有特定辅助码。"
|
||||
echo ' - zrm 仅表示“词库中包含zrm辅助码”,并**不代表这是自然码双拼方案,万象支持任意双拼与任意辅助码组合使用**。'
|
||||
echo " - 若已有目标辅助码类型,只需下载对应 zip,解压后根据 README 中提示修改表头(例如双拼方案)即可使用。"
|
||||
echo ""
|
||||
echo "3. **语法模型需单独下载**,并放入输入法用户目录根目录(与方案文件放一起),**无需配置**。"
|
||||
echo ""
|
||||
echo "4. 💾 飞机盘下载地址(最快更新):[点击访问](https://share.feijipan.com/s/xiGvXdKz)"
|
||||
echo ""
|
||||
echo "5. Arch Linux 用户推荐 [启用 Arch Linux CN 仓库](https://www.archlinuxcn.org/archlinux-cn-repo-and-mirror/) 或通过 [AUR](https://aur.archlinux.org/pkgbase/rime-wanxiang),按需安装。"
|
||||
echo " - 基础版包名:\`rime-wanxiang-[拼写方案名]\`,如:自然码方案:\`rime-wanxiang-zrm\`"
|
||||
echo " - 双拼辅助码增强版包名:\`rime-wanxiang-pro-[拼写方案名]\`,如:自然码方案:\`rime-wanxiang-pro-zrm\`"
|
||||
echo "6. Deepin Linux v25 用户亦可以通过仓库进行安装。"
|
||||
echo "### 4. 周边推荐"
|
||||
echo " - [高度适配万象拼音的仓输入法皮肤](https://github.com/BlackCCCat/ResourceforHamster/tree/main/Skin_Keyboard/)"
|
||||
echo ""
|
||||
echo " - [好用的更新脚本,助你优雅管理版本](https://github.com/rimeinn/rime-wanxiang-update-tools)"
|
||||
echo ""
|
||||
echo " - [万象cnb仓库,无需梯子的类GitHub仓库国内平台](https://cnb.cool/amzxyz/rime-wanxiang)"
|
||||
} >release_notes.md
|
||||
152
.github/workflows/scripts/release-build.sh
vendored
Normal file
152
.github/workflows/scripts/release-build.sh
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
#!/bin/bash
|
||||
# 打包对用方案到 zip 文件,放到 dist 目录
|
||||
set -e
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/../../../" && pwd)"
|
||||
DIST_DIR="$ROOT_DIR/dist"
|
||||
CUSTOM_DIR="$ROOT_DIR/custom"
|
||||
|
||||
# 成成 PRO 分包文件
|
||||
echo "▶️ PRO 分包开始"
|
||||
python3 "$ROOT_DIR/.github/workflows/scripts/aux_go.py"
|
||||
echo "✅ PRO 分包完毕"
|
||||
echo
|
||||
|
||||
package_schema_base() {
|
||||
OUT_DIR=$1
|
||||
rm -rf "$OUT_DIR"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
# 1) custom/:仅拷贝 yaml/md/jpg/png,排除指定文件(保留目录结构)
|
||||
mkdir -p "$OUT_DIR/custom"
|
||||
rsync -av --prune-empty-dirs \
|
||||
--include='*/' \
|
||||
--exclude='wanxiang_chaifen_*.dict.yaml' \
|
||||
--exclude='wanxiang_chaifen.schema.yaml' \
|
||||
--exclude='wanxiang_pro.custom.yaml' \
|
||||
--exclude='wanxiang_pro.dict.yaml' \
|
||||
--exclude='wanxiang_pro.schema.yaml' \
|
||||
--include='*.yaml' --include='*.md' --include='*.jpg' --include='*.png' \
|
||||
--exclude='*' \
|
||||
"$CUSTOM_DIR/" "$OUT_DIR/custom/"
|
||||
|
||||
# 2) 根目录 → $OUT_DIR(不排 dicts/),排除若干
|
||||
OUT_BASE="$(basename "$OUT_DIR")"
|
||||
rsync -av --ignore-existing \
|
||||
--exclude='/.*' \
|
||||
--exclude='/dist/' \
|
||||
--exclude='/release-please-config.json' \
|
||||
--exclude='/pro-*-fuzhu-dicts' \
|
||||
--exclude='/chaifen' \
|
||||
--exclude='/CHANGELOG.md' \
|
||||
--exclude='/custom' \
|
||||
--exclude='/LICENSE' \
|
||||
--exclude="/$OUT_BASE" \
|
||||
"$ROOT_DIR/" "$OUT_DIR/"
|
||||
}
|
||||
|
||||
package_schema_pro() {
|
||||
SCHEMA_NAME="$1"
|
||||
OUT_DIR="$2"
|
||||
rm -rf "$OUT_DIR"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
# 1) 移动分包后的 dicts
|
||||
if [[ -d "$ROOT_DIR/pro-$SCHEMA_NAME-fuzhu-dicts" ]]; then
|
||||
mv "$ROOT_DIR/pro-$SCHEMA_NAME-fuzhu-dicts" "$OUT_DIR/dicts"
|
||||
fi
|
||||
# 1.1) 补充必要的附加文件
|
||||
for f in en.dict.yaml "cn&en.dict.yaml" chengyu.txt people.dict.yaml; do
|
||||
if [[ -f "$ROOT_DIR/dicts/$f" ]]; then
|
||||
cp "$ROOT_DIR/dicts/$f" "$OUT_DIR/dicts/"
|
||||
fi
|
||||
done
|
||||
|
||||
# 2) 复制拆分表并重命名,同时拷贝 schema
|
||||
src="$ROOT_DIR/custom/wanxiang_chaifen_${SCHEMA_NAME}.dict.yaml"
|
||||
dst="$OUT_DIR/wanxiang_chaifen.dict.yaml"
|
||||
[[ -f "$src" ]] && cp "$src" "$dst"
|
||||
|
||||
for f in \
|
||||
wanxiang_pro.dict.yaml \
|
||||
wanxiang_pro.schema.yaml \
|
||||
wanxiang_chaifen.schema.yaml
|
||||
do
|
||||
src="$ROOT_DIR/custom/$f"
|
||||
dst="$OUT_DIR/$f"
|
||||
[[ -f "$src" ]] && cp "$src" "$dst"
|
||||
done
|
||||
|
||||
# 3) custom/:仅拷贝 yaml/md/jpg/png,排除若干(保留目录结构)
|
||||
mkdir -p "$OUT_DIR/custom"
|
||||
rsync -av --prune-empty-dirs \
|
||||
--include='*/' \
|
||||
--exclude='wanxiang.custom*' \
|
||||
--exclude='wanxiang_chaifen_*.dict.yaml' \
|
||||
--exclude='wanxiang_chaifen.schema.yaml' \
|
||||
--exclude='wanxiang_pro.dict.yaml' \
|
||||
--exclude='wanxiang_pro.schema.yaml' \
|
||||
--include='*.yaml' --include='*.md' --include='*.jpg' --include='*.png' \
|
||||
--exclude='*' \
|
||||
"$ROOT_DIR/custom/" "$OUT_DIR/custom/"
|
||||
|
||||
# 4) 根目录 → $OUT_DIR(排除若干)
|
||||
OUT_BASE="$(basename "$OUT_DIR")"
|
||||
rsync -av --ignore-existing \
|
||||
--exclude='/.*' \
|
||||
--exclude='/dist/' \
|
||||
--exclude='/dicts' \
|
||||
--exclude='release-please-config.json' \
|
||||
--exclude='pro-*-fuzhu-dicts' \
|
||||
--exclude='wanxiang_t9.schema.yaml' \
|
||||
--exclude='CHANGELOG.md' \
|
||||
--exclude='wanxiang.dict.yaml' \
|
||||
--exclude='wanxiang.schema.yaml' \
|
||||
--exclude='custom' \
|
||||
--exclude='LICENSE' \
|
||||
--exclude="/$OUT_BASE" \
|
||||
"$ROOT_DIR/" "$OUT_DIR/"
|
||||
|
||||
# 5) default.yaml: - schema: wanxiang -> - schema: wanxiang_pro
|
||||
sed -i -E 's/^([[:space:]]*)-\s*schema:\s*wanxiang\s*$/\1- schema: wanxiang_pro/' "$OUT_DIR/default.yaml"
|
||||
}
|
||||
|
||||
|
||||
|
||||
package_schema() {
|
||||
SCHEMA_NAME="$1"
|
||||
echo "▶️ 开始打包方案:$SCHEMA_NAME"
|
||||
|
||||
if [[ "$SCHEMA_NAME" == "base" ]]; then
|
||||
OUT_DIR="$DIST_DIR/rime-wanxiang-base"
|
||||
package_schema_base "$OUT_DIR"
|
||||
|
||||
ZIP_NAME=rime-wanxiang-"$SCHEMA_NAME".zip
|
||||
else
|
||||
OUT_DIR="$DIST_DIR/rime-wanxiang-$SCHEMA_NAME-fuzhu"
|
||||
package_schema_pro "$SCHEMA_NAME" "$OUT_DIR"
|
||||
|
||||
fi
|
||||
|
||||
ZIP_NAME=$(basename "$OUT_DIR").zip
|
||||
(cd "$OUT_DIR" && zip -r -9 -q ../"$ZIP_NAME" . && cd ..)
|
||||
echo "✅ 完成打包: $ZIP_NAME"
|
||||
echo
|
||||
}
|
||||
|
||||
SCHEMA_LIST=("base" "flypy" "hanxin" "moqi" "tiger" "wubi" "zrm" "shouyou")
|
||||
|
||||
# 如果没有传入参数,则循环 package 所有的
|
||||
if [[ -z "$SCHEMA_NAME" ]]; then
|
||||
for name in "${SCHEMA_LIST[@]}"; do
|
||||
package_schema "$name"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! " ${SCHEMA_LIST[*]} " =~ ${SCHEMA_NAME} ]]; then
|
||||
echo "参数错误: 只支持 ${SCHEMA_LIST[*]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package_schema "$SCHEMA_NAME"
|
||||
Reference in New Issue
Block a user