|
1 |
| -# For more information see: https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ |
2 |
| - |
3 |
| -name: Publish Python 🐍 distributions 📦 to TestPyPI and PyPI |
| 1 | +name: Publish Python distribution |
4 | 2 |
|
5 | 3 | on:
|
6 |
| - release: |
7 |
| - types: [published] |
8 |
| - |
9 |
| -jobs: |
10 |
| - deploy: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
11 | 7 |
|
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Build distribution |
12 | 11 | runs-on: ubuntu-latest
|
13 | 12 |
|
14 | 13 | steps:
|
15 |
| - - uses: actions/checkout@v2 |
| 14 | + - uses: actions/checkout@v4 |
16 | 15 | - name: Set up Python
|
17 |
| - uses: actions/setup-python@v2 |
| 16 | + uses: actions/setup-python@v4 |
| 17 | + with: |
| 18 | + python-version: "3.8" |
| 19 | + - name: Install pypa/build |
| 20 | + run: >- |
| 21 | + python3 -m |
| 22 | + pip install |
| 23 | + build |
| 24 | + --user |
| 25 | + - name: Build a binary wheel and a source tarball |
| 26 | + run: python3 -m build |
| 27 | + - name: Store the distribution packages |
| 28 | + uses: actions/upload-artifact@v3 |
| 29 | + with: |
| 30 | + name: python-package-distributions |
| 31 | + path: dist/ |
| 32 | + |
| 33 | + publish-to-pypi: |
| 34 | + name: Publish to PyPI |
| 35 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 36 | + needs: |
| 37 | + - build |
| 38 | + runs-on: ubuntu-latest |
| 39 | + environment: |
| 40 | + name: pypi |
| 41 | + url: https://pypi.org/p/lc-sdk-python |
| 42 | + permissions: |
| 43 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Download all the dists |
| 47 | + uses: actions/download-artifact@v3 |
| 48 | + with: |
| 49 | + name: python-package-distributions |
| 50 | + path: dist/ |
| 51 | + - name: Publish to PyPI |
| 52 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 53 | + |
| 54 | + publish-to-testpypi: |
| 55 | + name: Publish to TestPyPI |
| 56 | + needs: |
| 57 | + - build |
| 58 | + runs-on: ubuntu-latest |
| 59 | + |
| 60 | + environment: |
| 61 | + name: testpypi |
| 62 | + url: https://test.pypi.org/p/lc-sdk-python |
| 63 | + |
| 64 | + permissions: |
| 65 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Download all the dists |
| 69 | + uses: actions/download-artifact@v3 |
| 70 | + with: |
| 71 | + name: python-package-distributions |
| 72 | + path: dist/ |
| 73 | + - name: Publish to TestPyPI |
| 74 | + uses: pypa/gh-action-pypi-publish@release/v1 |
18 | 75 | with:
|
19 |
| - python-version: 3.8 |
20 |
| - - name: Install dependencies |
21 |
| - run: | |
22 |
| - python -m pip install --upgrade pip |
23 |
| - pip install setuptools wheel twine |
24 |
| - - name: Build and publish to TestPyPI |
25 |
| - env: |
26 |
| - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
27 |
| - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
28 |
| - run: | |
29 |
| - python setup.py sdist bdist_wheel |
30 |
| - twine upload --repository testpypi dist/* |
31 |
| - - name: Build and publish to PyPI |
32 |
| - env: |
33 |
| - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
34 |
| - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
35 |
| - run: | |
36 |
| - python setup.py sdist bdist_wheel |
37 |
| - twine upload dist/* |
38 |
| - |
| 76 | + skip-existing: true |
| 77 | + repository-url: https://test.pypi.org/legacy/ |
0 commit comments