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: Tag/Release and Publish to PyPI via Trusted Publisher | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| jobs: | |
| update-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # 确保可以获取完整的分支信息 | |
| - name: Switch to main branch | |
| run: | | |
| git checkout main # 将 "main" 替换为你的默认分支名 | |
| - name: Update _version.py | |
| run: | | |
| TAG_NAME=$(echo ${{ github.ref_name }}) | |
| echo "__version__ = '${TAG_NAME}'[1:]" > pyfmm/_version.py | |
| - name: Commit changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add pyfmm/_version.py | |
| git commit -m "Update version to ${{ github.ref_name }}" | |
| git push origin main # 推送到 "main" 分支 | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.9" | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade setuptools wheel build | |
| - name: Build the package | |
| run: | | |
| python setup.py sdist bdist_wheel | |
| - name: Pypi Publish | |
| uses: pypa/gh-action-pypi-publish@release/v1 |