|
1 |
| -# This workflows 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 |
3 |
| -# https://www.caktusgroup.com/blog/2021/02/11/automating-pypi-releases/ |
| 1 | +# This workflows will upload a Python Package for tagged commits |
| 2 | +# For more information see: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ |
4 | 3 |
|
5 |
| -name: Published |
| 4 | +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI |
6 | 5 |
|
7 |
| -on: |
| 6 | +on: |
8 | 7 | release:
|
9 | 8 | types: [created]
|
10 | 9 |
|
11 | 10 | jobs:
|
12 |
| - deploy: |
13 |
| - |
| 11 | + build: |
| 12 | + name: Build distribution 📦 |
14 | 13 | runs-on: ubuntu-latest
|
15 | 14 |
|
16 | 15 | steps:
|
17 |
| - - uses: actions/checkout@v3 |
| 16 | + - uses: actions/checkout@v4 |
18 | 17 | - name: Set up Python
|
19 |
| - uses: actions/setup-python@v3 |
| 18 | + uses: actions/setup-python@v4 |
| 19 | + with: |
| 20 | + python-version: "3.11" |
| 21 | + - name: Install pypa/build |
| 22 | + run: >- |
| 23 | + python3 -m |
| 24 | + pip install |
| 25 | + build |
| 26 | + --user |
| 27 | + - name: Build a source distribution |
| 28 | + run: python3 -m build |
| 29 | + - name: Store the distribution packages |
| 30 | + uses: actions/upload-artifact@v3 |
| 31 | + with: |
| 32 | + name: python-package-distributions |
| 33 | + path: dist/ |
| 34 | + |
| 35 | + publish-to-pypi: |
| 36 | + name: >- |
| 37 | + Publish Python 🐍 distribution 📦 to PyPI |
| 38 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 39 | + needs: |
| 40 | + - build |
| 41 | + runs-on: ubuntu-latest |
| 42 | + environment: |
| 43 | + name: release |
| 44 | + url: https://pypi.org/project/astroviper |
| 45 | + permissions: |
| 46 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Download all the dists |
| 50 | + uses: actions/download-artifact@v3 |
20 | 51 | with:
|
21 |
| - python-version: '3.11' |
22 |
| - - name: Install dependencies |
23 |
| - run: | |
24 |
| - python -m pip install --upgrade pip |
25 |
| - pip install setuptools wheel twine build |
26 |
| - - name: Build and publish |
27 |
| - env: |
28 |
| - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
29 |
| - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
30 |
| - run: | |
31 |
| - python -m build |
32 |
| - twine upload dist/* |
| 52 | + name: python-package-distributions |
| 53 | + path: dist/ |
| 54 | + - name: Publish distribution 📦 to PyPI |
| 55 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments