|
1 | 1 | name: Publish Pypi
|
2 | 2 | on:
|
3 | 3 | release:
|
4 |
| - types: [published] |
| 4 | + types: [ published ] |
5 | 5 |
|
6 | 6 | jobs:
|
7 |
| - publish: |
8 |
| - name: publish |
| 7 | + pytest: |
| 8 | + name: Publish to PyPi |
9 | 9 | runs-on: ubuntu-latest
|
| 10 | + env: |
| 11 | + ACTIONS_ALLOW_UNSECURE_COMMANDS: true |
10 | 12 | steps:
|
11 | 13 | - uses: actions/checkout@master
|
12 |
| - - name: Set up Python 2.7 |
| 14 | + - name: Set up Python 3.7 |
13 | 15 | uses: actions/setup-python@v1
|
14 | 16 | with:
|
15 |
| - python-version: 2.7 |
| 17 | + python-version: 3.7 |
16 | 18 |
|
17 |
| - - name: Install twine |
18 |
| - run: | |
19 |
| - pip install twine |
20 |
| -
|
21 |
| - - name: Install wheel |
22 |
| - run: | |
23 |
| - pip install wheel |
24 |
| -
|
25 |
| - - name: Create a source distribution |
26 |
| - run: | |
27 |
| - python setup.py sdist |
| 19 | + - name: Install Poetry |
| 20 | + |
28 | 21 |
|
29 |
| - - name: Create a wheel |
30 |
| - run: | |
31 |
| - python setup.py bdist_wheel |
| 22 | + - name: Cache Poetry virtualenv |
| 23 | + uses: actions/cache@v1 |
| 24 | + id: cache |
| 25 | + with: |
| 26 | + path: ~/.virtualenvs |
| 27 | + key: poetry-${{ hashFiles('**/poetry.lock') }} |
| 28 | + restore-keys: | |
| 29 | + poetry-${{ hashFiles('**/poetry.lock') }} |
32 | 30 |
|
33 |
| - - name: Create a .pypirc |
| 31 | + - name: Set Poetry config |
34 | 32 | run: |
|
35 |
| - echo -e "[pypi]" >> ~/.pypirc |
36 |
| - echo -e "username = __token__" >> ~/.pypirc |
37 |
| - echo -e "password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc |
38 |
| - echo -e "[testpypi]" >> ~/.pypirc |
39 |
| - echo -e "username = __token__" >> ~/.pypirc |
40 |
| - echo -e "password = ${{ secrets.TESTPYPI_TOKEN }}" >> ~/.pypirc |
| 33 | + poetry config virtualenvs.in-project false |
| 34 | + poetry config virtualenvs.path ~/.virtualenvs |
41 | 35 |
|
42 |
| - - name: Publish to Test PyPI |
43 |
| - if: github.event_name == 'release' |
44 |
| - run: | |
45 |
| - twine upload --skip-existing -r testpypi dist/* |
| 36 | + - name: Install Dependencies |
| 37 | + run: poetry install |
| 38 | + if: steps.cache.outputs.cache-hit != 'true' |
46 | 39 |
|
47 | 40 | - name: Publish to PyPI
|
48 | 41 | if: github.event_name == 'release'
|
49 | 42 | run: |
|
50 |
| - twine upload -r pypi dist/* |
| 43 | + poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} --build |
0 commit comments