Build Wheels #388
This file contains 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
# Ref: https://github.com/scipy/scipy/blob/main/.github/workflows/windows.yml | |
# Workflow to build and test wheels. | |
# To work on the wheel building infrastructure on a fork, comment out: | |
# | |
# if: github.repository == 'has2k1/scikit-misc' | |
# | |
# in the get_commit_message job include [wheel build] in your commit | |
# message to trigger the build. All files related to wheel building are located | |
# at tools/wheels/ | |
name: Build Wheels | |
on: | |
schedule: | |
# ┌───────────── minute (0 - 59) | |
# │ ┌───────────── hour (0 - 23) | |
# │ │ ┌───────────── day of the month (1 - 31) | |
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) | |
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) | |
# │ │ │ │ │ | |
- cron: "0 0 * * 6" | |
push: | |
tags: | |
- v* | |
branches: | |
- wheels | |
workflow_dispatch: | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
parse_commit_info: | |
name: Parse Commit Information | |
runs-on: ubuntu-latest | |
if: github.repository == 'has2k1/scikit-misc' | |
outputs: | |
can_build: ${{ steps.decide.outputs.can_build }} | |
can_release: ${{ steps.decide.outputs.can_release }} | |
can_pre_release: ${{ steps.decide.outputs.can_pre_release }} | |
steps: | |
- name: Checkout scikit-misc | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Fetch all Tags | |
run: | | |
git fetch --tags --force | |
git log -n 1 | |
- name: Copy build utils | |
run: | | |
cp -r .github/utils ../utils | |
- name: Environment information | |
run: | | |
echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" | |
echo "GITHUB_SHA=$GITHUB_SHA" | |
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME" | |
echo "GITHUB_REF_TYPE=$GITHUB_REF_TYPE" | |
echo "GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME" | |
echo "git describe: $(git describe --long)" | |
- name: Debug | |
run: | | |
set -xe | |
commit_message=$(python ../utils/please.py commit_message) | |
skip_ci_message=$(python ../utils/please.py skip_ci_message) | |
skip_gha_message=$(python ../utils/please.py skip_gha_message) | |
skip_build=$(python ../utils/please.py skip_build) | |
is_wheel_build=$(python ../utils/please.py is_wheel_build) | |
- name: Decide Whether to Build and/or Release | |
id: decide | |
run: | | |
set -xe | |
CAN_BUILD=$(python ../utils/please.py can_i_build) | |
CAN_RELEASE=$(python ../utils/please.py can_i_release) | |
CAN_PRE_RELEASE=$(python ../utils/please.py can_i_pre_release) | |
echo "can_build=$CAN_BUILD" >> $GITHUB_OUTPUT | |
echo "can_release=$CAN_RELEASE" >> $GITHUB_OUTPUT | |
echo "can_pre_release=$CAN_PRE_RELEASE" >> $GITHUB_OUTPUT | |
echo github.ref ${{ github.ref }} | |
build_wheels: | |
name: Wheel, ${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
needs: parse_commit_info | |
if: contains(needs.parse_commit_info.outputs.can_build, 'true') | |
runs-on: ${{ matrix.buildplat[0] }} | |
strategy: | |
# Ensure that a wheel builder finishes even if another fails | |
fail-fast: false | |
matrix: | |
# Github Actions doesn't support pairing matrix values together, let's improvise | |
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 | |
buildplat: | |
# should also be able to do multi-archs on a single entry, e.g. | |
# [windows-2019, win*, "AMD64 x86"]. However, those two require a different compiler setup | |
# so easier to separate out here. | |
- [ubuntu-22.04, manylinux_x86_64] | |
- [macos-13, macosx_x86_64] | |
- [macos-14, macosx_arm64] | |
- [windows-2019, win_amd64] | |
python: ["cp310", "cp311", "cp312"] | |
steps: | |
- name: Checkout scikit-misc | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Fetch all Tags | |
run: | | |
git fetch --tags --force | |
echo "git describe: $(git describe --long)" | |
- name: Copy build utils | |
run: | | |
cp -r .github/utils ../utils | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Checkout build target | |
run: | | |
python ../utils/please.py checkout_build_commit | |
- name: Install pip packages | |
run: | | |
pip install wheel | |
- name: Windows - Install rtools | |
if: runner.os == 'Windows' | |
run: | | |
# mingw-w64 | |
choco install rtools -y --no-progress --force --version=4.0.0.20220206 | |
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH | |
- name: macOS - Setup | |
if: matrix.buildplat[0] == 'macos-13' || matrix.buildplat[0] == 'macos-14' | |
run: | | |
# Needed due to https://github.com/actions/runner-images/issues/3371 | |
# Supported versions: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md | |
echo "FC=gfortran-13" >> "$GITHUB_ENV" | |
echo "F77=gfortran-13" >> "$GITHUB_ENV" | |
echo "F90=gfortran-13" >> "$GITHUB_ENV" | |
CIBW="RUNNER_OS=macOS" | |
echo "CIBW_ENVIRONMENT_MACOS=$CIBW" >> "$GITHUB_ENV" | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_PRERELEASE_PYTHONS: True | |
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
- name: Check Package Version | |
run: | | |
ls wheelhouse/*.whl | |
python ../utils/check_package_version.py | |
- uses: actions/upload-artifact@v4 | |
with: | |
# @v4 does not merge artifacts with the name (even if the contents) | |
# are different. So in a matrix, we have to give each artifact a | |
# unique name. We merge these later in another job. | |
name: skmisc-wheel-${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
runs-on: ubuntu-latest | |
name: Build Source Distribution | |
needs: [build_wheels] | |
steps: | |
- name: Checkout scikit-misc | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Fetch all Tags | |
run: | | |
git fetch --tags --force | |
- name: Copy build utils | |
run: | | |
cp -r .github/utils ../utils | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Checkout build target | |
run: | | |
python ../utils/please.py checkout_build_commit | |
- name: Install Ubuntu dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install gfortran | |
- name: Install requirements | |
run: | | |
pip install uv | |
uv pip install --system ".[build]" | |
- name: Create Source Distribution | |
run: | | |
make sdist | |
- name: Check Package Version | |
run: | | |
ls dist/*.tar.gz | |
python ../utils/check_package_version.py | |
- name: Upload Source dist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: skmisc-sdist | |
path: dist/*.tar.gz | |
release: | |
runs-on: ubuntu-latest | |
name: Upload Release to PyPI | |
needs: [parse_commit_info, build_wheels, build_sdist] | |
if: contains(needs.parse_commit_info.outputs.can_release, 'true') | |
steps: | |
- name: Checkout scikit-misc | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install Release Requirements | |
run: | | |
pip install uv | |
uv pip install --system twine | |
- name: Download wheels & sdist | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: skmisc-* | |
path: dist | |
merge-multiple: true | |
- name: Publish to PyPI | |
run: | | |
ls -la ${{ github.workspace }}/dist | |
# publish wheels first so that there is no window where users | |
# may accidentally install an sdist instead of a wheel | |
twine upload --skip-existing ${{ github.workspace }}/dist/*.whl | |
twine upload --skip-existing ${{ github.workspace }}/dist/*.tar.gz | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
pre_release: | |
runs-on: ubuntu-latest | |
name: Upload Release to TestPyPI | |
needs: [parse_commit_info, build_wheels, build_sdist] | |
if: contains(needs.parse_commit_info.outputs.can_pre_release, 'true') | |
steps: | |
- name: Checkout scikit-misc | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install Release Requirements | |
run: | | |
pip install uv | |
uv pip install --system twine | |
- name: Download wheels & sdist | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: skmisc-* | |
path: dist | |
merge-multiple: true | |
- name: Publish to TestPyPI | |
run: | | |
ls -la ${{ github.workspace }}/dist | |
# publish wheels first so that there is no window where users | |
# may accidentally install an sdist instead of a wheel | |
twine upload --skip-existing --repository testpypi ${{ github.workspace }}/dist/*.whl | |
twine upload --skip-existing --repository testpypi ${{ github.workspace }}/dist/*.tar.gz | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME_TEST }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_TEST }} |