|
1 | 1 | name: Deployment |
| 2 | + |
2 | 3 | on: [push, pull_request] |
| 4 | + |
3 | 5 | jobs: |
4 | | - has: |
5 | | - name: Check Secrets |
6 | | - runs-on: ubuntu-latest |
7 | | - steps: |
8 | | - - id: secrets |
9 | | - env: |
10 | | - test_pypi_token: ${{ secrets.TEST_PYPI_TOKEN }} |
11 | | - pypi_token: ${{ secrets.PYPI_TOKEN }} |
12 | | - if: ${{ env.test_pypi_token != '' && env.pypi_token != '' }} |
13 | | - run: |
14 | | - echo "::set-output name=secrets::1" |
15 | | - outputs: |
16 | | - secrets: ${{ steps.secrets.outputs.secrets }} |
17 | | - build-and-publish: |
18 | | - needs: has |
| 6 | + build: |
| 7 | + name: Build distribution |
19 | 8 | runs-on: ubuntu-latest |
20 | 9 | steps: |
21 | 10 | - uses: actions/checkout@v4 |
| 11 | + with: |
| 12 | + fetch-depth: 0 |
| 13 | + |
22 | 14 | - uses: actions/setup-python@v5 |
| 15 | + |
23 | 16 | - name: Install dependencies |
24 | | - run: pip install build twine |
| 17 | + run: pip install build |
| 18 | + |
25 | 19 | - name: Build a binary wheel and a source tarball |
26 | 20 | run: python3 -m build |
27 | | - - name: Publish distribution 📦 to Test PyPI |
28 | | - if: ${{ needs.has.outputs.secrets }} |
| 21 | + |
| 22 | + - name: Store the distribution packages |
| 23 | + uses: actions/upload-artifact@v4 |
| 24 | + with: |
| 25 | + name: python-package-distributions |
| 26 | + path: dist/ |
| 27 | + |
| 28 | + publish-to-testpypi: |
| 29 | + name: Publish to TestPyPI |
| 30 | + if: "!startsWith(github.ref, 'refs/tags')" |
| 31 | + needs: build |
| 32 | + runs-on: ubuntu-latest |
| 33 | + environment: |
| 34 | + name: testpypi |
| 35 | + url: https://test.pypi.org/p/sphinxcontrib-django |
| 36 | + permissions: |
| 37 | + id-token: write |
| 38 | + steps: |
| 39 | + - name: Download all the dists |
| 40 | + uses: actions/download-artifact@v4 |
| 41 | + with: |
| 42 | + name: python-package-distributions |
| 43 | + path: dist/ |
| 44 | + |
| 45 | + - name: Publish distribution 📦 to TestPyPI |
29 | 46 | uses: pypa/gh-action-pypi-publish@release/v1 |
30 | 47 | with: |
31 | | - password: ${{ secrets.TEST_PYPI_TOKEN }} |
32 | | - repository_url: https://test.pypi.org/legacy/ |
33 | | - skip_existing: true |
| 48 | + repository-url: https://test.pypi.org/legacy/ |
| 49 | + |
| 50 | + publish-to-pypi: |
| 51 | + name: Publish to PyPI |
| 52 | + if: startsWith(github.ref, 'refs/tags') |
| 53 | + needs: build |
| 54 | + runs-on: ubuntu-latest |
| 55 | + environment: |
| 56 | + name: pypi |
| 57 | + url: https://pypi.org/p/sphinxcontrib-django |
| 58 | + permissions: |
| 59 | + id-token: write |
| 60 | + steps: |
| 61 | + - name: Download all the dists |
| 62 | + uses: actions/download-artifact@v4 |
| 63 | + with: |
| 64 | + name: python-package-distributions |
| 65 | + path: dist/ |
| 66 | + |
34 | 67 | - name: Publish distribution 📦 to PyPI |
35 | | - if: startsWith(github.ref, 'refs/tags') |
36 | 68 | uses: pypa/gh-action-pypi-publish@release/v1 |
37 | | - with: |
38 | | - password: ${{ secrets.PYPI_TOKEN }} |
|
0 commit comments