@@ -2,90 +2,72 @@ name: Build and Release
22
33on :
44 push :
5- branches :
6- - master
75 tags :
86 - ' [0-9]+.*'
7+ branches :
8+ - master
9+ paths :
10+ - ' src/**'
11+ - ' radical.schema.yaml'
12+ - ' radical_pinyin.schema.yaml'
13+
14+ # 3. 允许手动触发
915 workflow_dispatch :
10- # repository_dispatch:
11- # types: [chaizi_update]
1216
1317jobs :
1418 build :
15- runs-on : windows -latest
19+ runs-on : ubuntu -latest
1620
1721 steps :
1822 - name : Checkout
19- uses : actions/checkout@v4
20- with :
21- token : ${{ secrets.TOKEN }}
22- fetch-depth : ' 0'
23- submodules : true
24-
25- - name : Set up git
26- run : |
27- git config --global user.name "github-actions[bot]"
28- git config --global user.email "github-actions[bot]@users.noreply.github.com"
29-
30- # - name: Update submodule
31- # if: github.event_name == 'repository_dispatch'
32- # run: |
33- # cd dict
34- # git checkout master
35- # git pull
23+ uses : actions/checkout@v6
3624
3725 - name : Update tag
3826 if : startsWith(github.ref, 'refs/tags/')
3927 run : |
40- $Date = Get-Date -Format yyyy.MM.dd
41- Write-output "${{ github.ref_name }}"
42- "# v${{ github.ref_name }} -> $Date" >> 'info.yaml'
43- (gc radical.schema.yaml -Raw) -replace 'version: "\d\.\d\.\d"',"version: `"${{ github.ref_name }}`"" | Out-File radical.schema.yaml
44- (gc radical_pinyin.schema.yaml -Raw) -replace 'version: "\d\.\d\.\d"',"version: `"${{ github.ref_name }}`"" | Out-File radical_pinyin.schema.yaml
45-
46- # - name: Update build branch
47- # run: |
48- # $Status = git status --porcelain
49- # if ( $Status ) {
50- # "Update submodule"
51- # $info = (irm https://whatthecommit.com/index.txt).trim()
52- # git add --all
53- # git commit -m "$info" && git push origin build
54- # }
55-
56- # - name: Set up Python
57- # uses: actions/setup-python@v5
58- # with:
59- # python-version: '3.x'
60- # cache: 'pip'
28+ DATE=$(date +'%Y.%m.%d')
29+ echo "${{ github.ref_name }}"
30+
31+ # 将版本信息追加到 dict-head-note.yaml
32+ echo "# v${{ github.ref_name }} -> $DATE" >> src/dict/dict-head-note.yaml
33+
34+ # 更新 schema 文件中的版本信息
35+ sed -i "s/version: \"[0-9]\.[0-9]\.[0-9]\"/version: \"${{ github.ref_name }}\"/g" radical.schema.yaml
36+ sed -i "s/version: \"[0-9]\.[0-9]\.[0-9]\"/version: \"${{ github.ref_name }}\"/g" radical_pinyin.schema.yaml
6137
62- # - name: Build
63- # run: |
64- # make
38+ - name : Set up Python
39+ uses : actions/setup-python@v6
40+ with :
41+ python-version : ' 3.x'
42+ cache : ' pip'
6543
66- - name : Update
44+ - name : Build
45+ working-directory : ./src
6746 run : |
68- $ErrorActionPreference = 'Break'
69- # $CommitInfo = Get-Date -UFormat %s
70- # $CommitInfo = (irm https://whatthecommit.com/index.txt).trim()
47+ make lint
48+ make
7149
72- # git checkout master
73- # cp gen/radical_pinyin.dict.yaml , gen/radical_pinyin.schema.yaml
74- # cp gen/radical_flypy.dict.yaml, gen/radical.schema.yaml
75- # $Status = git status --porcelain
76- # if ( $Status ) {
77- # "Push to master branch"
78- # git add --all
79- # git commit -m "$CommitInfo" && git push origin master
80- # }
81- mkdir gen
82- Compress-Archive "radical_pinyin.schema.yaml","radical_pinyin.dict.yaml" "gen/radical_pinyin.zip"
83- Compress-Archive "radical_flypy.dict.yaml","radical.schema.yaml" "gen/radical_flypy.zip"
84- Compress-Archive "lua", "build" "gen/extra.zip"
50+ - name : Push and pack
51+ run : |
52+ set -e
53+ COMMIT_INFO=$(curl -s https://whatthecommit.com/index.txt)
54+ if [ -n "$(git status --porcelain)" ]; then
55+ git config --global user.name "github-actions[bot]"
56+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
57+ echo "Push to changes"
58+ git add --all
59+ git commit -m "$COMMIT_INFO"
60+ git push origin master
61+ else
62+ echo "No changes to commit"
63+ fi
64+ zip radical_pinyin.zip radical_pinyin.schema.yaml radical_pinyin.dict.yaml
65+ zip radical_flypy.zip radical_flypy.dict.yaml radical.schema.yaml
66+ zip -r extra.zip lua build
8567
86- - name : Create Nightly release
68+ - name : Create nightly release
8769 if : ${{ ! startsWith(github.ref, 'refs/tags/') }}
88- uses : ' softprops/action-gh-release@v2.0.4 '
70+ uses : softprops/action-gh-release@v2
8971 with :
9072 body : |
9173 ## 文件
@@ -99,25 +81,25 @@ jobs:
9981 generate_release_notes : true
10082 fail_on_unmatched_files : true
10183 files : |
102- gen/*.zip
84+ radical_pinyin.zip
85+ radical_flypy.zip
86+ extra.zip
10387
104- - name : Create Stable release
88+ - name : Create stable release
10589 if : startsWith(github.ref, 'refs/tags/')
106- uses : ' softprops/action-gh-release@v2.0.4 '
90+ uses : softprops/action-gh-release@v2
10791 with :
10892 body : |
10993 ## 文件
11094 - `radical_pinyin.zip` : 包含全拼双拼的方案和词库
11195 - `radical_flypy.zip`:仅适用于小鹤双拼的方案和词库
11296 - `extra.zip`:辅码反查 lua 和带声调的 build 文件
11397 generate_release_notes : true
114- draft : true
98+ draft : false
11599 prerelease : false
116100 make_latest : true
117101 fail_on_unmatched_files : true
118102 files : |
119- gen/*.zip
120-
121- - name : Error Handling
122- if : ${{ failure() }}
123- run : exit 1
103+ radical_pinyin.zip
104+ radical_flypy.zip
105+ extra.zip
0 commit comments