Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 13 additions & 86 deletions .github/workflows/publish-PyPI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,100 +12,27 @@ on:
type: string

jobs:
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag_name || github.ref }}
fetch-depth: 0

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Add macOS Rust targets
if: runner.os == 'macOS'
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-apple-darwin, aarch64-apple-darwin

- name: Build wheels
uses: pypa/cibuildwheel@v4.1.0
env:
CIBW_BUILD: cp312-* cp313-* cp314-*
CIBW_PRERELEASE_PYTHONS: True
CIBW_SKIP: "*-musllinux_*"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ARCHS_WINDOWS: "AMD64"
# cibuildwheel runs the linux versions only inside a
# container. This means we need to install rust inside that
# container before we go ahead and build.
CIBW_BEFORE_ALL_LINUX: >
curl https://sh.rustup.rs -sSf | sh -s -- -y &&
source "$HOME/.cargo/env"
CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin"

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.os }}
path: ./wheelhouse/*.whl

build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag_name || github.ref }}
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install build
run: python -m pip install build

- name: Build sdist
run: python -m build --sdist

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-sdist
path: dist/*.tar.gz
# sdist plus a cibuildwheel matrix (Linux, macOS, Windows) over every CPython
# that requires-python allows. See ucgmsim/meta-ci-action's README.
build:
uses: ucgmsim/meta-ci-action/.github/workflows/build-dist.yml@v2.3
with:
ref: ${{ inputs.tag_name }} # empty on a release: builds the release tag
# Only GIL-enabled CPythons: free-threaded (*t-*) wheels are not built.
cibw-skip: "pp* *-musllinux_* *t-*"

publish-to-pypi:
name: Publish to PyPI
needs:
- build-wheels
- build-sdist
needs: build
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/im-calculation

permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
- uses: actions/download-artifact@v4
with:
pattern: python-package-distributions-*
path: dist
merge-multiple: true

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1.13.0
name: ${{ needs.build.outputs.artifact-name }}
path: dist/
- uses: pypa/gh-action-pypi-publish@v1.13.0
Loading