|
| 1 | +# reference: |
| 2 | +# - https://github.com/actions/cache |
| 3 | +# - https://github.com/actions/checkout |
| 4 | + |
| 5 | +name: ci-wheels |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - "main" |
| 13 | + - "v*x" |
| 14 | + - "!conda-lock-auto-update" |
| 15 | + - "!pre-commit-ci-update-config" |
| 16 | + - "!dependabot/*" |
| 17 | + tags: |
| 18 | + - "v*" |
| 19 | + |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-artifacts: |
| 28 | + name: "build pypi artifacts" |
| 29 | + |
| 30 | + runs-on: ubuntu-latest |
| 31 | + |
| 32 | + defaults: |
| 33 | + run: |
| 34 | + shell: bash -l {0} |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + fetch-depth: 0 |
| 40 | + |
| 41 | + - name: "build sdist and whell" |
| 42 | + run: | |
| 43 | + pipx run build |
| 44 | +
|
| 45 | + - name: "show sdist and wheel" |
| 46 | + run: | |
| 47 | + ls -l ${{ github.workspace }}/dist |
| 48 | +
|
| 49 | + - uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: pypi-artifacts-${{ github.job }}-${{ strategy.job-index }} |
| 52 | + path: ${{ github.workspace }}/dist |
| 53 | + |
| 54 | + test-artifacts: |
| 55 | + needs: [build-artifacts] |
| 56 | + name: "test wheel (${{ matrix.python-version }})" |
| 57 | + runs-on: ubuntu-latest |
| 58 | + defaults: |
| 59 | + run: |
| 60 | + shell: bash -l {0} |
| 61 | + env: |
| 62 | + ENV_CACHE_BUILD: "0" |
| 63 | + #: If you change the IRIS_SOURCE here you will also need to change it in |
| 64 | + #: the noxfile and the tests and benchmark workflows. |
| 65 | + IRIS_SOURCE: "github:main" |
| 66 | + |
| 67 | + strategy: |
| 68 | + fail-fast: false |
| 69 | + matrix: |
| 70 | + python-version: ["3.11", "3.12", "3.13"] |
| 71 | + session: ["wheel"] |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: "checkout" |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + fetch-depth: 0 |
| 78 | + |
| 79 | + - uses: actions/download-artifact@v4 |
| 80 | + with: |
| 81 | + pattern: pypi-artifacts-* |
| 82 | + path: ${{ github.workspace }}/dist |
| 83 | + merge-multiple: true |
| 84 | + |
| 85 | + - name: Install Nox |
| 86 | + run: | |
| 87 | + pip install nox |
| 88 | +
|
| 89 | + - name: Cache environment directories |
| 90 | + id: cache-env-dir |
| 91 | + uses: actions/cache@v4 |
| 92 | + with: |
| 93 | + path: | |
| 94 | + .nox |
| 95 | + $CONDA/pkgs |
| 96 | + key: ${{ runner.os }}-${{ hashFiles('requirements/locks/') }}-${{ env.ENV_CACHE_BUILD }}-${{ env.IRIS_SOURCE }}-${{ matrix.python-version }} |
| 97 | + |
| 98 | + - name: "nox install and test wheel" |
| 99 | + env: |
| 100 | + PY_VER: ${{ matrix.python-version }} |
| 101 | + run: | |
| 102 | + nox --session ${{ matrix.session }} -- --verbose |
| 103 | +
|
| 104 | + show-artifacts: |
| 105 | + needs: [build-artifacts] |
| 106 | + name: "show artifacts" |
| 107 | + runs-on: ubuntu-latest |
| 108 | + steps: |
| 109 | + - uses: actions/download-artifact@v4 |
| 110 | + with: |
| 111 | + pattern: pypi-artifacts-* |
| 112 | + path: ${{ github.workspace }}/dist |
| 113 | + merge-multiple: true |
| 114 | + |
| 115 | + - shell: bash |
| 116 | + run: | |
| 117 | + ls -l ${{ github.workspace }}/dist |
| 118 | +
|
| 119 | + publish-artifacts-test-pypi: |
| 120 | + needs: [test-artifacts] |
| 121 | + name: "Publish to Test PyPI" |
| 122 | + runs-on: ubuntu-latest |
| 123 | + # upload to Test PyPI for every commit on main branch |
| 124 | + # and check for the SciTools repo |
| 125 | + if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'SciTools' |
| 126 | + steps: |
| 127 | + - uses: actions/download-artifact@v4 |
| 128 | + with: |
| 129 | + pattern: pypi-artifacts-* |
| 130 | + path: ${{ github.workspace }}/dist |
| 131 | + merge-multiple: true |
| 132 | + |
| 133 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 134 | + with: |
| 135 | + user: __token__ |
| 136 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 137 | + repository_url: https://test.pypi.org/legacy/ |
| 138 | + skip_existing: true |
| 139 | + print_hash: true |
| 140 | + |
| 141 | + publish-artifacts-pypi: |
| 142 | + needs: [test-artifacts] |
| 143 | + name: "Publish to PyPI" |
| 144 | + runs-on: ubuntu-latest |
| 145 | + # upload to PyPI for every tag starting with 'v' |
| 146 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && github.repository_owner == 'SciTools' |
| 147 | + steps: |
| 148 | + - uses: actions/download-artifact@v4 |
| 149 | + with: |
| 150 | + pattern: pypi-artifacts-* |
| 151 | + path: ${{ github.workspace }}/dist |
| 152 | + merge-multiple: true |
| 153 | + |
| 154 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 155 | + with: |
| 156 | + user: __token__ |
| 157 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 158 | + print_hash: true |
0 commit comments