|
7 | 7 | inputs: |
8 | 8 | pypi_target: |
9 | 9 | description: 'PyPI target (pypi or testpypi)' |
10 | | - default: 'testpypi' |
| 10 | + default: 'pypi' |
11 | 11 | type: choice |
12 | 12 | options: |
13 | 13 | - pypi |
14 | 14 | - testpypi |
15 | 15 |
|
16 | 16 | jobs: |
17 | | - build-and-publish: |
| 17 | + publish: |
18 | 18 | runs-on: ubuntu-latest |
| 19 | + environment: pypi |
19 | 20 | permissions: |
20 | | - contents: read |
21 | 21 | id-token: write |
22 | 22 |
|
23 | 23 | steps: |
24 | | - - uses: actions/checkout@v6 |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + persist-credentials: false |
25 | 27 |
|
26 | | - - name: Set up Python 3.11 |
27 | | - uses: actions/setup-python@v6 |
| 28 | + - name: Set up Python 3.12 |
| 29 | + uses: actions/setup-python@v5 |
28 | 30 | with: |
29 | | - python-version: "3.11" |
| 31 | + python-version: "3.12" |
30 | 32 |
|
31 | | - - name: Install build deps |
| 33 | + - name: Install dependencies |
32 | 34 | run: | |
| 35 | + python -m pip install --upgrade pip |
33 | 36 | pip install build twine |
34 | 37 |
|
35 | 38 | - name: Lint with ruff |
36 | 39 | run: pip install ruff && ruff check src/ --target-version py310 |
37 | 40 |
|
38 | 41 | - name: Build package |
39 | | - run: | |
40 | | - python -m build |
| 42 | + run: python -m build |
41 | 43 |
|
42 | | - - name: Publish to PyPI |
43 | | - if: ${{ inputs.pypi_target != 'testpypi' || github.event_name == 'release' }} |
44 | | - env: |
45 | | - TWINE_USERNAME: __token__ |
46 | | - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
47 | | - run: | |
48 | | - twine upload dist/* --verbose |
| 44 | + - name: Check package |
| 45 | + run: twine check dist/* |
49 | 46 |
|
50 | 47 | - name: Publish to TestPyPI |
51 | 48 | if: ${{ inputs.pypi_target == 'testpypi' }} |
52 | | - env: |
53 | | - TWINE_USERNAME: __token__ |
54 | | - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} |
55 | | - run: | |
56 | | - twine upload --repository testpypi dist/* --verbose |
| 49 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 50 | + with: |
| 51 | + repository-url: https://test.pypi.org/legacy/ |
57 | 52 |
|
| 53 | + - name: Publish to PyPI |
| 54 | + if: ${{ inputs.pypi_target == 'pypi' || github.event_name == 'release' }} |
| 55 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments