|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags: |
| 8 | + - "*" |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + job_metadata: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + commit_message: ${{ steps.get_commit_message.outputs.commit_message }} |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v3 |
| 25 | + with: |
| 26 | + fetch-depth: 2 |
| 27 | + - name: Print head git commit message |
| 28 | + id: get_commit_message |
| 29 | + run: | |
| 30 | + if [[ -z "$COMMIT_MSG" ]]; then |
| 31 | + COMMIT_MSG=$(git show -s --format=%s $REF) |
| 32 | + fi |
| 33 | + echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT |
| 34 | + env: |
| 35 | + COMMIT_MSG: ${{ github.event.head_commit.message }} |
| 36 | + REF: ${{ github.event.pull_request.head.sha }} |
| 37 | + |
| 38 | + build-sdist: |
| 39 | + name: Build sdist |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v3 |
| 43 | + - name: Build sdist |
| 44 | + run: pipx run build -s |
| 45 | + - uses: actions/upload-artifact@v3 |
| 46 | + with: |
| 47 | + name: sdist |
| 48 | + path: ./dist/*.tar.gz |
| 49 | + |
| 50 | + build-wheel: |
| 51 | + name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }} |
| 52 | + needs: [job_metadata] |
| 53 | + runs-on: ${{ matrix.buildplat[0] }} |
| 54 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') || contains(needs.job_metadata.outputs.commit_message, '[build wheels]') |
| 55 | + strategy: |
| 56 | + fail-fast: false |
| 57 | + matrix: |
| 58 | + buildplat: |
| 59 | + - [ubuntu-20.04, musllinux_x86_64] |
| 60 | + - [macos-12, macosx_*] |
| 61 | + - [windows-2019, win_amd64] |
| 62 | + python: ["cp37", "cp38", "cp39", "cp310", "cp311"] |
| 63 | + include: |
| 64 | + # Manylinux builds are cheap, do all in one |
| 65 | + - { buildplat: ["ubuntu-20.04", "manylinux_x86_64"], python: "*" } |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v3 |
| 69 | + |
| 70 | + - name: Build wheel(s) |
| 71 | + run: pipx run cibuildwheel |
| 72 | + env: |
| 73 | + CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} |
| 74 | + |
| 75 | + - uses: actions/upload-artifact@v3 |
| 76 | + with: |
| 77 | + name: ${{ matrix.python == '*' && 'all' || matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }} |
| 78 | + path: ./wheelhouse/*.whl |
| 79 | + |
| 80 | + test-sdist: |
| 81 | + name: Test sdist |
| 82 | + needs: [build-sdist] |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/download-artifact@v3 |
| 86 | + with: |
| 87 | + name: sdist |
| 88 | + path: ./dist |
| 89 | + - uses: actions/setup-python@v4 |
| 90 | + with: |
| 91 | + python-version: "3.11" |
| 92 | + - name: Display Python version |
| 93 | + run: python -c "import sys; print(sys.version)" |
| 94 | + - name: Install sdist |
| 95 | + run: pip install dist/*.tar.gz |
| 96 | + - run: python -c 'import nitime; print(nitime.__version__)' |
| 97 | + - name: Install pytest |
| 98 | + run: pip install pytest |
| 99 | + - name: Run tests |
| 100 | + run: pytest -v --pyargs nitime |
| 101 | + |
| 102 | + pre-publish: |
| 103 | + runs-on: ubuntu-latest |
| 104 | + needs: [test-sdist, build-wheel] |
| 105 | + steps: |
| 106 | + - uses: actions/download-artifact@v3 |
| 107 | + with: |
| 108 | + path: dist/ |
| 109 | + - name: Check artifacts |
| 110 | + run: ls -lR |
| 111 | + - name: Consolidate and re-check |
| 112 | + run: | |
| 113 | + mv dist/*/*.{tar.gz,whl} dist |
| 114 | + rmdir dist/*/ |
| 115 | + ls -lR |
| 116 | + - run: pipx run twine check dist/* |
| 117 | + |
| 118 | + publish: |
| 119 | + runs-on: ubuntu-latest |
| 120 | + environment: "Package deployment" |
| 121 | + needs: [pre-publish] |
| 122 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| 123 | + steps: |
| 124 | + - uses: actions/download-artifact@v3 |
| 125 | + with: |
| 126 | + path: dist/ |
| 127 | + - name: Consolidate artifacts |
| 128 | + run: | |
| 129 | + mv dist/*/*.{tar.gz,whl} dist |
| 130 | + rmdir dist/*/ |
| 131 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 132 | + with: |
| 133 | + user: __token__ |
| 134 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments