|
| 1 | +# Reference: |
| 2 | +# - https://github.com/actions/checkout |
| 3 | +# - https://github.com/actions/download-artifact |
| 4 | +# - https://github.com/actions/upload-artifact |
| 5 | +# - https://github.com/pypa/cibuildwheel |
| 6 | +# - https://github.com/pypa/build |
| 7 | +# - https://github.com/pypa/gh-action-pypi-publish |
| 8 | +# - https://test.pypi.org/help/#apitoken |
| 9 | + |
| 10 | +name: ci-wheels |
| 11 | + |
| 12 | +on: |
| 13 | + pull_request: |
| 14 | + |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - "master" |
| 18 | + - "v*x" |
| 19 | + - "!auto-update-lockfiles" |
| 20 | + - "!pre-commit-ci-update-config" |
| 21 | + - "!dependabot/*" |
| 22 | + tags: |
| 23 | + - "v*" |
| 24 | + |
| 25 | +jobs: |
| 26 | + build_bdist: |
| 27 | + name: "build ${{ matrix.os }} wheels" |
| 28 | + runs-on: ${{ matrix.os }} |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + os: ["ubuntu-latest", "macos-latest", "windows-latest"] |
| 33 | + |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v3 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: "build ${{ matrix.os }} wheels" |
| 40 | + |
| 41 | + env: |
| 42 | + CIBW_SKIP: "cp36-* cp37-* pp* *-musllinux*" |
| 43 | + CIBW_ARCHS_LINUX: "x86_64" |
| 44 | + CIBW_ARCHS_MACOS: "x86_64 arm64" |
| 45 | + CIBW_ARCHS_WINDOWS: "AMD64" |
| 46 | + CIBW_BUILD_FRONTEND: "build" |
| 47 | + CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014" |
| 48 | + CIBW_TEST_SKIP: "*-macosx_arm64" |
| 49 | + CIBW_TEST_REQUIRES: "pytest" |
| 50 | + CIBW_TEST_COMMAND: > |
| 51 | + python -m pytest --pyargs stratify |
| 52 | +
|
| 53 | + - uses: actions/upload-artifact@v3 |
| 54 | + with: |
| 55 | + name: pypi-artifacts |
| 56 | + path: ${{ github.workspace }}/wheelhouse/*.whl |
| 57 | + |
| 58 | + |
| 59 | + build_sdist: |
| 60 | + name: "Build sdist" |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v3 |
| 64 | + with: |
| 65 | + fetch-depth: 0 |
| 66 | + |
| 67 | + - name: "Building sdist" |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + pipx run build --sdist |
| 71 | +
|
| 72 | + - uses: actions/upload-artifact@v3 |
| 73 | + with: |
| 74 | + name: pypi-artifacts |
| 75 | + path: ${{ github.workspace }}/dist/*.tar.gz |
| 76 | + |
| 77 | + |
| 78 | + show-artifacts: |
| 79 | + needs: [build_bdist, build_sdist] |
| 80 | + name: "Show artifacts" |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: actions/download-artifact@v3 |
| 84 | + with: |
| 85 | + name: pypi-artifacts |
| 86 | + path: ${{ github.workspace }}/dist |
| 87 | + |
| 88 | + - shell: bash |
| 89 | + run: | |
| 90 | + ls -l ${{ github.workspace }}/dist |
| 91 | +
|
| 92 | +
|
| 93 | + publish-artifacts-test-pypi: |
| 94 | + needs: [build_bdist, build_sdist] |
| 95 | + name: "Publish to Test PyPI" |
| 96 | + runs-on: ubuntu-latest |
| 97 | + # upload to Test PyPI for every commit on master branch |
| 98 | + if: github.event_name == 'push' && github.event.ref == 'refs/heads/master' |
| 99 | + steps: |
| 100 | + - uses: actions/download-artifact@v3 |
| 101 | + with: |
| 102 | + name: pypi-artifacts |
| 103 | + path: ${{ github.workspace }}/dist |
| 104 | + |
| 105 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 106 | + with: |
| 107 | + user: __token__ |
| 108 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 109 | + repository_url: https://test.pypi.org/legacy/ |
| 110 | + skip_existing: true |
| 111 | + print_hash: true |
| 112 | + |
| 113 | + |
| 114 | + publish-artifacts-pypi: |
| 115 | + needs: [build_bdist, build_sdist] |
| 116 | + name: "Publish to PyPI" |
| 117 | + runs-on: ubuntu-latest |
| 118 | + # upload to PyPI for every tag starting with 'v' |
| 119 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 120 | + steps: |
| 121 | + - uses: actions/download-artifact@v3 |
| 122 | + with: |
| 123 | + name: pypi-artifacts |
| 124 | + path: ${{ github.workspace }}/dist |
| 125 | + |
| 126 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 127 | + with: |
| 128 | + user: __token__ |
| 129 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 130 | + print_hash: true |
0 commit comments