|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright (C) 2025 The American University in Cairo |
| 3 | +# |
| 4 | +# Adapted from Yosys wheels |
| 5 | +# |
| 6 | +# Copyright (C) 2024 Efabless Corporation |
| 7 | +# |
| 8 | +# Permission to use, copy, modify, and/or distribute this software for any |
| 9 | +# purpose with or without fee is hereby granted, provided that the above |
| 10 | +# copyright notice and this permission notice appear in all copies. |
| 11 | +# |
| 12 | +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 13 | +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 14 | +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 15 | +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 16 | +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 17 | +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 18 | +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 | +name: Build Wheels for PyPI |
| 20 | + |
| 21 | +on: |
| 22 | + push: |
| 23 | + branches: |
| 24 | + - "*" |
| 25 | + pull_request: |
| 26 | + |
| 27 | +jobs: |
| 28 | + build_wheels: |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + os: [ |
| 33 | + { |
| 34 | + name: "Ubuntu 22.04", |
| 35 | + family: "linux", |
| 36 | + runner: "ubuntu-22.04", |
| 37 | + archs: "x86_64", |
| 38 | + }, |
| 39 | + { |
| 40 | + name: "Ubuntu 22.04", |
| 41 | + family: "linux", |
| 42 | + runner: "ubuntu-22.04-arm", |
| 43 | + archs: "aarch64", |
| 44 | + }, |
| 45 | + { |
| 46 | + name: "macOS 13", |
| 47 | + family: "macos", |
| 48 | + runner: "macos-13", |
| 49 | + archs: "x86_64", |
| 50 | + }, |
| 51 | + { |
| 52 | + name: "macOS 14", |
| 53 | + family: "macos", |
| 54 | + runner: "macos-14", |
| 55 | + archs: "arm64", |
| 56 | + }, |
| 57 | + ## Windows is disabled because of an issue with compiling FFI as |
| 58 | + ## under MinGW in the GitHub Actions environment (SHELL variable has |
| 59 | + ## whitespace.) |
| 60 | + # { |
| 61 | + # name: "Windows Server 2019", |
| 62 | + # family: "windows", |
| 63 | + # runner: "windows-2019", |
| 64 | + # archs: "AMD64", |
| 65 | + # }, |
| 66 | + ] |
| 67 | + name: Build Wheels | ${{ matrix.os.name }} | ${{ matrix.os.archs }} |
| 68 | + runs-on: ${{ matrix.os.runner }} |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + with: |
| 72 | + fetch-depth: 0 |
| 73 | + submodules: true |
| 74 | + persist-credentials: false |
| 75 | + - uses: actions/setup-python@v5 |
| 76 | + ## Software installed by default in GitHub Action Runner VMs: |
| 77 | + ## https://github.com/actions/runner-images |
| 78 | + - if: ${{ matrix.os.family == 'macos' && matrix.os.archs == 'arm64' }} |
| 79 | + name: "[macOS/arm64] Install Python 3.8 (see: https://cibuildwheel.pypa.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64)" |
| 80 | + uses: actions/setup-python@v5 |
| 81 | + with: |
| 82 | + python-version: 3.8 |
| 83 | + - name: Build wheels |
| 84 | + uses: pypa/cibuildwheel@v2.21.1 |
| 85 | + env: |
| 86 | + # * APIs not supported by PyPy |
| 87 | + # * Musllinux disabled to save build time |
| 88 | + CIBW_SKIP: > |
| 89 | + pp* |
| 90 | + *musllinux* |
| 91 | + CIBW_ARCHS: ${{ matrix.os.archs }} |
| 92 | + CIBW_BUILD_VERBOSITY: "1" |
| 93 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 |
| 94 | + CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 |
| 95 | + CIBW_BEFORE_ALL: | |
| 96 | + if command -v dnf > /dev/null; then |
| 97 | + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm |
| 98 | + dnf --enablerepo=powertools install -y libstdc++-static |
| 99 | + dnf install -y swift-lang |
| 100 | + fi |
| 101 | + CIBW_ENVIRONMENT: "" |
| 102 | + CIBW_ENVIRONMENT_MACOS: > |
| 103 | + MACOSX_DEPLOYMENT_TARGET=12 |
| 104 | + - uses: actions/upload-artifact@v4 |
| 105 | + with: |
| 106 | + name: python-wheels-${{ matrix.os.runner }} |
| 107 | + path: ./wheelhouse/*.whl |
| 108 | + upload_wheels: |
| 109 | + name: Upload Wheels |
| 110 | + runs-on: ubuntu-latest |
| 111 | + needs: build_wheels |
| 112 | + steps: |
| 113 | + - name: Check out Git repository |
| 114 | + uses: actions/checkout@v4 |
| 115 | + - uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + path: "." |
| 118 | + pattern: python-wheels-* |
| 119 | + merge-multiple: true |
| 120 | + - run: | |
| 121 | + ls |
| 122 | + mkdir -p ./dist |
| 123 | + mv *.whl ./dist |
| 124 | + - name: Set default for env.NEW_TAG |
| 125 | + run: echo "NEW_TAG=NO_NEW_TAG" >> $GITHUB_ENV |
| 126 | + - name: Check for new version |
| 127 | + if: ${{ env.BRANCH_NAME == 'main' }} |
| 128 | + run: | |
| 129 | + python3 .github/scripts/generate_tag.py |
| 130 | + - name: Tag Commit |
| 131 | + if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }} |
| 132 | + uses: tvdias/github-tagger@v0.0.1 |
| 133 | + with: |
| 134 | + tag: "${{ env.NEW_TAG }}" |
| 135 | + repo-token: "${{ secrets.MY_TOKEN }}" |
| 136 | + - name: Publish |
| 137 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 138 | + if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }} |
| 139 | + with: |
| 140 | + password: ${{ secrets.PYPI_TOKEN }} |
| 141 | + repository-url: ${{ vars.PYPI_INDEX || 'https://upload.pypi.org/legacy/' }} |
0 commit comments