fix(bagel): 优化国际化处理逻辑并增强代码健壮性 #89
Workflow file for this run
This file contains hidden or 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 | |
| on: | |
| push: | |
| # Sequence of patterns matched against refs/tags | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| env: | |
| PYTHONIOENCODING: 'UTF-8' | |
| strategy: | |
| matrix: | |
| python-version: [ 3.12 ] | |
| permissions: | |
| actions: write | |
| contents: write | |
| steps: | |
| - name: Configure git | |
| run: | | |
| [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| git config --global user.email "110257560+BnanZ0@users.noreply.github.com" | |
| git config --global user.name "RU" | |
| echo "action_state=yellow" >> $env:GITHUB_ENV | |
| echo "${{ env.action_state }}" | |
| - uses: actions/checkout@v6 | |
| with: | |
| lfs: true | |
| fetch-depth: 0 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set UTF-8 encoding | |
| run: | | |
| set PYTHONIOENCODING=utf-8 | |
| set PYTHONLEGACYWINDOWSSTDIO=utf-8 | |
| echo PYTHONIOENCODING=utf-8 >> $GITHUB_ENV | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| - name: inline_ok_requirements #把ok-script加入源码, 从requirements.txt中删除以提高升级更新速度 | |
| run: | | |
| python -m ok.update.inline_ok_requirements --tag ${{ github.ref_name }} | |
| - name: Run tests | |
| run: | | |
| Get-ChildItem -Path ".\tests\*.py" | ForEach-Object { | |
| Write-Host "Running tests in $($_.FullName)" | |
| try { | |
| # Run the Python unittest command | |
| python -m unittest $_.FullName | |
| # Check if the previous command succeeded | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "Tests failed in $($_.FullName)" | |
| } | |
| } catch { | |
| # Stop the loop and return the error | |
| Write-Error $_ | |
| exit 1 | |
| } | |
| } | |
| - name: Sync Repositories # 同步部分代码(deploy.txt中), 合并tag中间更新日志, 到更新库, 以减少用户更新使用的git库大小 | |
| id: sync # Give the step an ID to access its outputs | |
| uses: ok-oldking/partial-sync-repo@bbd55c1dffbcc1292a12295d949e7807b35ea93e # Replace with your action path | |
| with: | |
| repos: | | |
| https://cnb:${{ secrets.CNB_GH }}@cnb.cool/BnanZ0/ok-nte-update.git | |
| https://BnanZ0:${{ secrets.OK_GH }}@github.com/BnanZ0/ok-nte-update.git | |
| sync_list: 'deploy.txt' | |
| tag: ${{ github.ref_name }} | |
| gitignore_file: '.update_repo_gitignore' | |
| show_author: true #在更新日志中加入作者 | |
| - name: Check release version | |
| id: release-version | |
| shell: pwsh | |
| env: | |
| REF_NAME: ${{ github.ref_name }} | |
| run: | | |
| $tag = $env:REF_NAME | |
| $isRelease = $tag -match '^v?\d+\.\d+\.\d+$' | |
| "is_release=$($isRelease.ToString().ToLowerInvariant())" >> $env:GITHUB_OUTPUT | |
| Write-Host "Release version: $isRelease" | |
| - name: Build with PyAppify Action | |
| if: steps.release-version.outputs.is_release == 'true' | |
| id: build-app | |
| uses: ok-oldking/pyappify-action@master #使用pyappify打包exe | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| build_exe_only: false | |
| # 使用上一个稳定版本的 Release 来获取已打包的启动器,从而跳过耗时的打包过程 | |
| # use_release: https://api.github.com/repos/BnanZ0/ok-nte/releases/tags/v0.0.53 | |
| - name: Release | |
| uses: softprops/action-gh-release@v3 | |
| if: steps.release-version.outputs.is_release == 'true' && startsWith(github.ref, 'refs/tags/') | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| body: | | |
| ### 更新日志 ${{ steps.sync.outputs.start_tag }} -> ${{ steps.sync.outputs.end_tag }}: | |
| ${{ steps.sync.outputs.changes_with_asterisk }} | |
| ### 下载包说明 | |
| * [ok-nte-win32-China-setup.exe](https://github.com/BnanZ0/ok-nte/releases/download/${{ github.ref_name }}/ok-nte-win32-China-setup.exe) 完整安装包, 更新使用阿里云+腾讯CNB. | |
| * [ok-nte-win32-online-setup.exe](https://github.com/BnanZ0/ok-nte/releases/download/${{ github.ref_name }}/ok-nte-win32-online-setup.exe) 在线安装包, 在线白嫖的服务器不一定稳定, 建议优先使用完整包. | |
| * [ok-nte-win32-Global-setup.exe](https://github.com/BnanZ0/ok-nte/releases/download/${{ github.ref_name }}/ok-nte-win32-Global-setup.exe) full package with dependencies, using GitHub and PyPi as update source | |
| * 不要下载ok-nte-win32.zip,和SourceCode.zip, Do Not Download the SourceCode, ok-nte-win32.zip | |
| ### 如果无法下载或下载慢, 可以使用其他下载源 | |
| * [Mirror酱下载渠道](https://mirrorchyan.com/zh/projects?rid=ok-nte&channel=stable), 国内网页直链, 下载需要购买CD-KEY, 已有Mirror酱CD-KEY可免费下载 | |
| * [百度网盘](https://pan.baidu.com/s/102Mh1djq2B1T-cIJhct9Gg?pwd=okww) 免费下载 | |
| * [夸克网盘](https://pan.quark.cn/s/418018ddf7a0) 免费下载 | |
| draft: false | |
| prerelease: false | |
| make_latest: true | |
| files: pyappify_dist/* | |
| - name: Trigger MirrorChyanUploading | |
| if: steps.release-version.outputs.is_release == 'true' && startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| run: | | |
| gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release.yml -f tag=${{ github.ref_name }} | |
| gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note.yml -f tag=${{ github.ref_name }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |