|
1 | 1 | # This workflow will upload a Python Package using Twine when a release is created |
2 | 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 | 3 |
|
4 | | -name: Upload Python Package to PyPI |
| 4 | +name: Upload Python Package |
5 | 5 |
|
6 | 6 | on: |
7 | 7 | release: |
8 | 8 | types: [created] |
9 | 9 |
|
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
10 | 13 | jobs: |
11 | 14 | deploy: |
12 | 15 |
|
13 | 16 | runs-on: ubuntu-latest |
14 | | - env: |
15 | | - FASTAPI_FF: '{"json_only": False, "file_1": True, "file_2": False, "file_3": True, "file_4": True}' |
16 | | - |
| 17 | + |
17 | 18 | steps: |
18 | | - - uses: actions/checkout@v2 |
| 19 | + - uses: actions/checkout@v3 |
19 | 20 | - name: Set up Python |
20 | | - uses: actions/setup-python@v2 |
| 21 | + uses: actions/setup-python@v3 |
21 | 22 | with: |
22 | 23 | python-version: '3.x' |
| 24 | + - name: Install Poetry |
| 25 | + uses: snok/install-poetry@v1 |
| 26 | + with: |
| 27 | + virtualenvs-create: true |
| 28 | + virtualenvs-in-project: true |
| 29 | + installer-parallel: true |
| 30 | + - name: Load cached venv |
| 31 | + id: cached-poetry-dependencies |
| 32 | + uses: actions/cache@v3 |
| 33 | + with: |
| 34 | + path: .venv |
| 35 | + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} |
23 | 36 | - name: Install dependencies |
24 | | - run: | |
25 | | - python -m pip install --upgrade pip |
26 | | - python -m pip install pytest pytest-cov |
27 | | - python -m pip install setuptools wheel twine |
28 | | - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
29 | | - - name: Tests with pytest |
30 | | - run: | |
31 | | - python3 -m pytest --cov=fastapi_featureflags -v tests/ --disable-warnings |
32 | | - - name: Build and publish |
33 | | - env: |
34 | | - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
35 | | - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
36 | | - run: | |
37 | | - python setup.py sdist bdist_wheel |
38 | | - twine upload dist/* |
| 37 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 38 | + run: poetry install --no-interaction --no-root |
| 39 | + |
| 40 | + - name: Build package |
| 41 | + run: |
| 42 | + source .venv/bin/activate |
| 43 | + poetry build |
| 44 | + - name: Publish package |
| 45 | + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 |
| 46 | + with: |
| 47 | + user: __token__ |
| 48 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 49 | + |
| 50 | + |
0 commit comments