diff --git a/.ci/backup.travis.yml b/.ci/backup.travis.yml deleted file mode 100644 index fa943397..00000000 --- a/.ci/backup.travis.yml +++ /dev/null @@ -1,65 +0,0 @@ -if: tag IS present OR branch = main - -jobs: - include: -# For Mac pkg and Linux installation script - - dist: xenial - language: ruby - -# For Android apk builder - - dist: trusty - language: android - jdk: openjdk8 - android: - components: - - build-tools-25.0.2 - -# For Windows installer - - os: windows - language: cpp - -before_install: -# Get frontend version number from GitHub - - export WEASEL_VERSION=$( git ls-remote --tags --refs --sort="v:refname" https://github.com/rime/weasel.git | tail -n1 | sed 's/.*\///' ) - - export SQUIRREL_VERSION=$( git ls-remote --tags --refs --sort="v:refname" https://github.com/rime/squirrel.git | tail -n1 | sed 's/.*\///' ) - -# Download latest frontend - - export WEASEL_LINK=https://github.com/rime/weasel/releases/download/${WEASEL_VERSION}/weasel-${WEASEL_VERSION}.0-installer.exe - - export SQUIRREL_LINK=https://github.com/rime/squirrel/releases/download/${SQUIRREL_VERSION}/Squirrel-${SQUIRREL_VERSION}.zip - - export TRIME_LINK=https://github.com/osfans/trime/raw/gh-pages/release/app-release.apk - -# IME Files path - - export WEASEL_PACKAGES="cantonese emoji-cantonese CanCLID/rime-loengfan custom:set:config=default,key=installed_from,value=rime-cantonese custom:clear_schema_list custom:add:schema=jyut6ping3 custom:add:schema=cangjie5 custom:add:schema=stroke custom:add:schema=luna_pinyin lotem/rime-octagram-data lotem/rime-octagram-data@hant lotem/rime-octagram-data:customize:schema=jyut6ping3,model=hant" - - export SQUIRREL_PACKAGES="cantonese emoji-cantonese CanCLID/rime-loengfan custom:set:config=default,key=installed_from,value=rime-cantonese custom:clear_schema_list custom:add:schema=jyut6ping3 custom:add:schema=cangjie5 custom:add:schema=stroke custom:add:schema=luna_pinyin lotem/rime-octagram-data lotem/rime-octagram-data@hant lotem/rime-octagram-data:customize:schema=jyut6ping3,model=hant" - - export IBUS_PACKAGES=${SQUIRREL_PACKAGES} - - export TRIME_PACKAGES=":preset cantonese emoji-cantonese CanCLID/rime-loengfan" - -# Windows sfx installer header - - export SFXHEADER=7zSD.sfx - -install: - - if [[ "$TRAVIS_OS_NAME" = "linux" && "$TRAVIS_DIST" = "xenial" ]]; then sudo apt-get install p7zip-full; fi - -script: - - mkdir output - - chmod u+x .ci/* - - if [[ "$TRAVIS_OS_NAME" = "linux" && "$TRAVIS_DIST" = "xenial" ]]; then - ".ci/build_linux.sh"; - elif [[ "$TRAVIS_OS_NAME" = "linux" && "$TRAVIS_DIST" = "trusty" ]]; then - ".ci/build_android.sh"; - elif [ "$TRAVIS_OS_NAME" = "windows" ]; then - ".ci/build_windows.sh"; - fi - -after_success: - - ls output # debug - -deploy: - provider: releases - api_key: ${GITHUB_TOKEN} - file_glob: true - file: - - output/* - on: - tags: true - skip_cleanup: true diff --git a/.ci/build_android.sh b/.ci/build_android.sh deleted file mode 100644 index 7cd98b12..00000000 --- a/.ci/build_android.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# Android packing script - -# Script to fail when any command returns error -set -e - -# Preparing apk -export PATH=/usr/local/android-sdk/build-tools/25.0.2/:$PATH -export ORI_NAME=android.apk -export APK_NAME=output/android-dev-${TRAVIS_TAG}.apk -wget --output-document=${ORI_NAME} ${TRIME_LINK} - -# Downloading IME files -mkdir -p assets/rime -export rime_dir=assets/rime -curl -fsSL https://git.io/rime-install | bash -s -- ${TRIME_PACKAGES} -cp .ci/default.custom.yaml $rime_dir - -# add IME files -aapt add ${ORI_NAME} $rime_dir/* -aapt remove ${ORI_NAME} $rime_dir/opencc/* -aapt add ${ORI_NAME} $rime_dir/opencc/* -echo Finished adding files, check: -aapt list ${ORI_NAME} - -# Zip-align to 32-bit -zipalign -v 4 ${ORI_NAME} ${APK_NAME} - -# Sign apk -export KEYPASS=$( openssl rand -base64 12 ) -export STOREPASS=$( openssl rand -base64 12 ) - -keytool -genkey -alias key \ - -keyalg RSA -keystore keystore.jks \ - -dname "CN=tanxpyox, OU=RimeCantonese, O=Rime, L=SikSyuTong, S=Rime, C=ZungJyun" \ - -storepass ${STOREPASS} -keypass ${KEYPASS} - -apksigner sign --ks keystore.jks --ks-pass pass:${STOREPASS} --key-pass pass:${KEYPASS} ${APK_NAME} diff --git a/.ci/build_linux.sh b/.ci/build_linux.sh deleted file mode 100644 index 1a894588..00000000 --- a/.ci/build_linux.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# macOS Installer, default.custom.yaml and ibus-install.sh packing script - -# Script to fail when any command returns error -set -e - -# Building mac package -mkdir -p build/mac - -# Download Mac installation script, Mac package and unzip -wget ${SQUIRREL_LINK} -mv Squirrel*.Pkg ./build/mac/Squirrel.pkg -cat .ci/mac-install-template.sh | envsubst '${SQUIRREL_PACKAGES}' > ./build/mac/mac-install.sh - -# Build archives -7z a output/mac-${GITHUB_REF_NAME}-installer.zip ./build/mac/* - -# Copy default.custom.yaml and ibus-install.sh into output queue -cat .ci/ibus-install-template.sh | envsubst '${IBUS_PACKAGES}' > ./output/ibus-install.sh -cp .ci/default.custom.yaml output/ diff --git a/.ci/build_windows.sh b/.ci/build_windows.sh deleted file mode 100644 index d5837309..00000000 --- a/.ci/build_windows.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# Windows installer packing script - -# Script to fail when any command returns error -set -e - -mkdir -p build/windows/data -# Prepare update installation script template version number -cat .ci/windows-install-template.bat | envsubst > ./build/windows/windows-install.bat - -# Download IME files (and 32-bit OpenCC) -export rime_dir=build/windows/data -curl -fsSL https://git.io/rime-install | bash -s -- ${WEASEL_PACKAGES} - -# Prepare installer exe -wget -P ./build/windows ${WEASEL_LINK} --no-check-certificate - -# Packing sfx installer... -wget https://github.com/tanxpyox/7z.sfx-backup/raw/master/${SFXHEADER} -7z a windows-installer.7z ./build/windows/* -cat ${SFXHEADER} .ci/config.txt windows-installer.7z > output/windows-sfx-${GITHUB_REF_NAME}-installer.exe - -# Packing installer files into a separate zip -7z a output/windows-${GITHUB_REF_NAME}-installer.zip ./build/windows/* diff --git a/.ci/config.txt b/.ci/config.txt deleted file mode 100644 index 1c32b4d9..00000000 --- a/.ci/config.txt +++ /dev/null @@ -1,5 +0,0 @@ -;!@Install@!UTF-8! -Title="小狼毫輸入法引擎+廣東話方案安裝器" -RunProgram="windows-install.bat" -Path="%tmp%\\weasel-install" -;!@InstallEnd@! diff --git a/.ci/default.custom.yaml b/.ci/default.custom.yaml deleted file mode 100644 index c4a58a50..00000000 --- a/.ci/default.custom.yaml +++ /dev/null @@ -1,3 +0,0 @@ -patch: - schema_list: - - schema: jyut6ping3 diff --git a/.ci/ibus-install-template.sh b/.ci/ibus-install-template.sh deleted file mode 100644 index 57030242..00000000 --- a/.ci/ibus-install-template.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# For Ubuntu and derivatives thereof -# Linux ibus frontend + Cantonese schema installation script -# Author -# - tanxpyox - -RIMEDIR=~/.config/ibus/rime/ - -echo Installing ibus-rime frontend with APT -- -echo You may need to enter your system password to proceed... -sudo apt-get install curl git ibus-rime -y - -# check for user lib -if [ ! -d ${RIMEDIR} ]; then - mkdir ${RIMEDIR} -fi - -echo Installing IME files ... -curl -fsSL https://git.io/rime-install | bash -s -- ${IBUS_PACKAGES} - -echo Done! diff --git a/.ci/install-schema.sh b/.ci/install-schema.sh new file mode 100644 index 00000000..987041e4 --- /dev/null +++ b/.ci/install-schema.sh @@ -0,0 +1,18 @@ +#!/bin/bash +curl -fsSL https://git.io/rime-install | bash -s -- prelude essay cantonese emoji-cantonese cangjie stroke luna-pinyin CanCLID/rime-loengfan lotem/rime-octagram-data lotem/rime-octagram-data@hant + +if [ -n "$rime_dir" ]; then + pushd "$rime_dir" + perl -0777 -i -pe 's/\nschema_list:\n.*?\n\n/ +installed_from: rime-cantonese + +schema_list: + - schema: jyut6ping3 + - schema: cangjie5 + - schema: stroke + - schema: luna_pinyin + +/s; s/page_size: [0-9]+/page_size: 8/' default.yaml + rm emoji_cantonese_suggestion.yaml + popd +fi diff --git a/.ci/mac-install-template.sh b/.ci/mac-install-template.sh deleted file mode 100644 index 573b1c6c..00000000 --- a/.ci/mac-install-template.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# macOS Squirrel frontend + cantonese schema installation script -# Author -# - tanxpyox - -RIMEDIR=~/Library/Rime/ - -sudo installer -verbose -pkg ./Squirrel.pkg -target / - -# check for user lib -if [ ! -d ${RIMEDIR} ]; then - mkdir ${RIMEDIR} -fi - -echo Installing IME files... -curl -fsSL https://git.io/rime-install | bash -s -- ${SQUIRREL_PACKAGES} - - -echo Done! diff --git a/.ci/package-mac.sh b/.ci/package-mac.sh new file mode 100644 index 00000000..14d47124 --- /dev/null +++ b/.ci/package-mac.sh @@ -0,0 +1,53 @@ +#!/bin/bash +if [ -z "$SQUIRREL_VERSION" ]; then + echo 'Error: Please specify the Squirrel version to package in the SQUIRREL_VERSION variable' >&2 + exit 1 +fi +if [ -z "$SCHEMA_DIR" ]; then + echo 'Error: Please specify the path to the schema directory in the SCHEMA_DIR variable' >&2 + exit 1 +fi +if [ -z "$APPLE_DEVELOPER_NAME" ] || [ -z "$APPLE_DEVELOPER_TEAM_ID" ] || [ -z "$APPLE_CONNECT_USERNAME" ] || [ -z "$APPLE_CONNECT_PASSWORD" ]; then + echo 'Error: Please specify the APPLE_DEVELOPER_NAME, APPLE_DEVELOPER_TEAM_ID, APPLE_CONNECT_USERNAME, and APPLE_CONNECT_PASSWORD variables for code resigning and notarization' >&2 + exit 1 +fi +set -e + +# Modify the package with the solution from https://stackoverflow.com/a/11299907 +# First, download the package and extract it +wget https://github.com/rime/squirrel/releases/download/${SQUIRREL_VERSION}/Squirrel-${SQUIRREL_VERSION}.pkg +pkgutil --expand Squirrel-${SQUIRREL_VERSION}.pkg package +pushd package + +# Extract the application +tar -xzf Payload +pushd Squirrel.app/Contents + +# Remove all default rime schemas but keep opencc data and app config +# Then, download the latest schemas we need and amend the `default.yaml` +GLOBIGNORE=SharedSupport/squirrel.yaml +rm SharedSupport/*.* +cp -rf "$SCHEMA_DIR/"* SharedSupport +popd + +# Resign the application +codesign --sign "Developer ID Application: $APPLE_DEVELOPER_NAME ($APPLE_DEVELOPER_TEAM_ID)" --timestamp --deep --force --options runtime --preserve-metadata=identifier,entitlements Squirrel.app + +# Compress back the application +find Squirrel.app | cpio -o | gzip -c > Payload +mkbom Squirrel.app Bom +rm -rf Squirrel.app +popd + +# Finally, compress back the package +mkdir output +pkgutil --flatten package output/Squirrel.pkg +cd output + +# Resign the package +pkg_path=Squirrel-${SQUIRREL_VERSION}-rime-cantonese.pkg +productsign --sign "Developer ID Installer: $APPLE_DEVELOPER_NAME ($APPLE_DEVELOPER_TEAM_ID)" Squirrel.pkg "$pkg_path" + +# Notarize the package +xcrun notarytool submit "$pkg_path" --apple-id "$APPLE_CONNECT_USERNAME" --password "$APPLE_CONNECT_PASSWORD" --team-id "$APPLE_DEVELOPER_TEAM_ID" --wait +xcrun stapler staple "$pkg_path" diff --git a/.ci/package-windows.sh b/.ci/package-windows.sh new file mode 100644 index 00000000..d71a448a --- /dev/null +++ b/.ci/package-windows.sh @@ -0,0 +1,53 @@ +#!/bin/bash +if [ -z "$WEASEL_VERSION" ]; then + echo 'Error: Please specify the Weasel version to package in the WEASEL_VERSION variable' >&2 + exit 1 +fi +if [ -z "$SCHEMA_DIR" ]; then + echo 'Error: Please specify the path to the schema directory in the SCHEMA_DIR variable' >&2 + exit 1 +fi +if ! [ -x "$(command -v makensis.exe)" ]; then + echo 'Error: Please specify the path to makensis.exe in the PATH' >&2 + exit 1 +fi +set -e + +# First, download the executable and extract it +wget https://github.com/rime/weasel/releases/download/${WEASEL_VERSION}/weasel-${WEASEL_VERSION}.0-installer.exe --no-check-certificate +7z x weasel-${WEASEL_VERSION}.0-installer.exe -aou -ooutput +cd output + +# List all files with name ending with `_1`, compare the content of these files and the files with the same names but does not end with `_1` whether these binaries is 32-bit or 64-bit +# Then, move the ones that are 32-bit to the `Win32` folder and remove `_1` from the name of all the files +mkdir Win32 +for file in *_1.*; do + extension="${file##*.}" + base_file="${file%_1.*}.$extension" + if [[ $(file "$base_file") != *"x86-64"* ]]; then + mv "$base_file" "Win32/$base_file" + fi + if [[ $(file "$file") == *"x86-64"* ]]; then + mv "$file" "$base_file" + else + mv "$file" "Win32/$base_file" + fi +done + +# Remove all default rime schemas but keep opencc data, preview images and app config +# Then, download the latest schemas we need and amend the `default.yaml` +GLOBIGNORE=data/weasel.yaml +rm data/*.* +cp -rf "$SCHEMA_DIR/"* data + +# Finally, rebuild the installer +mkdir ../resource +wget https://raw.githubusercontent.com/rime/weasel/refs/tags/${WEASEL_VERSION}/resource/weasel.ico -P ../resource +wget https://raw.githubusercontent.com/rime/weasel/refs/tags/${WEASEL_VERSION}/output/install.nsi +mkdir archives +makensis.exe //DWEASEL_VERSION=$WEASEL_VERSION //DPRODUCT_VERSION=$WEASEL_VERSION install.nsi + +# Rename the installer +for file in archives/*.exe; do + mv "$file" "${file/installer/rime-cantonese}" +done diff --git a/.ci/uniqsort.sh b/.ci/uniqsort.sh deleted file mode 100644 index 362da3fb..00000000 --- a/.ci/uniqsort.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash -# Remove duplicates && Sort entries BY PRONUNCIATION (if available); -# else, BY CHINESE CHARACTERS - -# Base list--to be 'uniquified' -candidates=($( ls *.dict.yaml )) - -# Add files to this list if they are ALSO READY TO BE SORTED -goodToSort=( - # jyut6ping3.phrase.dict.yaml # Under development, do not sort - jyut6ping3.maps.dict.yaml - # jyut6ping3.dict.yaml - # jyut6ping3.lettered.dict.yaml -) - -# Set sort order by locale (default: "C"=radical-stroke) -if [ -z "$LC_ALL" ]; then LC_ALL=C; fi - -chmod u+w ${candidates[@]} - -for file in ${candidates[@]}; do - echo =============================== - echo $file - awk '{ - if (!x["..."]) { - print > "a.tmp"; - if ($0=="...") x["..."]++ - } else if ($0=="" || !x[$0]++) { - print > "b.tmp" - } - }' $file && echo " : uniquified" || continue - if [[ $(echo ${goodToSort[@]} | grep -w $file) ]]; then - /usr/bin/sort -k2,2 -k1,1 -o b.tmp b.tmp && echo " : sorted" || continue - fi - cat a.tmp b.tmp > $file && echo " - changes merged" - rm a.tmp b.tmp -done -echo =============================== - -# Clean up -rm *tmp 2> /dev/null diff --git a/.ci/windows-install-template.bat b/.ci/windows-install-template.bat deleted file mode 100644 index 57feb812..00000000 --- a/.ci/windows-install-template.bat +++ /dev/null @@ -1,29 +0,0 @@ -@echo off - -echo Checking system architecture... -reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT - -echo Preparing installation environment... -SET RIMEDIR=%APPDATA%\rime\ -SET VERSION=weasel-${WEASEL_VERSION} -SET RIMEPROGRAM=%ProgramFiles%\Rime\%VERSION%\ -IF %OS%==64BIT SET RIMEPROGRAM=%ProgramFiles(x86)%\Rime\%VERSION%\ - -CHOICE /T 40 /C yn /D y /M "Configure Traditional Chinese" -echo Installing Weasel frontend... -IF ERRORLEVEL 2 ( - for %%x in (*.exe) do (%%x /S) -) else ( - for %%x in (*.exe) do (%%x /S /T) -) - -if not exist %RIMEDIR% mkdir %RIMEDIR% - -echo Copying IME files to %RIMEDIR% -xcopy /E /Y data %RIMEDIR% - -echo Deploying... This may take quite a while... -"%RIMEPROGRAM%\WeaselDeployer.exe" /deploy - -echo Done! Please restart your computer to complete the installation. -pause diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml index 0848c081..ffea1029 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/deploy-test.yml @@ -5,7 +5,7 @@ on: branches: - main paths: - - '*.yaml' # root directory only + - '*.yaml' # root directory only - '*.txt' - 'opencc/**' pull_request: @@ -16,11 +16,6 @@ on: - '*.txt' - 'opencc/**' workflow_dispatch: - inputs: - logLevel: - description: 'Log level' - required: false - default: 'warning' jobs: compile: @@ -28,22 +23,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - run: | - echo "Installing rime engine" - sudo apt-get install curl git ibus-rime -y - - run: | - echo "Installing rime-cantonese files" - curl -fsSL https://git.io/rime-install | bash -s -- :preset cantonese emoji-cantonese CanCLID/rime-loengfan custom:set:config=default,key=installed_from,value=rime-cantonese custom:clear_schema_list custom:add:schema=jyut6ping3 custom:add:schema=cangjie5 custom:add:schema=stroke custom:add:schema=luna_pinyin lotem/rime-octagram-data lotem/rime-octagram-data@hant lotem/rime-octagram-data:customize:schema=jyut6ping3,model=hant - cp ./*.{txt,yaml} ~/.config/ibus/rime - cp ./opencc/* ~/.config/ibus/rime - - run: | - echo "Compiling..." + - name: Install rime engine + run: | + sudo apt-get install ibus-rime -y + - name: Install rime-cantonese files + run: | + chmod u+x ./.ci/* + export rime_dir=~/.config/ibus/rime + ./.ci/install-schema.sh + - name: Compile + run: | chmod u+wx ~/.config/ibus/rime/* rime_deployer --build ~/.config/ibus/rime 2> log.tmp - - run: | - echo "Checking..." + - name: Check + run: | cat log.tmp - exit $( cat log.tmp | grep -c ^[EW] ) + exit $(cat log.tmp | grep -c ^[EW]) check_jyutping_cpp: runs-on: ubuntu-latest @@ -62,7 +57,6 @@ jobs: echo "Checking jyut6ping3.dict.yaml" time ./checker.o jyut6ping3.dict.yaml - check_jyutping_php: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index ce890ad5..7972263b 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,82 +1,130 @@ name: Build packages on: - push: - branches: - - main - paths: - - '*.yaml' # root directory only - - '*.txt' - - 'opencc/**' + workflow_call: + inputs: + event_name: + required: true + type: string jobs: - mac_linux: + install-schema: runs-on: ubuntu-latest steps: - - name: checkout + - name: Checkout Repo uses: actions/checkout@v4 - - run: mkdir output - - run: chmod u+x .ci/* - - run: mkdir -p build/mac - - name: build + - name: Install Schemata run: | - export SQUIRREL_VERSION=$( git ls-remote --tags --refs --sort="v:refname" https://github.com/rime/squirrel.git | grep -v '/latest$' | tail -n1 | sed 's/.*\///' ) - export SQUIRREL_LINK=https://github.com/rime/squirrel/releases/download/${SQUIRREL_VERSION}/Squirrel-${SQUIRREL_VERSION}.Pkg - export SQUIRREL_PACKAGES="cantonese emoji-cantonese CanCLID/rime-loengfan custom:set:config=default,key=installed_from,value=rime-cantonese custom:clear_schema_list custom:add:schema=jyut6ping3 custom:add:schema=cangjie5 custom:add:schema=stroke custom:add:schema=luna_pinyin lotem/rime-octagram-data lotem/rime-octagram-data@hant lotem/rime-octagram-data:customize:schema=jyut6ping3,model=hant" - export IBUS_PACKAGES=${SQUIRREL_PACKAGES} - - # Download Mac installation script, Mac package and unzip - wget ${SQUIRREL_LINK} - mv Squirrel*.Pkg ./build/mac/Squirrel.pkg - cat .ci/mac-install-template.sh | envsubst '${SQUIRREL_PACKAGES}' > ./build/mac/mac-install.sh - - # Build archives - 7z a output/mac-${GITHUB_REF_NAME}-installer.zip ./build/mac/* - - # Copy default.custom.yaml and ibus-install.sh into output queue - cat .ci/ibus-install-template.sh | envsubst '${IBUS_PACKAGES}' > ./output/ibus-install.sh - cp .ci/default.custom.yaml output/ - - uses: softprops/action-gh-release@v2 + chmod u+x ./.ci/* + export rime_dir=schema + ./.ci/install-schema.sh + - name: Upload Schemata + uses: actions/upload-artifact@v4 with: - files: output/* - if: startsWith(github.ref, 'refs/tags/') - - run: ls output + name: install-schema + if-no-files-found: error + path: schema - windows: - runs-on: ubuntu-latest + package-windows: + needs: install-schema + runs-on: windows-2019 steps: - - name: checkout + - name: Checkout Repo uses: actions/checkout@v4 - - run: sudo apt-get install p7zip-full - - run: mkdir output - - run: chmod u+x .ci/* - - run: mkdir -p build/windows/data - - name: build + - name: Get Weasel Version + shell: bash + run: | + echo "WEASEL_VERSION=$(git ls-remote --tags --refs --sort="v:refname" https://github.com/rime/weasel.git | grep -v '/latest$' | tail -n1 | sed 's/.*\///')" >> $GITHUB_ENV + - id: check_version + name: Compare Weasel Version + if: inputs.event_name != 'push' + shell: bash + continue-on-error: true run: | - export WEASEL_VERSION=$( git ls-remote --tags --refs --sort="v:refname" https://github.com/rime/weasel.git | grep -v '/latest$' | tail -n1 | sed 's/.*\///' ) - export WEASEL_LINK=https://github.com/rime/weasel/releases/download/${WEASEL_VERSION}/weasel-${WEASEL_VERSION}.0-installer.exe - export WEASEL_PACKAGES="cantonese emoji-cantonese CanCLID/rime-loengfan custom:set:config=default,key=installed_from,value=rime-cantonese custom:clear_schema_list custom:add:schema=jyut6ping3 custom:add:schema=cangjie5 custom:add:schema=stroke custom:add:schema=luna_pinyin lotem/rime-octagram-data lotem/rime-octagram-data@hant lotem/rime-octagram-data:customize:schema=jyut6ping3,model=hant" - export SFXHEADER=7zSD.sfx + RELEASED_FILES=$(gh release view latest --json assets --jq '.assets[].name') + WEASEL_RELEASED_VERSION=$(echo "$RELEASED_FILES" | grep 'weasel-.*' | sed 's/weasel-\([^-]*\).*/\1/') + if [ "$WEASEL_VERSION" = "$WEASEL_RELEASED_VERSION" ]; then + echo "Weasel version is up to date. Skipping package." + exit 1 + - name: Download Schemata + if: inputs.event_name == 'push' || steps.check_version.outcome == 'success' + uses: actions/download-artifact@v4 + with: + name: install-schema + path: schema + - name: Package Weasel + if: inputs.event_name == 'push' || steps.check_version.outcome == 'success' + shell: bash + run: | + export PATH="/c/msys64/usr/bin:$PATH" # wget + export SCHEMA_DIR="$PWD/schema" + ./.ci/package-windows.sh + - name: Upload Artifact + if: inputs.event_name == 'push' || steps.check_version.outcome == 'success' + uses: actions/upload-artifact@v4 + with: + name: package-windows + if-no-files-found: error + path: ./output/archives/weasel-*.exe - # Prepare update installation script template version number - cat .ci/windows-install-template.bat | envsubst > ./build/windows/windows-install.bat + package-mac: + needs: install-schema + runs-on: macos-14 + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + - name: Get Squirrel Version + run: | + echo "SQUIRREL_VERSION=$(git ls-remote --tags --refs --sort="v:refname" https://github.com/rime/squirrel.git | grep -v '/latest$' | tail -n1 | sed 's/.*\///')" >> $GITHUB_ENV + - id: check_version + name: Compare Squirrel Version + if: inputs.event_name != 'push' + continue-on-error: true + run: | + RELEASED_FILES=$(gh release view latest --json assets --jq '.assets[].name') + SQUIRREL_RELEASED_VERSION=$(echo "$RELEASED_FILES" | grep 'Squirrel-.*' | sed 's/Squirrel-\([^-]*\).*/\1/') + if [ "$SQUIRREL_VERSION" = "$SQUIRREL_RELEASED_VERSION" ]; then + echo "Squirrel version is up to date. Skipping package." + exit 1 + - name: Download Schemata + if: inputs.event_name == 'push' || steps.check_version.outcome == 'success' + uses: actions/download-artifact@v4 + with: + name: install-schema + path: schema + - name: Package Squirrel + if: inputs.event_name == 'push' || steps.check_version.outcome == 'success' + env: + APPLE_DEVELOPER_NAME: ${{ secrets.APPLE_DEVELOPER_NAME }} + APPLE_DEVELOPER_TEAM_ID: ${{ secrets.APPLE_DEVELOPER_TEAM_ID }} + APPLE_CONNECT_USERNAME: ${{ secrets.APPLE_CONNECT_USERNAME }} + APPLE_CONNECT_PASSWORD: ${{ secrets.APPLE_CONNECT_PASSWORD }} + APPLICATION_CERTIFICATE: ${{ secrets.APPLICATION_CERTIFICATE }} + APPLICATION_CERTIFICATE_PASSWORD: ${{ secrets.APPLICATION_CERTIFICATE_PASSWORD }} + INSTALLER_CERTIFICATE: ${{ secrets.INSTALLER_CERTIFICATE }} + INSTALLER_CERTIFICATE_PASSWORD: ${{ secrets.INSTALLER_CERTIFICATE_PASSWORD }} + run: | + chmod u+x ./.ci/* - # Download IME files (and 32-bit OpenCC) - export rime_dir=build/windows/data - curl -fsSL https://git.io/rime-install | bash -s -- ${WEASEL_PACKAGES} + KEYCHAIN_PATH=~/Library/Keychains/squirrel.keychain + KEYCHAIN_PASSWORD=squirrel + security create-keychain -p "$KEYCHAIN_PASSWORD" squirrel.keychain - # Prepare installer exe - wget -P ./build/windows ${WEASEL_LINK} --no-check-certificate + echo "$APPLICATION_CERTIFICATE" | base64 -d > application_certificate.p12 + security import application_certificate.p12 -k "$KEYCHAIN_PATH" -P "$APPLICATION_CERTIFICATE_PASSWORD" -T /usr/bin/codesign + echo "$INSTALLER_CERTIFICATE" | base64 -d > installer_certificate.p12 + security import installer_certificate.p12 -k "$KEYCHAIN_PATH" -P "$INSTALLER_CERTIFICATE_PASSWORD" -T /usr/bin/productsign - # Packing sfx installer... - wget https://github.com/tanxpyox/7z.sfx-backup/raw/master/${SFXHEADER} - 7z a windows-installer.7z ./build/windows/* - cat ${SFXHEADER} .ci/config.txt windows-installer.7z > output/windows-sfx-${GITHUB_REF_NAME}-installer.exe + security list-keychain -s "$KEYCHAIN_PATH" + security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + security set-key-partition-list -S apple-tool:,apple:,codesign:,productsign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - # Packing installer files into a separate zip - 7z a output/windows-${GITHUB_REF_NAME}-installer.zip ./build/windows/* - - uses: softprops/action-gh-release@v2 + export SCHEMA_DIR="$PWD/schema" + ./.ci/package-mac.sh + - name: Upload Artifact + if: inputs.event_name == 'push' || steps.check_version.outcome == 'success' + uses: actions/upload-artifact@v4 with: - files: output/* - if: startsWith(github.ref, 'refs/tags/') - - run: ls output + name: package-mac + if-no-files-found: error + path: ./output/Squirrel-*.pkg diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..3ec28755 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Release + +on: + push: + branches: + - main + paths: + - '*.yaml' # root directory only + - '*.txt' + - 'opencc/**' + schedule: + - cron: '45 8 * * 4' # run every week + workflow_dispatch: + +jobs: + package: + uses: ./.github/workflows/package.yml + with: + event_name: ${{ github.event_name }} + secrets: inherit + release: + needs: package + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout Latest Commit + uses: actions/checkout@v4 + with: + filter: blob:none + - name: Tag the Latest Commit + run: | + git tag -f latest + git push -f origin latest + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + path: output + pattern: package-* + merge-multiple: true + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + run: | + assets=$(gh release view latest --json assets --jq '.assets[].name') + for prefix in $(ls output | xargs -n 1 basename | sed 's/-.*/-/' | sort -u); do + for asset in $(echo "$assets" | grep "^$prefix"); do + gh release delete-asset latest "$asset" -y + done + done + for file in output/*; do + gh release upload latest "$file" + done diff --git a/jyut6ping3.schema.yaml b/jyut6ping3.schema.yaml index a0fe0ca4..94a03bd2 100644 --- a/jyut6ping3.schema.yaml +++ b/jyut6ping3.schema.yaml @@ -224,3 +224,9 @@ recognizer: loengfan: "^r[a-z']*;?$" stroke: "^x[hspnz]*;?$" cangjie5: "^v[a-z]*;?$" + +__patch: + # 使用八股文語言模型 + - grammar:/hant? + # 用户自訂設定 + - jyut6ping3.custom:/patch?