publish.yml
This file
Path
.github/workflows/publish.yml
95 lines · 2.4 KiB · YAML
Last changed by
Bump the actions group with 2 updates (#7596)dependabot[bot]before adoption414f051
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596name: Publish to PyPI
on: push: tags: - "v*" workflow_dispatch: inputs: test-pypi-only: description: "Publish to Test PyPI only" type: boolean default: true
permissions: contents: read
jobs: build: name: "Build dists" runs-on: "ubuntu-latest" outputs: artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
steps: - name: "Checkout repository" uses: "actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0" # v7.0.0 with: persist-credentials: false
- name: "Setup Python" uses: "actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97" # v7.0.0 with: python-version: "3.x"
- name: "Install dependencies" run: python -m pip install build==1.4.0
- name: "Build dists" run: | SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) \ python -m build
- name: "Upload dists" uses: "actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f" id: upload-artifact with: name: "dist" path: "dist/" if-no-files-found: error retention-days: 5
publish: name: "Publish" if: startsWith(github.ref, 'refs/tags/') needs: ["build"] permissions: id-token: write runs-on: "ubuntu-latest" environment: name: "publish"
steps: - name: "Download dists" uses: "actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3" # v8.0.0 with: artifact-ids: ${{ needs.build.outputs.artifact-id }} path: "dist/"
- name: "Publish dists to PyPI" uses: "pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b" # v1.14.0 with: attestations: true
publish-test-pypi: name: "Publish to Test PyPI" if: github.event_name == 'workflow_dispatch' needs: ["build"] permissions: id-token: write runs-on: "ubuntu-latest" environment: name: "testpypi"
steps: - name: "Download dists" uses: "actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3" # v8.0.0 with: artifact-ids: ${{ needs.build.outputs.artifact-id }} path: "dist/"
- name: "Publish dists to Test PyPI" uses: "pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b" # v1.14.0 with: repository-url: https://test.pypi.org/legacy/ attestations: true