Skip to content

Update

Update #6

Workflow file for this run

name: Publish sdist and wheels
env:
SOURCE_REF_TO_BUILD: main
on:
schedule:
# 01:01 UTC every Monday and Thursday.
- cron: "1 1 * * 1,4"
pull_request:
branches:
- main
- release/**
push:
branches:
- main
workflow_dispatch:
inputs:
environment:
description: Which PyPI environment to upload to, if any
required: true
type: choice
options: ["none", "testpypi", "pypi"]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build_wheels:
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}
if: github.repository == 'scikit-learn/scikit-learn-release'
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
include:
# Window 64 bit
- os: windows-latest
python: 311
platform_id: win_amd64
- os: windows-latest
python: 312
platform_id: win_amd64
- os: windows-latest
python: 313
platform_id: win_amd64
- os: windows-latest
python: 314
platform_id: win_amd64
- os: windows-latest
python: 314t
platform_id: win_amd64
# Windows on ARM64 (WoA)
- os: windows-11-arm
python: 311
platform_id: win_arm64
- os: windows-11-arm
python: 312
platform_id: win_arm64
- os: windows-11-arm
python: 313
platform_id: win_arm64
- os: windows-11-arm
python: 314
platform_id: win_arm64
- os: windows-11-arm
python: 314t
platform_id: win_arm64
# Linux
- os: ubuntu-latest
python: 311
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 312
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 313
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 314
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 314t
platform_id: manylinux_x86_64
# Linux arm
- os: ubuntu-24.04-arm
python: 311
platform_id: manylinux_aarch64
- os: ubuntu-24.04-arm
python: 312
platform_id: manylinux_aarch64
- os: ubuntu-24.04-arm
python: 313
platform_id: manylinux_aarch64
- os: ubuntu-24.04-arm
python: 314
platform_id: manylinux_aarch64
- os: ubuntu-24.04-arm
python: 314t
platform_id: manylinux_aarch64
# MacOS x86_64
- os: macos-15-intel
python: 311
platform_id: macosx_x86_64
- os: macos-15-intel
python: 312
platform_id: macosx_x86_64
- os: macos-15-intel
python: 313
platform_id: macosx_x86_64
- os: macos-15-intel
python: 314
platform_id: macosx_x86_64
- os: macos-15-intel
python: 314t
platform_id: macosx_x86_64
# MacOS arm64
- os: macos-14
python: 311
platform_id: macosx_arm64
- os: macos-14
python: 312
platform_id: macosx_arm64
- os: macos-14
python: 313
platform_id: macosx_arm64
- os: macos-14
python: 314
platform_id: macosx_arm64
- os: macos-14
python: 314t
platform_id: macosx_arm64
steps:
- name: Checkout scikit-learn-release
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Checkout scikit-learn
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
repository: scikit-learn/scikit-learn
ref: ${{ env.SOURCE_REF_TO_BUILD }}
path: scikit-learn-src
persist-credentials: false
- uses: mamba-org/setup-micromamba@d7c9bd84e824b79d2af72a2d4196c7f4300d3476 # v3.0.0
if: ${{ startsWith(matrix.platform_id, 'macosx') }}
with:
micromamba-version: '2.8.1-0'
- name: Set-up macOS
if: ${{ startsWith(matrix.platform_id, 'macosx') }}
run: bash tools/configure_macos_env.sh
- name: Set SOURCE_DATE_EPOCH from source commit
run: |
echo "SOURCE_DATE_EPOCH=$(git -C scikit-learn-src log -1 --pretty=%ct)" >> "$GITHUB_ENV"
- name: Build and test wheels
uses: pypa/cibuildwheel@f03ac7617d6cff873ccf24cc0d567ef5ba5a9e6d # v4.0.0
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_BEFORE_TEST_WINDOWS: bash tools/build_minimal_windows_image.sh ${{ matrix.python }} ${{ matrix.platform_id }}
CIBW_TEST_COMMAND_WINDOWS: bash {project}/tools/test_windows_wheels.sh ${{ matrix.python }} {project} ${{ matrix.platform_id }}
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
PYTHONHASHSEED: "0"
CIBW_ENVIRONMENT_PASS_LINUX: SOURCE_DATE_EPOCH PYTHONHASHSEED RUNNER_OS
with:
package-dir: scikit-learn-src
output-dir: dist
config-file: cibuildwheel.toml
- name: Store artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cibw-wheels-cp${{ matrix.python }}-${{ matrix.platform_id }}
path: ./dist/*.whl
build_sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout scikit-learn-release
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Checkout scikit-learn
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
repository: scikit-learn/scikit-learn
ref: ${{ env.SOURCE_REF_TO_BUILD }}
path: scikit-learn-src
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
with:
python-version: "3.12"
- name: Build source distribution
run: bash tools/build_source.sh
- name: Test source distribution
run: bash tools/test_source.sh
- name: Store artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cibw-sdist
path: dist/*.tar.gz
testpypi-publish:
name: Publish release to TestPyPI
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi'
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]
environment:
name: testpypi
url: https://test.pypi.org/p/scikit-learn
permissions:
id-token: write # mandatory for trusted publishing
steps:
- name: Download sdist and wheels
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
merge-multiple: true
- name: View artifacts
run: ls dist
# - name: Publish
# uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
# with:
# repository-url: https://test.pypi.org/legacy/
# skip-existing: true
# print-hash: true
# attestations: true
nightly_upload:
name: Nightly upload
runs-on: ubuntu-latest
needs: [build_wheels]
steps:
- name: Download sdist and wheels
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
merge-multiple: true
- name: Install micromamba
uses: mamba-org/setup-micromamba@d7c9bd84e824b79d2af72a2d4196c7f4300d3476 # v3.0.0
with:
# For installation of anaconda-client, required for upload to anaconda.org
init-shell: bash
environment-name: upload-env
create-args: >-
anaconda-client
# - name: Upload to anaconda.org
# shell: bash -el {0} # required for micromamba
# env:
# TOKEN: ${{ secrets.SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN }}
# run: |
# anaconda -q -t ${TOKEN} upload --force -u scientific-python-nightly-wheels ./dist/*.whl
pypi-publish:
name: Publish release to PyPI
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'pypi'
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]
# environment:
# name: pypi
# url: https://pypi.org/p/scikit-learn
# permissions:
# id-token: write # mandatory for trusted publishing
steps:
- name: Download sdist and wheels
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
merge-multiple: true
- name: View artifacts
run: ls dist
# - name: Publish
# uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
# with:
# print-hash: true
# attestations: true