update #683
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Rime Configs | |
on: | |
push: | |
branches: | |
- master | |
- dev | |
tags: | |
- 'v*' | |
jobs: | |
sanity-check: | |
name: Dictionary Sanity Check 🧐 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Sanity Check 📄️ | |
run: | | |
bash scripts/sanity_check.sh | |
prepare-schemas: | |
name: Prepare Schemas 🖨️ | |
runs-on: ubuntu-latest | |
needs: sanity-check | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Clear Cache ❌ | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh extension install actions/gh-actions-cache | |
gh actions-cache delete ${{ runner.os }}-schemas --confirm | |
continue-on-error: true | |
- name: Install Dependencies ⚙️ | |
run: sudo apt-get install -y opencc | |
- name: Fetch Schemas 📥 | |
run: | | |
bash scripts/fetch.sh --setver ${{ github.ref_name }} | |
- name: Cache Schemas 💾 | |
uses: actions/cache/save@v4 | |
if: always() | |
with: | |
path: | | |
schemas | |
xiaoxiao | |
key: ${{ runner.os }}-schemas | |
build-package: | |
strategy: | |
matrix: | |
target: [ weasel, hamster, irime, squirrel, rabbit ] | |
include: | |
- { target: weasel, name: Weasel, emoji: 🦡 } | |
- { target: hamster, name: Hamster, emoji: 🐹 } | |
- { target: irime, name: iRime, emoji: ℹ️ } | |
- { target: squirrel, name: Squirrel, emoji: 🐿️ } | |
- { target: rabbit, name: Rabbit, emoji: 🐇️ } | |
- { target: yong, name: xiaoxiao, emoji: ☯️ } | |
name: Build Package for ${{ matrix.name }} ${{ matrix.emoji }} | |
runs-on: ubuntu-latest | |
needs: prepare-schemas | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Cache Schemas 💾 | |
id: cache-schemas | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
schemas | |
xiaoxiao | |
key: ${{ runner.os }}-schemas | |
- name: Check Schema Cache ✔️ | |
if: steps.cache-schemas.outputs.cache-hit != 'true' | |
uses: actions/github-script@v7 | |
with: | |
script: core.setFailed('Cached schemas not found!') | |
- name: Prepare User Settings for Weasel 🦡 | |
if: ${{ matrix.target == 'weasel' }} | |
run: | | |
cp -r schemas/* ${{ matrix.target }}/ && \ | |
cp lua/* ${{ matrix.target }}/lua/ && \ | |
echo "prepare for ${{ matrix.target }} done." | |
- name: Prepare User Settings for Hamster 🐹 | |
if: ${{ matrix.target == 'hamster' }} | |
run: | | |
mkdir -p ${{ matrix.target }}/lua ${{ matrix.target }}/opencc && \ | |
cp schemas/jiandao.* schemas/pinyin_simp.* ${{ matrix.target }}/ && \ | |
cp -r schemas/lua/* lua/* ${{ matrix.target }}/lua/ && \ | |
cp schemas/opencc/emoji_plus.* schemas/opencc/s2*.json schemas/opencc/S* opencc/* ${{ matrix.target }}/opencc/ && \ | |
echo "prepare for ${{ matrix.target }} done." | |
- name: Prepare User Settings for iRime ℹ️ | |
if: ${{ matrix.target == 'irime' }} | |
run: | | |
mkdir -p ${{ matrix.target }}/lua ${{ matrix.target }}/opencc && \ | |
cp schemas/jiandao.* ${{ matrix.target }}/ && \ | |
cp -r schemas/lua/* lua/* ${{ matrix.target }}/lua/ && \ | |
cp schemas/opencc/emoji_plus.* schemas/opencc/s2*.json schemas/opencc/S* opencc/* ${{ matrix.target }}/opencc/ && \ | |
echo "prepare for ${{ matrix.target }} done." | |
- name: Prepare User Settings for Squirrel 🐿️ | |
if: ${{ matrix.target == 'squirrel' }} | |
run: | | |
mkdir -p ${{ matrix.target }}/lua ${{ matrix.target }}/opencc && \ | |
cp -r schemas/* ${{ matrix.target }}/ && \ | |
cp lua/* ${{ matrix.target }}/lua/ && \ | |
echo "prepare for ${{ matrix.target }} done." | |
- name: Prepare User Settings for Rabbit 🐇️ | |
if: ${{ matrix.target == 'rabbit' }} | |
run: | | |
mkdir -p ${{ matrix.target }}/lua ${{ matrix.target }}/opencc && \ | |
cp -r schemas/jiandao.base.dict.yaml ${{ matrix.target }}/ && \ | |
cp lua/* ${{ matrix.target }}/lua/ && \ | |
cp schemas/opencc/emoji_plus.* schemas/opencc/s2m.json schemas/opencc/SM* opencc/* ${{ matrix.target }}/opencc/ && \ | |
echo "prepare for ${{ matrix.target }} done." | |
- name: Prepare User Settings for Yong ☯️ | |
if: ${{ matrix.target == 'yong' }} | |
run: | | |
mkdir ${{ matrix.target }} && \ | |
cp -r xiaoxiao/* ${{ matrix.target }}/ && \ | |
echo "prepare for ${{ matrix.target }} done." | |
- name: Make Zip Archive 🗄️ | |
run: | | |
cd ${{ matrix.target }} | |
zip -r -q ../${{ matrix.target }}.zip * | |
- name: Upload Artifact 📤 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }}.zip | |
path: ${{ matrix.target }}.zip | |
create-release: | |
name: Create Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: prepare-schemas | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Create Release 🚀 | |
uses: softprops/action-gh-release@v2 | |
upload-assets: | |
strategy: | |
matrix: | |
target: [ weasel, hamster, irime, squirrel ] | |
include: | |
- { target: weasel, name: Weasel, emoji: 🦡 } | |
- { target: hamster, name: Hamster, emoji: 🐹 } | |
- { target: irime, name: iRime, emoji: ℹ️ } | |
- { target: squirrel, name: Squirrel, emoji: 🐿️ } | |
- { target: rabbit, name: Rabbit, emoji: 🐇️ } | |
- { target: yong, name: xiaoxiao, emoji: ☯️ } | |
name: Upload Assets of ${{ matrix.name }} ${{ matrix.emoji }} | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: [ build-package, create-release ] | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Download Artifacts of ${{ matrix.name }} ${{ matrix.emoji }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.target }}.zip | |
- name: Rename Release Zip Archives 🗃️ | |
run: mv ${{ matrix.target }}.zip ${{ matrix.target }}-${{ github.ref_name }}.zip | |
- name: Upload Assets 🚀 | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ${{ matrix.target }}-${{ github.ref_name }}.zip |