|
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 | 1 | name: Build and upload to PyPI |
10 | 2 |
|
11 | 3 | on: |
12 | 4 | push: |
13 | 5 | branches: [ master ] |
| 6 | + tags: |
| 7 | + - '**' |
14 | 8 | pull_request: |
15 | 9 | branches: [ master ] |
16 | 10 | workflow_dispatch: |
17 | 11 |
|
18 | 12 | jobs: |
19 | | - build_wheels: |
20 | | - name: Build wheels manylinux |
21 | | - runs-on: ubuntu-latest |
22 | | - steps: |
23 | | - - uses: actions/checkout@v2 |
24 | | - |
25 | | - - name: Build wheels |
26 | | - |
27 | | - env: |
28 | | - CIBW_REPAIR_WHEEL_COMMAND_LINUX: "" |
29 | | - CIBW_SKIP: "*-musllinux_*" |
30 | | - CIBW_BEFORE_BUILD_LINUX: yum install -y openssl-devel libuuid-devel json-c-devel |
31 | | - CIBW_BUILD_VERBOSITY: 1 |
32 | | - |
33 | | - - uses: actions/upload-artifact@v2 |
34 | | - with: |
35 | | - path: ./wheelhouse/*.whl |
36 | | - retention-days: 5 |
37 | | - |
38 | 13 | build_sdist: |
39 | 14 | name: Build source distribution |
40 | 15 | runs-on: ubuntu-latest |
41 | 16 | steps: |
42 | | - - uses: actions/checkout@v2 |
| 17 | + - uses: actions/checkout@v3 |
43 | 18 |
|
44 | 19 | - name: Build sdist |
45 | 20 | run: pipx run build --sdist |
46 | 21 |
|
47 | | - - uses: actions/upload-artifact@v2 |
| 22 | + - uses: actions/upload-artifact@v3 |
48 | 23 | with: |
49 | 24 | path: dist/*.tar.gz |
50 | 25 | retention-days: 5 |
51 | 26 |
|
52 | | - upload_pypi: |
53 | | - needs: [build_wheels, build_sdist] |
| 27 | + upload_test_pypi: |
| 28 | + needs: [build_sdist] |
54 | 29 | runs-on: ubuntu-latest |
55 | | - if: github.event_name == 'release' && github.event.action == 'published' |
| 30 | + if: startsWith(github.ref, 'refs/tags/v') |
56 | 31 | steps: |
57 | | - - uses: actions/download-artifact@v2 |
| 32 | + - uses: actions/download-artifact@v3 |
58 | 33 | with: |
59 | 34 | name: artifact |
60 | 35 | path: dist |
61 | 36 |
|
62 | 37 | - name: Publish package to TestPyPI |
63 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 38 | + uses: pypa/gh-action-pypi-publish@release/v1.5 |
64 | 39 | with: |
65 | 40 | user: __token__ |
66 | 41 | password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
67 | 42 | repository_url: https://test.pypi.org/legacy/ |
| 43 | + |
| 44 | + upload_pypi: |
| 45 | + needs: [build_sdist] |
| 46 | + runs-on: ubuntu-latest |
| 47 | + if: startsWith(github.ref, 'refs/tags/v') |
| 48 | + steps: |
| 49 | + - uses: actions/download-artifact@v3 |
| 50 | + with: |
| 51 | + name: artifact |
| 52 | + path: dist |
| 53 | + |
| 54 | + - name: Publish package to PyPI |
| 55 | + uses: pypa/gh-action-pypi-publish@release/v1.5 |
| 56 | + with: |
| 57 | + user: __token__ |
| 58 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments