|
1 | | -# This workflow will upload a Python Package using Twine when a release is created |
2 | | -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries |
| 1 | +name: Publish Python 🐍 distribution 📦 to PyPI |
3 | 2 |
|
4 | | -# This workflow uses actions that are not certified by GitHub. |
5 | | -# They are provided by a third-party and are governed by |
6 | | -# separate terms of service, privacy policy, and support |
7 | | -# documentation. |
| 3 | +on: push |
8 | 4 |
|
9 | | -name: Upload Python Package |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: Build distribution 📦 |
| 8 | + runs-on: ubuntu-latest |
10 | 9 |
|
11 | | -on: |
12 | | - release: |
13 | | - types: [published] |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + - name: Set up Python |
| 13 | + uses: actions/setup-python@v4 |
| 14 | + with: |
| 15 | + python-version: "3.x" |
| 16 | + - name: Install pypa/build |
| 17 | + run: >- |
| 18 | + python3 -m |
| 19 | + pip install |
| 20 | + build |
| 21 | + --user |
| 22 | + - name: Build a binary wheel and a source tarball |
| 23 | + run: python3 -m build |
| 24 | + - name: Store the distribution packages |
| 25 | + uses: actions/upload-artifact@v3 |
| 26 | + with: |
| 27 | + name: python-package-distributions |
| 28 | + path: dist/ |
14 | 29 |
|
15 | | -permissions: |
16 | | - contents: read |
| 30 | + publish-to-pypi: |
| 31 | + name: >- |
| 32 | + Publish Python 🐍 distribution 📦 to PyPI |
| 33 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 34 | + needs: |
| 35 | + - build |
| 36 | + runs-on: ubuntu-latest |
| 37 | + environment: |
| 38 | + name: pypi |
| 39 | + url: https://pypi.org/p/certbot-dns-synergy-wholesale |
| 40 | + permissions: |
| 41 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
17 | 42 |
|
18 | | -jobs: |
19 | | - deploy: |
| 43 | + steps: |
| 44 | + - name: Download all the dists |
| 45 | + uses: actions/download-artifact@v3 |
| 46 | + with: |
| 47 | + name: python-package-distributions |
| 48 | + path: dist/ |
| 49 | + - name: Publish distribution 📦 to PyPI |
| 50 | + uses: pypa/gh-action-pypi-publish@release/v1 |
20 | 51 |
|
| 52 | + github-release: |
| 53 | + name: >- |
| 54 | + Sign the Python 🐍 distribution 📦 with Sigstore |
| 55 | + and upload them to GitHub Release |
| 56 | + needs: |
| 57 | + - publish-to-pypi |
21 | 58 | runs-on: ubuntu-latest |
22 | 59 |
|
| 60 | + permissions: |
| 61 | + contents: write # IMPORTANT: mandatory for making GitHub Releases |
| 62 | + id-token: write # IMPORTANT: mandatory for sigstore |
| 63 | + |
23 | 64 | steps: |
24 | | - - uses: actions/checkout@v3 |
25 | | - - name: Set up Python |
26 | | - uses: actions/setup-python@v3 |
| 65 | + - name: Download all the dists |
| 66 | + uses: actions/download-artifact@v3 |
27 | 67 | with: |
28 | | - python-version: '3.x' |
29 | | - - name: Install dependencies |
30 | | - run: | |
31 | | - python -m pip install --upgrade pip |
32 | | - pip install build |
33 | | - - name: Build package |
34 | | - run: python -m build |
35 | | - - name: Publish package |
36 | | - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 |
| 68 | + name: python-package-distributions |
| 69 | + path: dist/ |
| 70 | + - name: Sign the dists with Sigstore |
| 71 | + |
37 | 72 | with: |
38 | | - user: __token__ |
39 | | - password: ${{ secrets.PYPI_API_TOKEN }} |
| 73 | + inputs: >- |
| 74 | + ./dist/*.tar.gz |
| 75 | + ./dist/*.whl |
| 76 | + - name: Create GitHub Release |
| 77 | + env: |
| 78 | + GITHUB_TOKEN: ${{ github.token }} |
| 79 | + run: >- |
| 80 | + gh release create |
| 81 | + '${{ github.ref_name }}' |
| 82 | + --repo '${{ github.repository }}' |
| 83 | + --notes "" |
| 84 | + - name: Upload artifact signatures to GitHub Release |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ github.token }} |
| 87 | + # Upload to GitHub Release using the `gh` CLI. |
| 88 | + # `dist/` contains the built packages, and the |
| 89 | + # sigstore-produced signatures and certificates. |
| 90 | + run: >- |
| 91 | + gh release upload |
| 92 | + '${{ github.ref_name }}' dist/** |
| 93 | + --repo '${{ github.repository }}' |
0 commit comments