|
1 | | -# This workflow will upload a Python Package using Twine when a release is created |
2 | | -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
| 1 | +name: Publish 📦 |
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. |
8 | | - |
9 | | -name: Upload Python Package |
10 | | - |
11 | | -on: |
12 | | - release: |
13 | | - types: [published] |
| 3 | +on: push |
14 | 4 |
|
15 | 5 | jobs: |
16 | | - deploy: |
17 | | - |
| 6 | + build: |
| 7 | + name: Build distribution 📦 |
18 | 8 | runs-on: ubuntu-latest |
19 | 9 |
|
20 | 10 | steps: |
21 | | - - uses: actions/checkout@v3 |
| 11 | + - uses: actions/checkout@v4 |
22 | 12 | with: |
23 | 13 | submodules: recursive |
24 | 14 | - name: Set up Python |
25 | | - uses: actions/setup-python@v4 |
| 15 | + uses: actions/setup-python@v5 |
| 16 | + with: |
| 17 | + python-version: "3.x" |
| 18 | + - name: Install pypa/build |
| 19 | + run: >- |
| 20 | + python3 -m |
| 21 | + pip install |
| 22 | + build |
| 23 | + --user |
| 24 | + - name: Build a binary wheel and a source tarball |
| 25 | + run: python3 -m build |
| 26 | + - name: Store the distribution packages |
| 27 | + uses: actions/upload-artifact@v4 |
| 28 | + with: |
| 29 | + name: python-package-distributions |
| 30 | + path: dist/ |
| 31 | + |
| 32 | + publish-to-pypi: |
| 33 | + name: >- |
| 34 | + Publish to PyPi |
| 35 | + if: startsWith(github.ref, 'refs/tags/') |
| 36 | + needs: |
| 37 | + - build |
| 38 | + runs-on: ubuntu-latest |
| 39 | + environment: |
| 40 | + name: pypi |
| 41 | + url: https://pypi.org/p/pyElli/ |
| 42 | + permissions: |
| 43 | + id-token: write |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Download all the dists |
| 47 | + uses: actions/download-artifact@v4 |
| 48 | + with: |
| 49 | + name: python-package-distributions |
| 50 | + path: dist/ |
| 51 | + - name: Publish distribution 📦 to PyPI |
| 52 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 53 | + |
| 54 | + github-release: |
| 55 | + name: >- |
| 56 | + GitHub Release |
| 57 | + needs: |
| 58 | + - publish-to-pypi |
| 59 | + runs-on: ubuntu-latest |
| 60 | + |
| 61 | + permissions: |
| 62 | + contents: write |
| 63 | + id-token: write |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Download all the dists |
| 67 | + uses: actions/download-artifact@v4 |
26 | 68 | with: |
27 | | - python-version: '3.x' |
28 | | - - name: Install dependencies |
29 | | - run: | |
30 | | - python -m pip install --upgrade pip |
31 | | - pip install build |
32 | | - - name: Build package |
33 | | - run: python -m build |
34 | | - - name: Publish package |
35 | | - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 |
| 69 | + name: python-package-distributions |
| 70 | + path: dist/ |
| 71 | + - name: Sign the dists with Sigstore |
| 72 | + |
36 | 73 | with: |
37 | | - user: __token__ |
38 | | - password: ${{ secrets.PYPI_API_TOKEN }} |
| 74 | + inputs: >- |
| 75 | + ./dist/*.tar.gz |
| 76 | + ./dist/*.whl |
| 77 | + - name: Create GitHub Release |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: ${{ github.token }} |
| 80 | + run: >- |
| 81 | + gh release create |
| 82 | + '${{ github.ref_name }}' |
| 83 | + --repo '${{ github.repository }}' |
| 84 | + --notes "" |
| 85 | + - name: Upload artifact signatures to GitHub Release |
| 86 | + env: |
| 87 | + GITHUB_TOKEN: ${{ github.token }} |
| 88 | + run: >- |
| 89 | + gh release upload |
| 90 | + '${{ github.ref_name }}' dist/** |
| 91 | + --repo '${{ github.repository }}' |
0 commit comments