-
Notifications
You must be signed in to change notification settings - Fork 3
121 lines (107 loc) · 3.88 KB
/
build.yml
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
name: Build and Release
on:
push:
tags:
- '[0-9]+.*'
workflow_dispatch:
repository_dispatch:
types: [chaizi_update]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}
ref: 'build'
fetch-depth: '0'
submodules: true
- name: Set up git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Update submodule
if: github.event_name == 'repository_dispatch'
run: |
cd dict
git checkout master
git pull
- name: Update tag
if: startsWith(github.ref, 'refs/tags/')
run: |
$Date = Get-Date -Format yyyy.MM.dd
Write-output "${{ github.ref_name }}"
"# v${{ github.ref_name }} -> $Date" >> 'info.yaml'
(gc radical.schema.yaml -Raw) -replace 'version: "\d\.\d\.\d"',"version: `"${{ github.ref_name }}`"" | Out-File radical.schema.yaml
(gc radical_pinyin.schema.yaml -Raw) -replace 'version: "\d\.\d\.\d"',"version: `"${{ github.ref_name }}`"" | Out-File radical_pinyin.schema.yaml
- name: Update build branch
run: |
$Status = git status --porcelain
if ( $Status ) {
"Update submodule"
$info = (irm https://whatthecommit.com/index.txt).trim()
git add --all
git commit -m "$info" && git push origin build
}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: Build
run: |
make
- name: Update
run: |
$ErrorActionPreference = 'Break'
# $CommitInfo = Get-Date -UFormat %s
$CommitInfo = (irm https://whatthecommit.com/index.txt).trim()
git checkout master
cp gen/radical_pinyin.dict.yaml , gen/radical_pinyin.schema.yaml
cp gen/radical_flypy.dict.yaml, gen/radical.schema.yaml
$Status = git status --porcelain
if ( $Status ) {
"Push to master branch"
git add --all
git commit -m "$CommitInfo" && git push origin master
}
Compress-Archive "radical_pinyin.schema.yaml","radical_pinyin.dict.yaml" "gen/radical_pinyin.zip"
Compress-Archive "radical_flypy.dict.yaml","radical.schema.yaml" "gen/radical_flypy.zip"
Compress-Archive "lua", "build" "gen/extra.zip"
- name: Create Nightly release
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
uses: 'softprops/action-gh-release@v2.0.4'
with:
body: |
## Note
- `radical_pinyin.zip` : 包含全拼双拼的方案和词库
- `radical_flypy.zip`:仅适用于小鹤双拼的方案和词库
- `extra.zip`:辅码反查 lua 和带声调的 build 文件
tag_name: nightly
name: "nightly build"
make_latest: true
prerelease: true
generate_release_notes: true
fail_on_unmatched_files: true
files: |
gen/*.zip
- name: Create Stable release
if: startsWith(github.ref, 'refs/tags/')
uses: 'softprops/action-gh-release@v2.0.4'
with:
body: |
## Note
- `radical_pinyin.zip` : 包含全拼双拼的方案和词库
- `radical_flypy.zip`:仅适用于小鹤双拼的方案和词库
- `extra.zip`:辅码反查 lua 和带声调的 build 文件
generate_release_notes: true
draft: true
prerelease: false
make_latest: true
fail_on_unmatched_files: true
files: |
gen/*.zip
- name: Error Handling
if: ${{ failure() }}
run: exit 1