-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (165 loc) · 6.39 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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