Skip to content

chore(ci): update workflow #103

chore(ci): update workflow

chore(ci): update workflow #103

Workflow file for this run

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: Install Dependencies
uses: MinoruSekine/setup-scoop@v4.0.1
with:
buckets: extras
apps: resource-hacker autohotkey imagemagick-lean
- name: Prepare binaries
run: |
Push-Location assets
# https://learn.microsoft.com/windows/apps/design/style/iconography/app-icon-construction
magick.exe -background transparent -define 'icon:auto-resize=16,24,32,48,256' icon.svg rabbit.ico
magick.exe -background transparent -define 'icon:auto-resize=16,24,32,48,256' icon-alt.svg rabbit-alt.ico
Copy-Item "$(scoop prefix autohotkey)/v2/AutoHotkey32.exe" 32.exe
Copy-Item "$(scoop prefix autohotkey)/v2/AutoHotkey64.exe" 64.exe
resourcehacker.exe -open 32.exe -save temp32.exe -action addoverwrite -resource rabbit.ico -mask ICONGROUP,159,0
resourcehacker.exe -open temp32.exe -save AutoHotkey32.exe -action addoverwrite -resource rabbit-alt.ico -mask ICONGROUP,206,0
resourcehacker.exe -open 64.exe -save temp64.exe -action addoverwrite -resource rabbit.ico -mask ICONGROUP,159,0
resourcehacker.exe -open temp64.exe -save AutoHotkey64.exe -action addoverwrite -resource rabbit-alt.ico -mask ICONGROUP,206,0
Pop-Location
Move-Item "assets/AutoHotkey32.exe","assets/AutoHotkey64.exe","assets/rabbit.ico","assets/rabbit-alt.ico" .
- name: Upload Icon
uses: actions/upload-artifact@v4
with:
name: Icon
path: |
rabbit.ico
rabbit-alt.ico
- 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: Build Jiandao
run: |
WORK=`pwd`
JIANDAO_DIR=${WORK}/schemas/jiandao-src
pushd ${JIANDAO_DIR}
JIANDAO_TAG=$(curl -s https://api.github.com/repos/amorphobia/rime-jiandao/releases/latest | jq -r '.tag_name')
make dicts DEWEIGHT=1 VERSION="${JIANDAO_TAG}-rabbit-${{ github.ref_name }}"
popd
sudo apt-get install -y opencc
if command -v opencc &> /dev/null; then
echo "$(opencc --version)"
mkdir -p ${JIANDAO_DIR}/schema/opencc
opencc -c t2s.json -i ${JIANDAO_DIR}/deps/rime-emoji/opencc/emoji_category.txt | awk '!seen[$1]++' > ${JIANDAO_DIR}/schema/opencc/emoji_category.txt
opencc -c t2s.json -i ${JIANDAO_DIR}/deps/rime-emoji/opencc/emoji_word.txt | awk '!seen[$1]++' > ${JIANDAO_DIR}/schema/opencc/emoji_word.txt
# https://github.com/rime/rime-emoji/issues/48
sed -i 's/鼔/鼓/g' ${JIANDAO_DIR}/schema/opencc/emoji_word.txt
cp ${JIANDAO_DIR}/deps/rime-emoji/opencc/emoji.json ${JIANDAO_DIR}/schema/opencc/
make -C ${JIANDAO_DIR}/deps/opencc-tonggui
cp ${JIANDAO_DIR}/deps/opencc-tonggui/opencc/* ${JIANDAO_DIR}/schema/opencc/
fi
rm -f ${JIANDAO_DIR}/schema/recipe.yaml ${JIANDAO_DIR}/schema/rime.lua
mkdir -p ${WORK}/schemas/jiandao
cp -r ${JIANDAO_DIR}/schema/* ${WORK}/schemas/jiandao/
- 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 Data
run: |
WORK=`pwd`
SCHEMAS=${WORK}/schemas
DATA=${WORK}/Data
rm -rf ${DATA} && mkdir -p ${DATA}
cp ${SCHEMAS}/prelude/*.yaml ${DATA}/
cp ${SCHEMAS}/essay/essay.txt ${DATA}/
cp ${SCHEMAS}/default.yaml ${DATA}/
cp ${SCHEMAS}/rabbit.yaml ${DATA}/
cp ${SCHEMAS}/pinyin-simp/*.yaml ${DATA}/
cp -r ${SCHEMAS}/jiandao/* ${DATA}/
cp ${WORK}/opencc/* ${DATA}/opencc/
- name: Upload Data
uses: actions/upload-artifact@v4
with:
name: Data
path: Data
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, prepare-autohotkey-binaries ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Download Dependencies
uses: actions/download-artifact@v4
- name: Copy Artifacts
run: |
cp AutoHotkey/${{ matrix.ahk }} Rabbit.exe
cp Rime/${{ matrix.rime }} rime.dll
- name: Upload Rabbit ${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: Rabbit-${{ matrix.target }}
path: |
Lib/librime-ahk/*.ahk
Lib/librime-ahk/utils
Lib/librime-ahk/LICENSE
Lib/GetCaretPosEx/*.ahk
Lib/GetCaretPosEx/LICENSE.txt
Lib/*.ahk
rime.dll
Rabbit.exe
*.ahk
LICENSE
README.md
- name: Upload Full Zip of Rabbit ${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: Rabbit-Full-${{ matrix.target }}
path: |
Data
Lib/librime-ahk/*.ahk
Lib/librime-ahk/utils
Lib/librime-ahk/LICENSE
Lib/GetCaretPosEx/*.ahk
Lib/GetCaretPosEx/LICENSE.txt
Lib/*.ahk
rime.dll
Rabbit.exe
*.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