Build #181
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: Build | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: ["*"] | |
| schedule: # runs on last commit on main branch | |
| - cron: "0 1 * * 1" # every Monday at 1AM, for weekly wheels | |
| workflow_dispatch: # allows you to trigger manually | |
| permissions: {} | |
| # When this workflow is queued, automatically cancel any previous running | |
| # or pending jobs from the same branch | |
| concurrency: | |
| group: cidbuildwheel-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| maybe_skip_scheduled: | |
| name: Determine whether to skip scheduled run | |
| runs-on: ubuntu-latest | |
| outputs: | |
| skip: ${{ env.skip }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: On explosion main, skip scheduled run if no changes in last week | |
| if: github.event_name == 'schedule' && github.repository_owner == 'explosion' | |
| run: | | |
| LAST_COMMIT_TIME=$(git log -1 --format=%ct) | |
| CURRENT_TIME=$(date +%s) | |
| TIME_DIFF=$((CURRENT_TIME - LAST_COMMIT_TIME)) | |
| echo "Time since last commit: $TIME_DIFF seconds" | |
| if [ $TIME_DIFF -gt 604800 ]; then | |
| echo "No changes in the last week. Skipping build." | |
| echo "skip=true" >> $GITHUB_ENV | |
| else | |
| echo "Changes detected in the last week. Proceeding with build." | |
| echo "skip=false" >> $GITHUB_ENV | |
| fi | |
| - name: Always skip scheduled runs on forks | |
| if: github.event_name == 'schedule' && github.repository_owner != 'explosion' | |
| run: echo "skip=true" >> $GITHUB_ENV | |
| - name: Never skip non-scheduled runs | |
| if: github.event_name != 'schedule' | |
| run: echo "skip=false" >> $GITHUB_ENV | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| needs: maybe_skip_scheduled | |
| if: needs.maybe_skip_scheduled.outputs.skip == 'false' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: | |
| - ubuntu-latest # x64 | |
| - ubuntu-24.04-arm # ARM | |
| - macos-15-intel # x64 | |
| - macos-latest # ARM | |
| - windows-latest # x64 | |
| - windows-11-arm # ARM | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| # See https://cibuildwheel.pypa.io/en/1.x/cpp_standards/ | |
| - name: Setup MSVC on Windows x64 | |
| if: matrix.os == 'windows-latest' | |
| uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1 | |
| - name: Setup MSVC on Windows ARM64 | |
| if: matrix.os == 'windows-11-arm' | |
| uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1 | |
| with: | |
| architecture: arm64 | |
| # Install LLVM on Windows | |
| - name: Install LLVM on Windows x64 | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| choco install llvm --version=18.1.8 -y --force | |
| echo "C:\Program Files\LLVM\bin" >> $env:GITHUB_PATH | |
| - name: Install LLVM on Windows ARM64 | |
| if: matrix.os == 'windows-11-arm' | |
| shell: pwsh | |
| run: | | |
| Invoke-WebRequest https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.6/LLVM-20.1.6-woa64.exe -UseBasicParsing -OutFile LLVM-woa64.exe | |
| Start-Process -FilePath ".\LLVM-woa64.exe" -ArgumentList "/S" -Wait | |
| echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| echo "CC=clang-cl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: Debug env | |
| run: env | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@45616d2b12f67573cd48b844c047f8cda2809f43 # v3.3.0 | |
| env: | |
| CIBW_ARCHS_LINUX: auto | |
| DISTUTILS_USE_SDK: 1 | |
| MSSdk: 1 | |
| AR: llvm-ar | |
| AS: llvm-as | |
| CC: clang | |
| RANLIB: echo | |
| CIBW_BUILD_VERBOSITY: 5 | |
| with: | |
| package-dir: . | |
| output-dir: wheelhouse | |
| config-file: "{package}/pyproject.toml" | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 | |
| with: | |
| name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
| path: ./wheelhouse/*.whl | |
| build_sdist: | |
| name: Build source distribution | |
| needs: maybe_skip_scheduled | |
| if: needs.maybe_skip_scheduled.outputs.skip == 'false' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Build sdist | |
| run: pipx run build --sdist | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 | |
| with: | |
| name: cibw-sdist | |
| path: dist/*.tar.gz | |
| create_release: | |
| needs: [maybe_skip_scheduled, build_wheels, build_sdist] | |
| if: needs.maybe_skip_scheduled.outputs.skip == 'false' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| checks: write | |
| actions: read | |
| issues: read | |
| packages: write | |
| pull-requests: read | |
| repository-projects: read | |
| statuses: read | |
| steps: | |
| - name: Get the tag name and determine if it's a prerelease | |
| id: get_tag_info | |
| run: | | |
| FULL_TAG=${GITHUB_REF#refs/tags/} | |
| if [[ $FULL_TAG == release-* ]]; then | |
| TAG_NAME=${FULL_TAG#release-} | |
| IS_PRERELEASE=false | |
| elif [[ $FULL_TAG == prerelease-* ]]; then | |
| TAG_NAME=${FULL_TAG#prerelease-} | |
| IS_PRERELEASE=true | |
| else | |
| TAG_NAME=$FULL_TAG | |
| IS_PRERELEASE=false | |
| fi | |
| echo "FULL_TAG=$TAG_NAME" >> $GITHUB_ENV | |
| echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
| echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV | |
| - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 | |
| with: | |
| # unpacks all CIBW artifacts into dist/ | |
| pattern: cibw-* | |
| path: dist | |
| merge-multiple: true | |
| - name: List dist directory | |
| run: ls -l dist | |
| - name: Create Draft Release | |
| id: create_release | |
| uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2 | |
| if: (startsWith(github.ref, 'refs/tags/release-') || startsWith(github.ref, 'refs/tags/prerelease-')) && github.event_name != 'schedule' && github.repository_owner == 'explosion' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| name: ${{ env.TAG_NAME }} | |
| draft: true | |
| prerelease: ${{ env.IS_PRERELEASE }} | |
| files: "./dist/*" | |
| - name: Upload nightly wheels | |
| if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.repository_owner == 'explosion' && github.ref == 'refs/heads/main' | |
| uses: scientific-python/upload-nightly-action@b36e8c0c10dbcfd2e05bf95f17ef8c14fd708dbf # 0.6.2 | |
| with: | |
| artifacts_path: dist | |
| anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} |