name: 🚀 发布到 PyPI on: push: tags: ['v*'] permissions: contents: read concurrency: group: nonebot-pypi-${{ github.ref }} cancel-in-progress: false jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: persist-credentials: false - uses: actions/setup-python@v7 with: python-version: '3.10' - name: Verify generated files run: python verify_package.py --directory . - name: Check tag matches package version env: RELEASE_TAG: ${{ github.ref_name }} run: | python - <<'PY' import os from pathlib import Path version = Path('version.txt').read_text().strip() if os.environ['RELEASE_TAG'] != 'v' + version: raise SystemExit('Tag differs from version.txt') PY - run: python -m pip install build twine - run: python -m build --sdist --wheel --outdir ../packages - run: python -m twine check ../packages/* - uses: actions/upload-artifact@v7 with: name: pypi-distributions path: ../packages/* if-no-files-found: error publish: needs: build if: github.repository == 'Shu-Ying/nonebot_plugin_farm' runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v8 with: name: pypi-distributions path: dist - name: 📤 发布到 PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_TOKEN }}