|
3 | 3 | # GitHub: https://github.com/btschwertfeger
|
4 | 4 | #
|
5 | 5 | # Template workflow to build the project and publish
|
6 |
| -# the package to PyPI. It can be used to publish on the |
7 |
| -# test index and the "live" PyPI index. |
| 6 | +# the package to PyPI. |
8 | 7 | #
|
9 | 8 |
|
10 | 9 | name: PyPI Publish
|
11 | 10 |
|
12 | 11 | on:
|
13 | 12 | workflow_call:
|
14 |
| - inputs: |
15 |
| - REPOSITORY_URL: |
16 |
| - type: string |
17 |
| - required: true |
18 | 13 | secrets:
|
19 | 14 | API_TOKEN:
|
20 | 15 | required: true
|
21 | 16 |
|
22 | 17 | permissions: read-all
|
23 | 18 |
|
24 | 19 | jobs:
|
25 |
| - PyPI-Publish: |
26 |
| - name: Upload to ${{ inputs.REPOSITORY_URL }} |
| 20 | + publish-to-pypi: |
| 21 | + name: Publish Python distribution to PyPI |
27 | 22 | runs-on: ubuntu-latest
|
28 | 23 | permissions:
|
29 | 24 | id-token: write # IMPORTANT: this permission is mandatory for OIDC publishing
|
30 |
| - |
| 25 | + environment: |
| 26 | + name: pypi |
| 27 | + url: https://pypi.org/p/python-cmethods |
31 | 28 | steps:
|
32 |
| - - name: Checkout repository |
33 |
| - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 |
34 |
| - with: |
35 |
| - fetch-depth: 0 # IMPORTANT: otherwise the current tag does not get fetched and the build version gets worse |
36 |
| - |
37 |
| - - name: Set up Python 3.11 |
38 |
| - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 |
| 29 | + - name: Download all the distributions |
| 30 | + uses: actions/download-artifact@v4 |
39 | 31 | with:
|
40 |
| - python-version: 3.11 |
41 |
| - |
42 |
| - - name: Install dependencies |
43 |
| - run: | |
44 |
| - python -m pip install --upgrade pip |
45 |
| -
|
46 |
| - - name: Check git status |
47 |
| - run: | |
48 |
| - if [[ -z "$(git status --porcelain)" ]]; then |
49 |
| - echo "No changes found." |
50 |
| - else |
51 |
| - echo "Changes detected. Please commit or discard changes before publishing." |
52 |
| - git status --porcelain |
53 |
| - exit 1 |
54 |
| - fi |
55 |
| -
|
56 |
| - - name: Build the package |
57 |
| - run: python -m pip wheel -w dist --no-deps . |
| 32 | + name: python-package-distributions |
| 33 | + path: dist/ |
58 | 34 |
|
59 | 35 | - name: Publish package distributions to PyPI (optional - testpypi)
|
60 | 36 | uses: pypa/gh-action-pypi-publish@release/v1
|
61 | 37 | with:
|
62 | 38 | password: ${{ secrets.API_TOKEN }}
|
63 |
| - repository-url: ${{ inputs.REPOSITORY_URL }} |
| 39 | + repository-url: https://upload.pypi.org/legacy/ |
0 commit comments