2024-08-20 07:04:34 +02:00
|
|
|
|
name: Build and Release
|
2024-05-21 03:03:20 +02:00
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches:
|
|
|
|
|
- main
|
|
|
|
|
tags:
|
2024-08-20 07:04:34 +02:00
|
|
|
|
- "[0-9]+.*"
|
2024-05-21 03:03:20 +02:00
|
|
|
|
paths:
|
2024-08-20 07:04:34 +02:00
|
|
|
|
- "**/**"
|
|
|
|
|
- "!**.md"
|
|
|
|
|
- "!**.gitignore"
|
|
|
|
|
- "!.github/**"
|
2024-05-21 03:03:20 +02:00
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
Release:
|
|
|
|
|
runs-on: ubuntu-latest
|
2024-08-20 07:04:34 +02:00
|
|
|
|
if: github.repository == 'iDvel/rime-ice'
|
2024-05-21 03:03:20 +02:00
|
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
- name: Checkout
|
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
2024-08-20 07:04:34 +02:00
|
|
|
|
- name: Setup Go
|
|
|
|
|
if: ${{ contains(github.event.head_commit.message, ' [build]') || github.event_name == 'workflow_dispatch' }}
|
|
|
|
|
uses: actions/setup-go@v5
|
|
|
|
|
with:
|
|
|
|
|
go-version: 1.22
|
|
|
|
|
|
|
|
|
|
- name: Check and build
|
|
|
|
|
id: check_and_build
|
|
|
|
|
if: ${{ contains(github.event.head_commit.message, ' [build]') || github.event_name == 'workflow_dispatch' }}
|
|
|
|
|
run: |
|
|
|
|
|
cd others/script
|
|
|
|
|
go mod tidy
|
|
|
|
|
go run main.go --rime_path "${{ github.workspace }}" --auto_confirm
|
|
|
|
|
|
2024-05-21 03:03:20 +02:00
|
|
|
|
- name: Pack dicts
|
|
|
|
|
run: |
|
|
|
|
|
mkdir dist
|
|
|
|
|
echo "Pack all ..."
|
|
|
|
|
find . -maxdepth 1 -name "*.lua" -o -name "*.yaml" -o -name "*.txt" | zip dist/full.zip -@
|
|
|
|
|
zip -r dist/full.zip cn_dicts en_dicts lua opencc LICENSE
|
|
|
|
|
echo "Pack dicts ..."
|
2024-05-27 04:03:15 +02:00
|
|
|
|
zip -r dist/all_dicts.zip cn_dicts en_dicts opencc radical_pinyin.dict.yaml
|
2024-05-21 03:03:20 +02:00
|
|
|
|
echo "Pack cn_dicts ..."
|
|
|
|
|
zip -r dist/cn_dicts.zip cn_dicts
|
|
|
|
|
echo "Pack en_dicts ..."
|
|
|
|
|
zip -r dist/en_dicts.zip en_dicts
|
|
|
|
|
echo "Pack opencc ..."
|
|
|
|
|
zip -r dist/opencc.zip opencc
|
2024-07-31 18:40:44 +02:00
|
|
|
|
echo "copy LICENSE and README.md..."
|
|
|
|
|
cp LICENSE dist/LICENSE.txt
|
|
|
|
|
cp README.md dist/README.md
|
2024-05-21 03:03:20 +02:00
|
|
|
|
|
|
|
|
|
- name: Create nightly release
|
|
|
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
2024-08-20 07:04:34 +02:00
|
|
|
|
uses: "softprops/action-gh-release@v2"
|
2024-05-21 03:03:20 +02:00
|
|
|
|
with:
|
|
|
|
|
body: |
|
|
|
|
|
## 说明
|
2024-08-20 07:04:34 +02:00
|
|
|
|
|
2024-05-21 03:03:20 +02:00
|
|
|
|
这里是每次提交后自动打包的版本,包含最新的功能和词库
|
|
|
|
|
|
2024-07-31 18:40:44 +02:00
|
|
|
|
- `README.md`:简易的使用说明
|
2024-05-21 03:03:20 +02:00
|
|
|
|
- `full.zip` : 包含所有词典和方案文件
|
|
|
|
|
- `cn_dicts.zip`:中文词库
|
|
|
|
|
- `en_dicts.zip`:英文词库
|
|
|
|
|
- `opencc.zip`:opencc 词库(emoji 等)
|
|
|
|
|
- `all_dicts.zip`:以上三个词库的整合
|
2024-07-31 18:40:44 +02:00
|
|
|
|
- `LICENSE.txt`:开源协议
|
2024-05-21 03:03:20 +02:00
|
|
|
|
|
|
|
|
|
tag_name: nightly
|
2024-08-18 05:15:48 +02:00
|
|
|
|
name: "nightly build"
|
2024-05-21 03:03:20 +02:00
|
|
|
|
make_latest: true
|
|
|
|
|
files: |
|
|
|
|
|
dist/*
|
|
|
|
|
|
|
|
|
|
- name: Create stable release
|
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
2024-08-20 07:04:34 +02:00
|
|
|
|
uses: "softprops/action-gh-release@v2"
|
2024-05-21 03:03:20 +02:00
|
|
|
|
with:
|
|
|
|
|
body_path: ${{ github.workspace }}/others/CHANGELOG.md
|
|
|
|
|
draft: true
|
|
|
|
|
make_latest: true
|
|
|
|
|
files: |
|
2024-08-20 07:04:34 +02:00
|
|
|
|
dist/*
|
|
|
|
|
|
|
|
|
|
- name: Push and commit
|
|
|
|
|
if: ${{ steps.check_and_build.outcome == 'success' }}
|
|
|
|
|
run: |
|
|
|
|
|
git config --global user.name "github-actions[bot]"
|
|
|
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
|
git add --all
|
|
|
|
|
if ! git diff --cached --quiet; then
|
|
|
|
|
COMMIT_MSG=$(git log -1 --pretty=%B | sed -e 's/\s\[build\]$//' -e 's/^[a-zA-Z()]*:\s*//')
|
|
|
|
|
git commit -m "build(ci): auto build for -> ${COMMIT_MSG} <-"
|
|
|
|
|
git push
|
|
|
|
|
else
|
|
|
|
|
echo "No changes to commit."
|
|
|
|
|
fi
|