|
| 1 | +name: Build release artifacts |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + default-action: |
| 6 | + description: >- |
| 7 | + The default action for each artifact. |
| 8 | + Choose from 'build' (default) or 'skip'. |
| 9 | + type: string |
| 10 | + default: "build" |
| 11 | + required: false |
| 12 | + |
| 13 | + sdist: |
| 14 | + description: >- |
| 15 | + The action to take for the sdist. |
| 16 | + Choose from 'default', 'build' or 'skip'. |
| 17 | + type: string |
| 18 | + default: "default" |
| 19 | + required: false |
| 20 | + |
| 21 | + wheels-tier-1: |
| 22 | + description: >- |
| 23 | + The action to take for Tier 1 wheels. |
| 24 | + Choose from 'default', 'build' or 'skip'. |
| 25 | + This builds multiple artifacts, which all match 'wheels-tier-1-*'. |
| 26 | + type: string |
| 27 | + default: "default" |
| 28 | + required: false |
| 29 | + |
| 30 | + wheels-32bit: |
| 31 | + description: >- |
| 32 | + The action to take for Tier 1 wheels. |
| 33 | + Choose from 'default', 'build' or 'skip'. |
| 34 | + This builds multiple artifacts, which all match 'wheels-32bit-*'. |
| 35 | + type: string |
| 36 | + default: "default" |
| 37 | + required: false |
| 38 | + |
| 39 | + wheels-linux-s390x: |
| 40 | + description: >- |
| 41 | + The action to take for Linux s390x wheels. |
| 42 | + Choose from 'default', 'build' or 'skip'. |
| 43 | + type: string |
| 44 | + default: "default" |
| 45 | + required: false |
| 46 | + |
| 47 | + wheels-linux-ppc64le: |
| 48 | + description: >- |
| 49 | + The action to take for Linux ppc64le wheels. |
| 50 | + Choose from 'default', 'build' or 'skip'. |
| 51 | + type: string |
| 52 | + default: "default" |
| 53 | + required: false |
| 54 | + |
| 55 | + wheels-linux-aarch64: |
| 56 | + description: >- |
| 57 | + The action to take for Linux AArch64 wheels. |
| 58 | + Choose from 'default', 'build' or 'skip'. |
| 59 | + type: string |
| 60 | + default: "default" |
| 61 | + required: false |
| 62 | + |
| 63 | + artifact-prefix: |
| 64 | + description: "A prefix to give all artifacts uploaded with 'actions/upload-artifact'." |
| 65 | + type: string |
| 66 | + default: "" |
| 67 | + required: false |
| 68 | + |
| 69 | + python-version: |
| 70 | + description: "The Python version to use to host the build runner." |
| 71 | + type: string |
| 72 | + default: "3.10" |
| 73 | + required: false |
| 74 | + |
| 75 | + pgo: |
| 76 | + description: "Whether to enable profile-guided optimizations for supported platforms." |
| 77 | + type: boolean |
| 78 | + default: true |
| 79 | + required: false |
| 80 | + |
| 81 | + |
| 82 | +jobs: |
| 83 | + wheels-tier-1: |
| 84 | + name: "Wheels / Tier 1" |
| 85 | + if: (inputs.wheels-tier-1 == 'default' && inputs.default-action || inputs.wheels-tier-1) == 'build' |
| 86 | + runs-on: ${{ matrix.os }} |
| 87 | + strategy: |
| 88 | + fail-fast: false |
| 89 | + matrix: |
| 90 | + os: |
| 91 | + - ubuntu-latest |
| 92 | + # Used for the x86_64 builds. |
| 93 | + - macos-12 |
| 94 | + # Used for the ARM builds. |
| 95 | + - macos-14 |
| 96 | + - windows-latest |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v4 |
| 99 | + - uses: actions/setup-python@v5 |
| 100 | + with: |
| 101 | + python-version: ${{ inputs.python-version }} |
| 102 | + architecture: ${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }} |
| 103 | + - uses: dtolnay/rust-toolchain@stable |
| 104 | + with: |
| 105 | + components: llvm-tools-preview |
| 106 | + - name: Configure PGO |
| 107 | + shell: bash |
| 108 | + if: inputs.pgo |
| 109 | + # The `$GITHUB_ENV` magic file uses some sort of custom parsing, so the variables shouldn't |
| 110 | + # be quoted like they would be if bash were interpreting them. You still need to use quotes |
| 111 | + # to avoid word splitting where appropriate in compound environment variables. |
| 112 | + # |
| 113 | + # Beware that the heredoc is configured to expand bash variables, but cibuildwheel has |
| 114 | + # special handling for certain variables (`$PATH`, in particular), so you may need to escape |
| 115 | + # some dollar signs to pass those through to cibuildwheel as variables, or use single quotes |
| 116 | + # to prevent shell expansion. |
| 117 | + run: | |
| 118 | + set -e |
| 119 | + mkdir -p "$PGO_WORK_DIR" |
| 120 | +
|
| 121 | + cat >>"$GITHUB_ENV" <<EOF |
| 122 | + CIBW_BEFORE_BUILD=bash ./tools/build_pgo.sh $PGO_WORK_DIR $PGO_OUT_PATH |
| 123 | + CIBW_ENVIRONMENT=RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function' |
| 124 | + CIBW_ENVIRONMENT_LINUX=RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function' PATH="\$PATH:\$HOME/.cargo/bin" CARGO_NET_GIT_FETCH_WITH_CLI="true" |
| 125 | + EOF |
| 126 | + env: |
| 127 | + PGO_WORK_DIR: ${{ github.workspace }}/pgo-data |
| 128 | + PGO_OUT_PATH: ${{ github.workspace }}/merged.profdata |
| 129 | + - uses: pypa/cibuildwheel@v2.21.3 |
| 130 | + - uses: actions/upload-artifact@v4 |
| 131 | + with: |
| 132 | + path: ./wheelhouse/*.whl |
| 133 | + name: ${{ inputs.artifact-prefix }}wheels-tier-1-${{ matrix.os }} |
| 134 | + |
| 135 | + wheels-32bit: |
| 136 | + name: "Wheels / 32bit" |
| 137 | + if: (inputs.wheels-32bit == 'default' && inputs.default-action || inputs.wheels-32bit) == 'build' |
| 138 | + runs-on: ${{ matrix.os }} |
| 139 | + strategy: |
| 140 | + fail-fast: false |
| 141 | + matrix: |
| 142 | + os: |
| 143 | + - ubuntu-latest |
| 144 | + - windows-latest |
| 145 | + steps: |
| 146 | + - uses: actions/checkout@v4 |
| 147 | + - uses: actions/setup-python@v5 |
| 148 | + with: |
| 149 | + python-version: ${{ inputs.python-version }} |
| 150 | + - uses: dtolnay/rust-toolchain@stable |
| 151 | + with: |
| 152 | + components: llvm-tools-preview |
| 153 | + - name: Build wheels |
| 154 | + uses: pypa/cibuildwheel@v2.21.3 |
| 155 | + env: |
| 156 | + CIBW_SKIP: 'pp* cp36-* cp37-* cp38-* *musllinux* *amd64 *x86_64' |
| 157 | + - uses: actions/upload-artifact@v4 |
| 158 | + with: |
| 159 | + path: ./wheelhouse/*.whl |
| 160 | + name: ${{ inputs.artifact-prefix }}wheels-32bit-${{ matrix.os }} |
| 161 | + |
| 162 | + wheels-linux-s390x: |
| 163 | + name: "Wheels / Linux s390x" |
| 164 | + if: (inputs.wheels-linux-s390x == 'default' && inputs.default-action || inputs.wheels-linux-s390x) == 'build' |
| 165 | + runs-on: ubuntu-latest |
| 166 | + steps: |
| 167 | + - uses: actions/checkout@v4 |
| 168 | + - uses: actions/setup-python@v5 |
| 169 | + name: Install Python |
| 170 | + with: |
| 171 | + python-version: ${{ inputs.python-version }} |
| 172 | + - uses: dtolnay/rust-toolchain@stable |
| 173 | + - uses: docker/setup-qemu-action@v3 |
| 174 | + with: |
| 175 | + platforms: all |
| 176 | + - uses: pypa/cibuildwheel@v2.21.3 |
| 177 | + env: |
| 178 | + CIBW_ARCHS_LINUX: s390x |
| 179 | + CIBW_TEST_SKIP: "cp*" |
| 180 | + - uses: actions/upload-artifact@v4 |
| 181 | + with: |
| 182 | + path: ./wheelhouse/*.whl |
| 183 | + name: ${{ inputs.artifact-prefix }}wheels-linux-s390x |
| 184 | + |
| 185 | + wheels-linux-ppc64le: |
| 186 | + name: "Wheels / Linux ppc64le" |
| 187 | + if: (inputs.wheels-linux-ppc64le == 'default' && inputs.default-action || inputs.wheels-linux-ppc64le) == 'build' |
| 188 | + runs-on: ubuntu-latest |
| 189 | + steps: |
| 190 | + - uses: actions/checkout@v4 |
| 191 | + - uses: actions/setup-python@v5 |
| 192 | + name: Install Python |
| 193 | + with: |
| 194 | + python-version: ${{ inputs.python-version }} |
| 195 | + - uses: dtolnay/rust-toolchain@stable |
| 196 | + - uses: docker/setup-qemu-action@v3 |
| 197 | + with: |
| 198 | + platforms: all |
| 199 | + - uses: pypa/cibuildwheel@v2.21.3 |
| 200 | + env: |
| 201 | + CIBW_ARCHS_LINUX: ppc64le |
| 202 | + CIBW_TEST_SKIP: "cp*" |
| 203 | + - uses: actions/upload-artifact@v4 |
| 204 | + with: |
| 205 | + path: ./wheelhouse/*.whl |
| 206 | + name: ${{ inputs.artifact-prefix }}wheels-linux-ppc64le |
| 207 | + |
| 208 | + wheels-linux-aarch64: |
| 209 | + name: "Wheels / Linux AArch64" |
| 210 | + if: (inputs.wheels-linux-aarch64 == 'default' && inputs.default-action || inputs.wheels-linux-aarch64) == 'build' |
| 211 | + runs-on: ubuntu-latest |
| 212 | + steps: |
| 213 | + - uses: actions/checkout@v4 |
| 214 | + - uses: actions/setup-python@v5 |
| 215 | + with: |
| 216 | + python-version: ${{ inputs.python-version }} |
| 217 | + - uses: dtolnay/rust-toolchain@stable |
| 218 | + - uses: docker/setup-qemu-action@v3 |
| 219 | + with: |
| 220 | + platforms: all |
| 221 | + - uses: pypa/cibuildwheel@v2.21.3 |
| 222 | + env: |
| 223 | + CIBW_ARCHS_LINUX: aarch64 |
| 224 | + CIBW_TEST_COMMAND: cp -r {project}/test . && QISKIT_PARALLEL=FALSE stestr --test-path test/python run --abbreviate -n test.python.compiler.test_transpiler |
| 225 | + - uses: actions/upload-artifact@v4 |
| 226 | + with: |
| 227 | + path: ./wheelhouse/*.whl |
| 228 | + name: ${{ inputs.artifact-prefix }}wheels-linux-aarch64 |
| 229 | + |
| 230 | + sdist: |
| 231 | + name: "sdist" |
| 232 | + if: (inputs.sdist == 'default' && inputs.default-action || inputs.sdist) == 'build' |
| 233 | + runs-on: ubuntu-latest |
| 234 | + steps: |
| 235 | + - uses: actions/checkout@v4 |
| 236 | + - uses: actions/setup-python@v5 |
| 237 | + with: |
| 238 | + python-version: ${{ inputs.python-version }} |
| 239 | + - name: Build sdist |
| 240 | + run: | |
| 241 | + set -e |
| 242 | + python -m pip install -U build |
| 243 | + python -m build --sdist . |
| 244 | + - uses: actions/upload-artifact@v4 |
| 245 | + with: |
| 246 | + path: ./dist/*.tar.gz |
| 247 | + name: ${{ inputs.artifact-prefix }}sdist |
0 commit comments