updated ci #1019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| push: | |
| branches: | |
| - master | |
| release: | |
| types: published | |
| jobs: | |
| tar_gz: | |
| name: Package | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@master | |
| - uses: actions/setup-python@master | |
| with: | |
| python-version: 3.13 | |
| - run: pip install -r requirements-build-3_13.txt | |
| - run: python setup.py sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-sdist | |
| path: dist | |
| matrix_config: | |
| name: Matrix Runner Config | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| matrix_os: ${{ steps.step.outputs.matrix_os }} | |
| steps: | |
| - run: echo "$GITHUB_EVENT_NAME" | |
| - id: step | |
| run: | | |
| if [ "$GITHUB_EVENT_NAME" = "release" ]; then | |
| echo 'matrix_os=["macos-13-xlarge", "macos-13", "ubuntu-22.04", "windows-2022"]' >> $GITHUB_OUTPUT | |
| else | |
| echo 'matrix_os=["macos-13", "ubuntu-22.04", "windows-2022"]' >> $GITHUB_OUTPUT | |
| fi | |
| wheels: | |
| name: Build / ${{ matrix.os }} / Python 3.${{ matrix.python.minor }} | |
| needs: matrix_config | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ${{ fromJson(needs.matrix_config.outputs.matrix_os) }} | |
| python: | |
| - {minor: 10, req_build: 'requirements-build-3_11.txt', req_test: 'requirements-dev-3_11.txt'} | |
| - {minor: 11, req_build: 'requirements-build-3_11.txt', req_test: 'requirements-dev-3_11.txt'} | |
| - {minor: 12, req_build: 'requirements-build-3_12.txt', req_test: 'requirements-dev-3_12.txt'} | |
| - {minor: 13, req_build: 'requirements-build-3_13.txt', req_test: 'requirements-dev-3_13.txt'} | |
| runs-on: ${{ matrix.os }} | |
| outputs: | |
| artifact_names: ${{ steps.record_artifacts.outputs.artifact_names }} | |
| steps: | |
| - uses: actions/checkout@master | |
| - uses: actions/setup-python@master | |
| - run: echo '::add-matcher::.github/problem-matchers/gcc.json' | |
| if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-') | |
| - run: echo '::add-matcher::.github/problem-matchers/msvc.json' | |
| if: startsWith(matrix.os, 'windows-') | |
| - uses: pypa/cibuildwheel@v2.23.3 | |
| if: matrix.os != 'macos-13-xlarge' | |
| with: | |
| output-dir: dist | |
| env: | |
| CIBW_BUILD: cp3${{ matrix.python.minor }}-* | |
| CIBW_ARCHS_WINDOWS: x86 AMD64 | |
| CIBW_ARCHS_MACOS: x86_64 | |
| CIBW_BEFORE_BUILD: pip install -r {project}/${{ matrix.python.req_build }} | |
| CIBW_BEFORE_TEST: pip install -r {project}/${{ matrix.python.req_test }} | |
| CIBW_TEST_COMMAND: pytest {project}/test | |
| - run: pip install pipx | |
| if: matrix.os == 'macos-13-xlarge' | |
| - uses: pypa/cibuildwheel@v2.23.3 | |
| if: matrix.os == 'macos-13-xlarge' | |
| with: | |
| output-dir: dist | |
| env: | |
| CIBW_BUILD: cp3${{ matrix.python.minor }}-macosx_arm64 | |
| CIBW_BEFORE_BUILD: pip install -r {project}/${{ matrix.python.req_build }} | |
| CIBW_BEFORE_TEST: pip install -r {project}/${{ matrix.python.req_test }} | |
| CIBW_TEST_COMMAND: pytest {project}/test | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-wheels-${{ matrix.os }}-py3${{ matrix.python.minor }} # Unique artifact name | |
| path: dist/* | |
| - name: Collect artifact name | |
| run: | | |
| echo "ARTIFACT_NAMES=${ARTIFACT_NAMES} dist-wheels-${{ matrix.os }}-py3${{ matrix.python.minor }} " >> $GITHUB_ENV | |
| - id: collect_artifacts | |
| run: echo "::set-output name=artifact_names::${{ env.ARTIFACT_NAMES }}" | |
| upload: | |
| name: Publish | |
| if: github.event_name == 'release' | |
| needs: [tar_gz, wheels] | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist-sdist | |
| path: dist | |
| - name: Download wheel artifacts using recorded names | |
| run: | | |
| for artifact in ${{ needs.wheels.outputs.artifact_names }}; do | |
| echo "Downloading artifact: $artifact" | |
| gh run download -n "$artifact" -D dist || echo "Artifact $artifact not found." | |
| done | |
| - uses: pypa/gh-action-pypi-publish@master | |
| with: | |
| password: ${{ secrets.PYPI_TOKEN }} | |
| skip_existing: true |