|
1 |
| -name: Publish Python 🐍 distributions 📦 to PyPI |
| 1 | +name: Publish |
2 | 2 |
|
3 | 3 | on:
|
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
4 | 7 | release:
|
5 |
| - types: [published] |
6 |
| - |
| 8 | + types: |
| 9 | + - published |
| 10 | + |
7 | 11 | jobs:
|
8 |
| - build-n-publish: |
9 |
| - name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI |
10 |
| - runs-on: ubuntu-18.04 |
| 12 | + build: |
| 13 | + name: Build package |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v3 |
| 18 | + - name: Set up Python |
| 19 | + uses: actions/setup-python@v4 |
| 20 | + with: |
| 21 | + python-version: 3.11 |
| 22 | + - name: Install Poetry |
| 23 | + uses: snok/install-poetry@v1 |
| 24 | + with: |
| 25 | + virtualenvs-create: false |
| 26 | + version: 1.5.0 |
| 27 | + - name: Build package distribution |
| 28 | + run: poetry build |
| 29 | + - name: Upload package artifact |
| 30 | + uses: actions/upload-artifact@v3 |
| 31 | + with: |
| 32 | + name: distribution |
| 33 | + path: dist |
| 34 | + test-release: |
| 35 | + name: Publish release to Test PyPI |
| 36 | + if: github.event_name != 'release' |
| 37 | + runs-on: ubuntu-latest |
| 38 | + needs: build |
| 39 | + environment: |
| 40 | + name: test |
| 41 | + url: https://test.pypi.org/p/openapi-pydantic |
| 42 | + permissions: |
| 43 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
11 | 44 | steps:
|
12 |
| - - uses: actions/checkout@master |
13 |
| - - name: Set up Python 3.7 |
14 |
| - uses: actions/setup-python@v1 |
| 45 | + - name: Download package distribution |
| 46 | + uses: actions/download-artifact@v3 |
| 47 | + with: |
| 48 | + name: distribution |
| 49 | + path: dist |
| 50 | + - name: Publish package distribution to Test PyPI |
| 51 | + uses: pypa/gh-action-pypi-publish@release/v1 |
15 | 52 | with:
|
16 |
| - python-version: 3.7 |
17 |
| - - name: Install pypa/build |
18 |
| - run: >- |
19 |
| - python -m |
20 |
| - pip install |
21 |
| - build |
22 |
| - --user |
23 |
| - - name: Build a binary wheel and a source tarball |
24 |
| - run: >- |
25 |
| - python -m |
26 |
| - build |
27 |
| - --sdist |
28 |
| - --wheel |
29 |
| - --outdir dist/ |
30 |
| - . |
31 |
| - - name: Publish distribution 📦 to PyPI |
32 |
| - if: startsWith(github.ref, 'refs/tags') |
33 |
| - uses: pypa/gh-action-pypi-publish@master |
| 53 | + repository-url: https://test.pypi.org/legacy/ |
| 54 | + release: |
| 55 | + name: Publish release to PyPI |
| 56 | + if: github.event_name == 'release' |
| 57 | + runs-on: ubuntu-latest |
| 58 | + needs: build |
| 59 | + environment: |
| 60 | + name: production |
| 61 | + url: https://pypi.org/p/openapi-pydantic |
| 62 | + permissions: |
| 63 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 64 | + steps: |
| 65 | + - name: Download package distribution |
| 66 | + uses: actions/download-artifact@v3 |
34 | 67 | with:
|
35 |
| - password: ${{ secrets.PYPI_API_TOKEN }} |
| 68 | + name: distribution |
| 69 | + path: dist |
| 70 | + - name: Publish package distribution to PyPI |
| 71 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments