chaizi_update #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
"# v${{ github.ref }} -> $Date" >> 'info.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 |