|
1 | | -name: Publish to PyPI (Token) |
| 1 | +name: Publish to PyPI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | release: |
5 | 5 | types: [published] |
6 | | - push: |
7 | | - tags: |
8 | | - - 'v*-test' # Trigger TestPyPI on tags like v0.1.0-test |
9 | 6 | workflow_dispatch: |
10 | | - inputs: |
11 | | - environment: |
12 | | - description: 'Environment to deploy to' |
13 | | - required: true |
14 | | - default: 'testpypi' |
15 | | - type: choice |
16 | | - options: |
17 | | - - testpypi |
18 | | - - pypi |
19 | 7 |
|
20 | 8 | jobs: |
21 | 9 | build: |
22 | 10 | name: Build distribution |
23 | 11 | runs-on: ubuntu-latest |
24 | 12 |
|
25 | 13 | steps: |
26 | | - - name: Checkout code |
27 | | - uses: actions/checkout@v4 |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
28 | 16 |
|
29 | | - - name: Set up Python |
30 | | - uses: actions/setup-python@v4 |
31 | | - with: |
32 | | - python-version: '3.11' |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v4 |
| 19 | + with: |
| 20 | + python-version: "3.11" |
33 | 21 |
|
34 | | - - name: Install build dependencies |
35 | | - run: | |
36 | | - python -m pip install --upgrade pip |
37 | | - pip install build twine |
| 22 | + - name: Install build dependencies |
| 23 | + run: | |
| 24 | + python -m pip install --upgrade pip |
| 25 | + pip install build twine |
38 | 26 |
|
39 | | - - name: Build package |
40 | | - run: python -m build |
| 27 | + - name: Build package |
| 28 | + run: python -m build |
41 | 29 |
|
42 | | - - name: Check package |
43 | | - run: twine check dist/* |
| 30 | + - name: Check package |
| 31 | + run: twine check dist/* |
44 | 32 |
|
45 | | - - name: Upload artifacts |
46 | | - uses: actions/upload-artifact@v4 |
47 | | - with: |
48 | | - name: python-package-distributions |
49 | | - path: dist/ |
50 | | - |
51 | | - publish-to-testpypi: |
52 | | - name: Publish to TestPyPI |
53 | | - if: | |
54 | | - (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi') || |
55 | | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-test')) |
56 | | - needs: [build] |
57 | | - runs-on: ubuntu-latest |
58 | | - |
59 | | - steps: |
60 | | - - name: Download artifacts |
61 | | - uses: actions/download-artifact@v4 |
62 | | - with: |
63 | | - name: python-package-distributions |
64 | | - path: dist/ |
65 | | - |
66 | | - - name: Publish to TestPyPI |
67 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
68 | | - with: |
69 | | - repository-url: https://test.pypi.org/legacy/ |
70 | | - password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 33 | + - name: Upload artifacts |
| 34 | + uses: actions/upload-artifact@v4 |
| 35 | + with: |
| 36 | + name: python-package-distributions |
| 37 | + path: dist/ |
71 | 38 |
|
72 | 39 | publish-to-pypi: |
73 | 40 | name: Publish to PyPI |
74 | | - if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'pypi') |
75 | 41 | needs: [build] |
76 | 42 | runs-on: ubuntu-latest |
77 | 43 |
|
78 | 44 | steps: |
79 | | - - name: Download artifacts |
80 | | - uses: actions/download-artifact@v4 |
81 | | - with: |
82 | | - name: python-package-distributions |
83 | | - path: dist/ |
84 | | - |
85 | | - - name: Publish to PyPI |
86 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
87 | | - with: |
88 | | - password: ${{ secrets.PYPI_API_TOKEN }} |
| 45 | + - name: Download artifacts |
| 46 | + uses: actions/download-artifact@v4 |
| 47 | + with: |
| 48 | + name: python-package-distributions |
| 49 | + path: dist/ |
| 50 | + |
| 51 | + - name: Publish to PyPI |
| 52 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 53 | + with: |
| 54 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments