|
| 1 | +# This workflow will upload a Python Package using Twine when a release is created |
| 2 | +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
| 3 | + |
| 4 | +# This workflow uses actions that are not certified by GitHub. |
| 5 | +# They are provided by a third-party and are governed by |
| 6 | +# separate terms of service, privacy policy, and support |
| 7 | +# documentation. |
| 8 | + |
| 9 | +name: Upload Python Package |
| 10 | + |
| 11 | +on: |
| 12 | + workflow_call: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + publish: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + # use fetch --all for setuptools_scm to work |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: '3.x' |
| 30 | + - name: Install dependencies |
| 31 | + run: python -m pip install --upgrade pip twine |
| 32 | + - name: Build wheel |
| 33 | + run: python -m pip wheel -w dist --no-deps . |
| 34 | + - name: Check distribution |
| 35 | + run: twine check dist/* |
| 36 | + - name: Publish package (to TestPyPI) |
| 37 | + if: github.event_name == 'workflow_dispatch' && startsWith(github.repository, 'cpp-linter') |
| 38 | + env: |
| 39 | + TWINE_USERNAME: __token__ |
| 40 | + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} |
| 41 | + run: twine upload --repository testpypi dist/* |
| 42 | + - name: Publish package (to PyPI) |
| 43 | + if: github.event_name != 'workflow_dispatch' && startsWith(github.repository, 'cpp-linter') |
| 44 | + env: |
| 45 | + TWINE_USERNAME: __token__ |
| 46 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 47 | + run: twine upload dist/* |
0 commit comments