|
1 | | -# This workflow uploads PyLops on PyPI 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 | +# This workflow uploads PyLops on PyPI when a release is created |
| 2 | +# For more information see: https://github.com/python-attrs/attrs/blob/main/.github/workflows/pypi-package.yml |
3 | 3 | name: PyLops-deploy |
4 | 4 |
|
5 | 5 | on: |
| 6 | + push: |
| 7 | + tags: ["*"] |
6 | 8 | release: |
7 | | - types: [published] |
| 9 | + types: |
| 10 | + - published |
| 11 | + workflow_dispatch: |
8 | 12 |
|
9 | 13 | jobs: |
10 | | - deploy: |
| 14 | + build-package: |
| 15 | + name: Build & verify package |
11 | 16 | runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Check out source repository |
| 20 | + uses: actions/checkout@v6 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + - name: Build and inspect package |
| 24 | + uses: hynek/build-and-inspect-python-package@v2 |
| 25 | + |
| 26 | + release-test-pypi: |
| 27 | + name: Publish in-dev package to test.pypi.org |
| 28 | + if: github.repository_owner == 'PyLops' && github.ref_type == 'tag' |
| 29 | + runs-on: ubuntu-latest |
| 30 | + needs: build-package |
| 31 | + permissions: |
| 32 | + contents: read |
| 33 | + id-token: write |
| 34 | + |
12 | 35 | steps: |
13 | | - - uses: actions/checkout@v2 |
14 | | - - name: Set up Python |
15 | | - uses: actions/setup-python@v2 |
| 36 | + - name: Download package |
| 37 | + uses: actions/download-artifact@v8 |
16 | 38 | with: |
17 | | - python-version: '3.x' |
18 | | - - name: Install dependencies |
19 | | - run: | |
20 | | - python -m pip install --upgrade pip |
21 | | - pip install build |
22 | | - - name: Build package |
23 | | - run: python -m build |
24 | | - - name: Publish package |
| 39 | + name: Packages |
| 40 | + path: dist |
| 41 | + |
| 42 | + - name: Upload package to Test PyPI |
| 43 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 44 | + with: |
| 45 | + attestations: true |
| 46 | + repository-url: https://test.pypi.org/legacy/ |
| 47 | + |
| 48 | + release-pypi: |
| 49 | + name: Publish released package to pypi.org |
| 50 | + if: github.repository_owner == 'PyLops' && github.event.action == 'published' |
| 51 | + runs-on: ubuntu-latest |
| 52 | + needs: build-package |
| 53 | + permissions: |
| 54 | + contents: read |
| 55 | + id-token: write |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Download package |
| 59 | + uses: actions/download-artifact@v8 |
| 60 | + with: |
| 61 | + name: Packages |
| 62 | + path: dist |
| 63 | + |
| 64 | + - name: Upload package to PyPI |
25 | 65 | uses: pypa/gh-action-pypi-publish@release/v1 |
26 | 66 | with: |
27 | | - user: __token__ |
28 | | - password: ${{ secrets.PYPI_API_TOKEN }} |
| 67 | + attestations: true |
0 commit comments