|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
| 7 | + tags: |
| 8 | + - "v*" |
7 | 9 | pull_request: |
8 | 10 | branches: |
9 | 11 | - main |
|
42 | 44 |
|
43 | 45 | - name: Test with python ${{ matrix.python-version }} |
44 | 46 | run: uv run --frozen -m pytest |
| 47 | + |
| 48 | + build: |
| 49 | + name: Build package |
| 50 | + runs-on: ubuntu-latest |
| 51 | + needs: [test] |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Install the latest version of uv and set the python version |
| 56 | + uses: astral-sh/setup-uv@v5 |
| 57 | + with: |
| 58 | + python-version: 3.12 |
| 59 | + |
| 60 | + - name: Build |
| 61 | + run: uv build |
| 62 | + |
| 63 | + - name: Store the distribution packages |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: python-package-distributions |
| 67 | + path: dist/ |
| 68 | + |
| 69 | + publish-to-pypi: |
| 70 | + name: Publish to PyPI |
| 71 | + runs-on: ubuntu-latest |
| 72 | + if: "startsWith(github.ref, 'refs/tags/')" |
| 73 | + needs: [build] |
| 74 | + environment: |
| 75 | + name: pypi |
| 76 | + url: https://pypi.org/p/santander-python-sdk |
| 77 | + permissions: |
| 78 | + id-token: write |
| 79 | + steps: |
| 80 | + - name: Download all the dists |
| 81 | + uses: actions/download-artifact@v4 |
| 82 | + with: |
| 83 | + name: python-package-distributions |
| 84 | + path: dist/ |
| 85 | + - name: Publish distribution 📦 to PyPI |
| 86 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 87 | + |
| 88 | + github-release: |
| 89 | + name: GitHub Release |
| 90 | + needs: |
| 91 | + - publish-to-pypi |
| 92 | + runs-on: ubuntu-latest |
| 93 | + |
| 94 | + permissions: |
| 95 | + contents: write |
| 96 | + id-token: write |
| 97 | + |
| 98 | + steps: |
| 99 | + - name: Download all the dists |
| 100 | + uses: actions/download-artifact@v4 |
| 101 | + with: |
| 102 | + name: python-package-distributions |
| 103 | + path: dist/ |
| 104 | + - name: Sign the dists with Sigstore |
| 105 | + |
| 106 | + with: |
| 107 | + inputs: >- |
| 108 | + ./dist/*.tar.gz |
| 109 | + ./dist/*.whl |
| 110 | + - name: Create GitHub Release |
| 111 | + env: |
| 112 | + GITHUB_TOKEN: ${{ github.token }} |
| 113 | + run: >- |
| 114 | + gh release create |
| 115 | + '${{ github.ref_name }}' |
| 116 | + --repo '${{ github.repository }}' |
| 117 | + --notes "" |
| 118 | + - name: Upload artifact signatures to GitHub Release |
| 119 | + env: |
| 120 | + GITHUB_TOKEN: ${{ github.token }} |
| 121 | + # Upload to GitHub Release using the `gh` CLI. |
| 122 | + # `dist/` contains the built packages, and the |
| 123 | + # sigstore-produced signatures and certificates. |
| 124 | + run: >- |
| 125 | + gh release upload |
| 126 | + '${{ github.ref_name }}' dist/** |
| 127 | + --repo '${{ github.repository }}' |
0 commit comments