update-download-version #91
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: Update Download Version | |
| on: | |
| repository_dispatch: | |
| types: [update-download-version] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: '要更新的版本号(需要包含前面的v)' | |
| required: true | |
| type: string | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| update-version: | |
| # 添加条件判断:如果是 repository_dispatch 触发(自动触发) | |
| # 且版本号包含 "rc" 或 "beta" 或 "alpha",则跳过此 job | |
| if: ${{ github.event_name != 'repository_dispatch' || (github.event_name == 'repository_dispatch' && !contains(github.event.client_payload.version, 'rc') && !contains(github.event.client_payload.version, 'beta') && (!contains(github.event.client_payload.version, 'alpha'))) }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| latest_sha: ${{ steps.get_latest_sha.outputs.sha }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 获取完整的历史记录,以便进行文件差异比较 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.14' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| - name: Run Update Download Version Script | |
| id: run_script | |
| env: | |
| NEW_VERSION: ${{ github.event.client_payload.version || github.event.inputs.version }} | |
| run: python .github/scripts/update_download_version.py | |
| - name: Commit and push if changes | |
| id: commit_push | |
| if: success() | |
| run: | | |
| git diff --quiet cherrystudio/download.md || \ | |
| ( | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add cherrystudio/download.md | |
| git commit -m "Auto: Update download links to ${{ github.event.client_payload.version || github.event.inputs.version }}" | |
| git push | |
| ) | |
| echo "No changes to commit or changes committed." | |
| dispatch-translation-workflow: | |
| needs: update-version | |
| # 只有当 update-version 成功且确实运行了(没有被跳过),才执行此 job | |
| if: always() && needs.update-version.result == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Dispatch translate-docs workflow | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.REPO_DISPATCH_TOKEN }} # 需要一个具有 repo 权限的 token | |
| repository: CherryHQ/cherry-studio-docs # 触发自身仓库的 workflow | |
| event-type: trigger-translation # 触发 translate-docs.yml 的 trigger-translation 事件 |