Merge pull request #442 from light-curve/dependabot/cargo/light-curve… #494
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: Publish Python packages | |
on: | |
push: | |
tags: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
check-version: | |
name: Check the tag corresponds to the crate version | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check Cargo.toml version vs Git tag | |
if: startsWith(github.ref, 'refs/tags/v') | |
working-directory: ./light-curve | |
run: | | |
cargo read-manifest | jq -r '.version' > /tmp/.crate_version | |
echo '${{ github.ref_name }}' | sed 's/^v//' > /tmp/.tag | |
diff /tmp/.crate_version /tmp/.tag | |
cibuildwheel: | |
name: Build ${{ matrix.cibw_build }} | |
runs-on: ${{ matrix.os }} | |
needs: check-version | |
defaults: | |
run: | |
working-directory: ./light-curve | |
strategy: | |
fail-fast: false | |
matrix: | |
# CIBW_BUILD identifiers from https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip | |
# We use the same order as in the table | |
# * For Windows we support amd64 only | |
# * For Linux we support ARM64, PPC64le, and x86_64 | |
# * We build wheels for CPython only, one per platform, compatible with ABI3.8 | |
# * We skip PPC64le MUSL Linux, because there is no Rust toolchain for it | |
# * macos-12 runner is x86_64, macos-14 runner is arm64 | |
include: | |
# CPython 3.8 | |
- os: macos-12 | |
cibw_build: cp38-macosx_x86_64 | |
- os: macos-14 | |
cibw_build: cp38-macosx_arm64 | |
- os: windows-2019 | |
cibw_build: cp38-win_amd64 | |
- os: ubuntu-20.04 | |
cibw_build: cp38-manylinux_x86_64 | |
- os: ubuntu-20.04 | |
cibw_build: cp38-musllinux_x86_64 | |
- os: ubuntu-20.04 | |
cibw_build: cp38-manylinux_aarch64 | |
- os: ubuntu-20.04 | |
cibw_build: cp38-manylinux_ppc64le | |
- os: ubuntu-20.04 | |
cibw_build: cp38-musllinux_aarch64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU on Linux | |
if: ${{ runner.os == 'Linux' }} | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
# ARM macOS runner misses some peaces | |
- name: Set up Homebrew paths on ARM macOS | |
if: ${{ matrix.os == 'macos-14' }} | |
run: | | |
echo "CPATH=$(brew --prefix)/include:$(brew --prefix)/include/eigen3:${CPATH}" >> $GITHUB_ENV | |
echo "LIBRARY_PATH=$(brew --prefix)/lib:$(brew --prefix)/lib64:${LIBRARY_PATH}" >> $GITHUB_ENV | |
- name: Set MACOSX_DEPLOYMENT_TARGET to the current macOS version | |
if: ${{ runner.os == 'macOS' }} | |
run: | | |
export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | awk -F '.' '{print $1"."0}') | |
echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV | |
# We only support AMD64 architecture for Windows, so we hard-code it here. | |
- name: Set CIBW envs on Windows | |
if: ${{ runner.os == 'Windows' }} | |
run: | | |
"CIBW_BUILD=${{ matrix.cibw_build }}" >> $env:GITHUB_ENV | |
"CIBW_ARCHS=AMD64" >> $env:GITHUB_ENV | |
- name: Set CIBW envs on Linux or macOS | |
if: ${{ runner.os != 'Windows' }} | |
run: | | |
echo "CIBW_BUILD=${{ matrix.cibw_build }}" >> $GITHUB_ENV | |
CIBW_ARCHS=$(echo ${{ matrix.cibw_build }} | cut -d'_' -f2,3) | |
echo "CIBW_ARCHS=${CIBW_ARCHS}" >> $GITHUB_ENV | |
- name: Build wheels | |
uses: pypa/[email protected] | |
with: | |
package-dir: ./light-curve | |
env: | |
CIBW_BUILD_VERBOSITY: "3" | |
- name: Upload wheels as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./wheelhouse/*.whl | |
if-no-files-found: error | |
name: artifact_${{ matrix.cibw_build }} | |
sdist: | |
name: Build source distribution | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
working-directory: ./light-curve | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install maturin | |
run: pip install 'maturin>=1.0,<2.0' | |
- name: Build sdist | |
run: maturin sdist | |
- name: Upload sdist as an artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./light-curve/target/wheels/*.tar.gz | |
if-no-files-found: error | |
name: artifact_sdist | |
publish: | |
needs: [ cibuildwheel, sdist ] | |
name: Publish light-curve | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: artifact_* | |
merge-multiple: true | |
path: artifact | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install twine | |
run: pip install twine | |
- name: Publish light-curve for a new version tag | |
if: startsWith(github.ref, 'refs/tags/v') | |
working-directory: artifact | |
run: twine upload *whl *tar.gz -u __token__ -p ${{ secrets.PYPI_TOKEN_LIGHT_CURVE }} --verbose | |
publish-light-curve-python: | |
needs: publish | |
name: Publish light-curve-python | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
working-directory: light-curve-python | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install deps | |
run: python3 -mpip install setuptools toml twine | |
- name: Publish light-curve-python for a new version tag | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
python3 setup.py sdist | |
twine check --strict dist/* | |
twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN_LIGHT_CURVE_PYTHON }} --verbose |