-
Notifications
You must be signed in to change notification settings - Fork 3
206 lines (185 loc) · 6.61 KB
/
ci.yaml
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Continuous Integration
on:
workflow_dispatch:
push:
branches:
- master
- dev
tags:
- 'v*'
jobs:
prepare-autohotkey-binaries:
name: Prepare AutoHotkey Binaries
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch AutoHotkey
run: |
$AhkVer = Invoke-RestMethod "https://www.autohotkey.com/download/2.0/version.txt"
$AhkUrl = "https://www.autohotkey.com/download/2.0/AutoHotkey_$AhkVer.zip"
Invoke-WebRequest $AhkUrl -Out ahk.zip
Expand-Archive -Path ahk.zip -DestinationPath temp -Force
Move-Item -Path .\temp\AutoHotkey*.exe -Destination .\
Remove-Item -Recurse temp,ahk.zip
- name: Upload AutoHotkey
uses: actions/upload-artifact@v4
with:
name: AutoHotkey
path: |
AutoHotkey32.exe
AutoHotkey64.exe
prepare-dependency:
name: Prepare Dependency
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Fetch Jiandao
run: |
WORK=`pwd`
JIANDAO_TAG=$(curl -s https://api.github.com/repos/amorphobia/rime-jiandao/releases/latest | jq -r '.tag_name')
JIANDAO_URL="https://github.com/amorphobia/rime-jiandao/releases/download/${JIANDAO_TAG}/jiandao-${JIANDAO_TAG}.zip"
wget -O jiandao.zip ${JIANDAO_URL} && \
rm -rf ${WORK}/schemas/jiandao && \
mkdir ${WORK}/schemas/jiandao && \
unzip jiandao.zip -d ${WORK}/schemas/jiandao/ && \
rm jiandao.zip
- name: Fetch Librime
run: |
WORK=`pwd`
LIBRIME_TAG=$(curl -s https://api.github.com/repos/rime/librime/releases/latest | jq -r '.tag_name')
LIBRIME_SHA=$(curl -s https://api.github.com/repos/rime/librime/tags | jq -r --arg LIBRIME_TAG "${LIBRIME_TAG}" '.[] | select(.name == $LIBRIME_TAG).commit.sha' | cut -c1-7)
LIBRIME_MSVC_X86_URL="https://github.com/rime/librime/releases/download/${LIBRIME_TAG}/rime-${LIBRIME_SHA}-Windows-msvc-x86.7z"
LIBRIME_MSVC_X86_DEPS_URL="https://github.com/rime/librime/releases/download/${LIBRIME_TAG}/rime-deps-${LIBRIME_SHA}-Windows-msvc-x86.7z"
LIBRIME_MSVC_X64_URL="https://github.com/rime/librime/releases/download/${LIBRIME_TAG}/rime-${LIBRIME_SHA}-Windows-msvc-x64.7z"
mkdir -p ${WORK}/librime-msvc ${WORK}/librime-clang
cd ${WORK}/librime-msvc && \
wget -O librime.7z ${LIBRIME_MSVC_X86_URL} && \
7z x '-i!dist/lib/rime.dll' librime.7z && \
cp dist/lib/rime.dll ${WORK}/rime-x86.dll && \
rm -rf librime.7z dist && \
wget -O deps.7z ${LIBRIME_MSVC_X86_DEPS_URL} && \
7z x '-i!share/opencc' deps.7z && \
cp -r share/opencc ${WORK}/ && \
rm -rf deps.7z share
cd ${WORK}/librime-clang && \
wget -O librime.7z ${LIBRIME_MSVC_X64_URL} && \
7z x '-i!dist/lib/rime.dll' librime.7z && \
cp dist/lib/rime.dll ${WORK}/rime-x64.dll && \
rm -rf librime.7z dist
- name: Upload Rime
uses: actions/upload-artifact@v4
with:
name: Rime
path: |
rime-x86.dll
rime-x64.dll
- name: Prepare SharedSupport
run: |
WORK=`pwd`
SCHEMAS=${WORK}/schemas
SHARED=${WORK}/SharedSupport
rm -rf ${SHARED} && mkdir -p ${SHARED}
cp ${SCHEMAS}/prelude/*.yaml ${SHARED}/
cp ${SCHEMAS}/essay/essay.txt ${SHARED}/
cp ${SCHEMAS}/default.yaml ${SHARED}/
cp ${SCHEMAS}/pinyin-simp/*.yaml ${SHARED}/
cp -r ${SCHEMAS}/jiandao/* ${SHARED}/
cp ${WORK}/opencc/* ${SHARED}/opencc/
- name: Upload SharedSupport
uses: actions/upload-artifact@v4
with:
name: SharedSupport
path: SharedSupport
build-rabbit:
strategy:
matrix:
target: [ x86, x64 ]
include:
- { target: x86, ahk: AutoHotkey32.exe, rime: rime-x86.dll }
- { target: x64, ahk: AutoHotkey64.exe, rime: rime-x64.dll }
name: Build for ${{ matrix.target }}
runs-on: ubuntu-latest
needs: prepare-dependency
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Download Dependencies
uses: actions/download-artifact@v4
- name: Copy Binaries
run: |
cp AutoHotkey/${{ matrix.ahk }} Rabbit.exe
cp Rime/${{ matrix.rime }} rime.dll
- name: Make Icon
run: |
sudo apt-get install -y imagemagick
convert -background transparent -define 'icon:auto-resize=16,24,32,64' icon.svg Rabbit.ico
- name: Upload Rabbit ${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: Rabbit-${{ matrix.target }}
path: |
Lib/librime-ahk/*.ahk
Lib/librime-ahk/LICENSE
Lib/*.ahk
rime.dll
Rabbit.exe
Rabbit.ico
*.ahk
LICENSE
README.md
- name: Upload Full Zip of Rabbit ${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: Rabbit-Full-${{ matrix.target }}
path: |
SharedSupport
Lib/librime-ahk/*.ahk
Lib/librime-ahk/LICENSE
Lib/*.ahk
rime.dll
Rabbit.exe
Rabbit.ico
*.ahk
LICENSE
README.md
create-release:
name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: build-rabbit
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Release
uses: softprops/action-gh-release@v2
upload-release:
strategy:
matrix:
target: [ x86, x64 ]
name: Upload Release for ${{ matrix.target }}
runs-on: ubuntu-latest
needs: create-release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: Rabbit-Full-${{ matrix.target }}
path: release
- name: Pack Zip
working-directory: release
run: |
mkdir Rime && zip -r -q ../rabbit-${{ github.ref_name }}-${{ matrix.target }}.zip *
- name: Upload Assets
uses: softprops/action-gh-release@v2
with:
prerelease: true
files: |
rabbit-${{ github.ref_name }}-${{ matrix.target }}.zip