|
62 | 62 | with: |
63 | 63 | path: dist/ |
64 | 64 |
|
| 65 | + upload_test_pypi: # Upload to TestPyPi first to ensure that the release is OK (we will try to download it and install it afterwards), as recommended in https://py-pkgs.org/08-ci-cd#uploading-to-testpypi-and-pypi |
| 66 | + name: Upload to TestPyPi |
| 67 | + needs: [test, build] |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - name: Unpack default artifact into dist/ |
| 71 | + uses: actions/download-artifact@v3 |
| 72 | + with: |
| 73 | + # unpacks default artifact into dist/ |
| 74 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 75 | + name: artifact |
| 76 | + path: dist |
| 77 | + |
| 78 | + - name: Upload to TestPyPi |
| 79 | + uses: pypa/gh-action-pypi-publish@v1.5.0 |
| 80 | + with: |
| 81 | + user: __token__ |
| 82 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 83 | + repository_url: https://test.pypi.org/legacy/ |
| 84 | + # To test: repository_url: https://test.pypi.org/legacy/ # and also change token: ${{ secrets.PYPI_API_TOKEN }} to secrets.TEST_PYPI_API_TOKEN # for more infos on registering and using TestPyPi, read: https://py-pkgs.org/08-ci-cd#uploading-to-testpypi-and-pypi -- remove the repository_url to upload to the real PyPi |
| 85 | + |
| 86 | + - name: Test install from TestPyPI |
| 87 | + run: | |
| 88 | + python -m pip install --upgrade pip |
| 89 | + pip install \ |
| 90 | + --index-url https://test.pypi.org/simple/ \ |
| 91 | + --extra-index-url https://pypi.org/simple \ |
| 92 | + pyFileFixity |
| 93 | +
|
| 94 | + upload_pypi: # Upload to the real PyPi if everything else worked before, as suggested in: https://py-pkgs.org/08-ci-cd#uploading-to-testpypi-and-pypi |
| 95 | + name: Upload to the real PyPi |
| 96 | + needs: [test, build, upload_test_pypi] |
| 97 | + runs-on: ubuntu-latest |
| 98 | + steps: |
| 99 | + - uses: actions/download-artifact@v3 |
| 100 | + with: |
| 101 | + # unpacks default artifact into dist/ |
| 102 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 103 | + name: artifact |
| 104 | + path: dist |
65 | 105 |
|
| 106 | + - uses: pypa/gh-action-pypi-publish@v1.5.0 |
| 107 | + with: |
| 108 | + user: __token__ |
| 109 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments