Publish to test.pypi.org #154
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
name: CI | |
on: | |
push: | |
branches: ["**"] # For now, let's build all branches. Roll this back if it gets too slow or we exhaust our quota. | |
pull_request: | |
branches: ["**"] # * does not match '/' | |
workflow_dispatch: # For manually triggering a build: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_dispatch | |
jobs: | |
build: | |
strategy: | |
matrix: | |
# We mainly care about hardware rather than OS | |
# macos-13 is x86 | |
# macos-latest is arm64 | |
# ubuntu-latest is x64 | |
os: [ubuntu-latest, macos-latest, macos-13] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
# Build (and test) Lean. Tests are all via #guard macros | |
# now so you can't really build without testing. | |
- uses: leanprover/lean-action@v1 | |
- name: Run tests | |
run: lake exe klr | |
# Run pytest | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
cache: 'pip' | |
- name: Install dependencies | |
working-directory: ./interop | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run pytest | |
working-directory: ./interop | |
run: | | |
pytest | |
- name: Make a wheel | |
# https://github.com/pypa/cibuildwheel | |
# Hit this: https://github.com/pypa/cibuildwheel/discussions/1926 | |
env: | |
# https://github.com/leanprover/lean4/pull/6631/files | |
MACOSX_DEPLOYMENT_TARGET: 99.0 | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_SKIP: 'pp* *-win32 *-manylinux_i686 *-musllinux_*' # The build doesn't work 686 or musl | |
run: | | |
pip install cibuildwheel | |
bin/make-wheel | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
path: ./.wheel/wheelhouse/*.whl | |
if-no-files-found: error | |
# Mostly followed guides here: | |
# - https://github.com/pypa/gh-action-pypi-publish?tab=readme-ov-file | |
# - https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
# NB: I needed to set the trusted publisher to repo NKL, not KLR, since that was its original name. Scary detail! No idea how I'd figure that out without knowing the original name. | |
publish-to-testpypi: | |
name: Publish Python 🐍 distribution 📦 to TestPyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
# name: python-package-distributions | |
# # unpacks all CIBW artifacts into dist/ | |
# pattern: cibw-* | |
path: dist/ | |
merge-multiple: true | |
- name: List the wheels | |
run: | | |
ls -1 dist/ | |
# Example output: | |
# klr-0.0.3-cp310-cp310-macosx_99_0_arm64.whl | |
# klr-0.0.3-cp310-cp310-macosx_99_0_x86_64.whl | |
# klr-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | |
# klr-0.0.3-cp311-cp311-macosx_99_0_arm64.whl | |
# klr-0.0.3-cp311-cp311-macosx_99_0_x86_64.whl | |
# klr-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | |
# klr-0.0.3-cp312-cp312-macosx_99_0_arm64.whl | |
# klr-0.0.3-cp312-cp312-macosx_99_0_x86_64.whl | |
# klr-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | |
# klr-0.0.3-cp313-cp313-macosx_99_0_arm64.whl | |
# klr-0.0.3-cp313-cp313-macosx_99_0_x86_64.whl | |
# klr-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | |
# klr-0.0.3-cp38-cp38-macosx_99_0_arm64.whl | |
# klr-0.0.3-cp38-cp38-macosx_99_0_x86_64.whl | |
# klr-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | |
# klr-0.0.3-cp39-cp39-macosx_99_0_arm64.whl | |
# klr-0.0.3-cp39-cp39-macosx_99_0_x86_64.whl | |
# klr-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | |
- name: Rename OSX wheels | |
# pypi can't handle the 99.0 version tags. We need to move those back to versions it is OK with | |
# This should be OK; we only bumped the version because Lake required it, and OSX is | |
# backward compatible so we can run older versions on newer machines. | |
run: | | |
echo "Renaming x86 wheels" | |
suffix=macosx_99_0_x86_64 | |
for file in *; do | |
if [[ "$file" == *"$suffix"* ]]; then | |
newname=$(echo "$file" | sed "s/$suffix/macosx_13_0_x86_64/g") | |
mv $file $newname | |
echo "Renamed: $file -> $newname" | |
fi | |
done | |
echo "Renaming ARM wheels" | |
suffix=macosx_99_0_arm64 | |
for file in *; do | |
if [[ "$file" == *"$suffix"* ]]; then | |
newname=$(echo "$file" | sed "s/$suffix/macosx_14_0_arm64/g") | |
mv $file $newname | |
echo "Renamed: $file -> $newname" | |
fi | |
done | |
- name: Publish distribution 📦 to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true |