chore: 新增 desktop 目录 #2
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
| # 每次推送到 main 或推送 tag (v*) 时构建并发布到 PyPI | |
| name: Publish to PyPI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Install build | |
| run: uv pip install --system build | |
| # 每次提交(push 到 main)用唯一 dev 版本,避免 PyPI 409;打 tag 时用 tag 版本 | |
| - name: Set package version | |
| id: version | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| else | |
| BASE=$(grep '^version = ' pyproject.toml | sed -n 's/.*"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p') | |
| VERSION="${BASE}.dev${{ github.run_number }}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| sed -i 's/^version = .*/version = "'"$VERSION"'"/' pyproject.toml | |
| - name: Build package | |
| run: python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| repository-url: https://upload.pypi.org/legacy/ | |
| - name: Create GitHub Release (attach dist) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: Release ${{ github.ref_name }} | |
| files: dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |