|
| 1 | +# SPDX-FileCopyrightText: 2023 Forschungszentrum Jülich GmbH (FZJ) |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: CC0-1.0 |
| 4 | + |
| 5 | +# SPDX-FileContributor: Oliver Bertuch |
| 6 | + |
| 7 | +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + - develop |
| 14 | + tags: |
| 15 | + - 'v**' |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + name: Build distribution 📦 |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v4 |
| 26 | + with: |
| 27 | + python-version: "3.10" |
| 28 | + - name: Install pypa/build |
| 29 | + run: >- |
| 30 | + python3 -m |
| 31 | + pip install |
| 32 | + build |
| 33 | + --user |
| 34 | + - name: Build a binary wheel and a source tarball |
| 35 | + run: python3 -m build |
| 36 | + - name: Store the distribution packages |
| 37 | + uses: actions/upload-artifact@v3 |
| 38 | + with: |
| 39 | + name: python-package-distributions |
| 40 | + path: dist/ |
| 41 | + |
| 42 | + publish-to-pypi: |
| 43 | + name: >- |
| 44 | + Publish Python 🐍 distribution 📦 to PyPI |
| 45 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 46 | + needs: |
| 47 | + - build |
| 48 | + runs-on: ubuntu-latest |
| 49 | + environment: |
| 50 | + name: pypi |
| 51 | + url: https://pypi.org/p/hermes |
| 52 | + permissions: |
| 53 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Download all the dists |
| 57 | + uses: actions/download-artifact@v3 |
| 58 | + with: |
| 59 | + name: python-package-distributions |
| 60 | + path: dist/ |
| 61 | + - name: Publish distribution 📦 to PyPI |
| 62 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 63 | + |
| 64 | + # Commented out for now, until we decide to actually use GitHub Releases |
| 65 | + # |
| 66 | + #github-release: |
| 67 | + # name: >- |
| 68 | + # Sign the Python 🐍 distribution 📦 with Sigstore |
| 69 | + # and upload them to GitHub Release |
| 70 | + # needs: |
| 71 | + # - publish-to-pypi |
| 72 | + # runs-on: ubuntu-latest |
| 73 | + # permissions: |
| 74 | + # contents: write # IMPORTANT: mandatory for making GitHub Releases |
| 75 | + # id-token: write # IMPORTANT: mandatory for sigstore |
| 76 | + # steps: |
| 77 | + # - name: Download all the dists |
| 78 | + # uses: actions/download-artifact@v3 |
| 79 | + # with: |
| 80 | + # name: python-package-distributions |
| 81 | + # path: dist/ |
| 82 | + # - name: Sign the dists with Sigstore |
| 83 | + # uses: sigstore/gh-action-sigstore-python@v1.2.3 |
| 84 | + # with: |
| 85 | + # inputs: >- |
| 86 | + # ./dist/*.tar.gz |
| 87 | + # ./dist/*.whl |
| 88 | + # - name: Create GitHub Release |
| 89 | + # env: |
| 90 | + # GITHUB_TOKEN: ${{ github.token }} |
| 91 | + # run: >- |
| 92 | + # gh release create |
| 93 | + # '${{ github.ref_name }}' |
| 94 | + # --repo '${{ github.repository }}' |
| 95 | + # --notes "" |
| 96 | + # - name: Upload artifact signatures to GitHub Release |
| 97 | + # env: |
| 98 | + # GITHUB_TOKEN: ${{ github.token }} |
| 99 | + # # Upload to GitHub Release using the `gh` CLI. |
| 100 | + # # `dist/` contains the built packages, and the |
| 101 | + # # sigstore-produced signatures and certificates. |
| 102 | + # run: >- |
| 103 | + # gh release upload |
| 104 | + # '${{ github.ref_name }}' dist/** |
| 105 | + # --repo '${{ github.repository }}' |
| 106 | + |
| 107 | + # Releasing to TestPyPI has been removed with commit d6f78804. |
| 108 | + # See https://github.com/hermes-hmc/hermes/commit/d6f78804 to see the removed parts. |
0 commit comments