forked from cellml/libcellml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test uploading and downloading artifacts to publish to PyPI.
- Loading branch information
Showing
1 changed file
with
128 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
name: test-upload-to-pypi | ||
|
||
on: | ||
push: | ||
|
||
env: | ||
BUILD_TYPE: Release | ||
MACOSX_DEPLOYMENT_TARGET: 10.15 | ||
|
||
jobs: | ||
wheels: | ||
name: ${{ matrix.name }} ${{ matrix.py }} wheel | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-13, ubuntu-20.04, windows-2019] | ||
py: ['3.9'] | ||
include: | ||
- name: 'Windows' | ||
os: windows-2019 | ||
- name: 'Linux' | ||
os: ubuntu-20.04 | ||
- name: 'macOS' | ||
os: macos-13 | ||
exclude: | ||
- os: macos-13 | ||
py: '3.7' | ||
- os: ubuntu-20.04 | ||
py: '3.7' | ||
|
||
steps: | ||
- name: Check out libCellML | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.release.tag_name }} | ||
|
||
- name: Setup for cibuildwheel | ||
id: setup | ||
shell: bash | ||
run: | | ||
mkdir src/bindings/python/libcellml | ||
cp src/bindings/python/README.rst src/bindings/python/libcellml/README.rst | ||
mv src/bindings/python/cibuildwheel.setup.py src/bindings/python/setup.py | ||
v=${{ matrix.py }} | ||
echo "Setting tag as: tag=${GITHUB_REF#refs/tags/}" | ||
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | ||
echo "Setting build as: build=cp${v/./}-*" | ||
echo "build=cp${v/./}-*" >> $GITHUB_OUTPUT | ||
if [[ "macOS" == "${{ matrix.name }}" ]]; then | ||
if [[ "${{ matrix.py }}" == "3.8" ]]; then | ||
echo "Setting macos_archs as: macos_archs='x86_64'" | ||
echo "macos_archs=x86_64" >> $GITHUB_OUTPUT | ||
echo "macos_deployment_target=10.15" >> $GITHUB_OUTPUT | ||
else | ||
echo "Setting macos_archs as: macos_archs='x86_64 arm64'" | ||
echo 'macos_archs=x86_64 arm64' >> $GITHUB_OUTPUT | ||
echo "macos_deployment_target=11.0" >> $GITHUB_OUTPUT | ||
fi | ||
else | ||
echo "Setting macos_archs as: macos_archs='x86_64'" | ||
echo "macos_archs=x86_64" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Configure MSVC (Windows) | ||
if: runner.os == 'Windows' | ||
uses: ilammy/msvc-dev-cmd@v1 | ||
|
||
- name: Install SWIG (macOS) | ||
if: runner.os == 'macOS' | ||
run: brew install swig | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
#CIBW_BUILD_VERBOSITY: 1 | ||
CIBW_ARCHS: auto64 | ||
CIBW_ARCHS_MACOS: ${{ steps.setup.outputs.macos_archs }} | ||
CIBW_BUILD: ${{ steps.setup.outputs.build }} | ||
CIBW_TEST_SKIP: "*_arm64" | ||
CIBW_BEFORE_ALL_LINUX: yum install -y libxml2-devel || (apk add libxml2-dev && rm /usr/lib/cmake/libxml2/libxml2-config.cmake) | ||
CIBW_BEFORE_ALL_WINDOWS: cd src/bindings/python && cmake -S wheel_dependencies -B build-wheel_dependencies -G Ninja && cd build-wheel_dependencies && ninja | ||
CIBW_ENVIRONMENT: > | ||
LIBCELLML_VERSION_TAG=${{ steps.setup.outputs.tag }} | ||
MACOSX_DEPLOYMENT_TARGET=${{ steps.setup.outputs.macos_deployment_target }} | ||
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" | ||
CIBW_BEFORE_BUILD_LINUX: pip install renamewheel | ||
CIBW_REPAIR_WHEEL_COMMAND_LINUX: renamewheel -w {dest_dir} {wheel} | ||
with: | ||
output-dir: wheelhouse | ||
package-dir: src/bindings/python/ | ||
|
||
- name: Upload Python wheels as artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: ./wheelhouse/*.whl | ||
name: ${{ matrix.name }}-${{ matrix.py }}-wheel | ||
retention-days: 7 | ||
|
||
publish-wheels: | ||
# if: needs.setup-jobs.outputs.binaries-destination == 'Publish' | ||
needs: wheels | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 5 # Docker+network are slow sometimes. | ||
permissions: | ||
id-token: write | ||
name: Publish Wheels | ||
steps: | ||
|
||
- name: Download Python wheel artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: wheelhouse/ | ||
pattern: *-wheel | ||
merge-multiple: true | ||
|
||
- name: Display structure of downloaded files | ||
run: | | ||
ls -R | ||
ls -R wheelhouse | ||
- name: Publish Python wheels | ||
env: | ||
name: pypi | ||
url: https://pypi.org/p/libcellml | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: ./wheelhouse/ |