Skip to content

refactor deploy.yml

refactor deploy.yml #7

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
release:
types:
- published
env:
FORCE_COLOR: 3
jobs:
build-sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build SDist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
generate-wheels-matrix:
name: Generate wheels matrix
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v4
- name: Install cibuildwheel
run: pipx install cibuildwheel==2.16.0
- id: set-matrix
run: |
MATRIX=$(
{
cibuildwheel --print-build-identifiers --platform linux \
| jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \
&& cibuildwheel --print-build-identifiers --platform macos \
| jq -nRc '{"only": inputs, "os": "macos-latest"}' \
&& cibuildwheel --print-build-identifiers --platform windows \
| jq -nRc '{"only": inputs, "os": "windows-latest"}'
} | jq '. + [{"only": "qiskit-aer-gpu-cu11", "os": "ubuntu-latest"}, {"only": "qiskit-aer-gpu-cu12", "os": "ubuntu-latest"}]' | jq -sc
)
echo "MATRIX IS $MATRIX"
echo "include=$MATRIX" >> $GITHUB_OUTPUT
env:
CIBW_ARCHS_LINUX: x86_64 aarch64 s390x ppc64le
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ARCHS_WINDOWS: AMD64
build-wheels:
name: Build ${{ matrix.only }}
needs: generate-wheels-matrix
strategy:
matrix:
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
#- uses: actions-rs/toolchain@v1
# if: contains(fromJSON('["aarch64", "ppc64le", "s390x"]'), '${{ matrix.only }}')
# with:
# toolchain: stable
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Maximize build space
if: matrix.os == 'ubuntu-latest' && contains('-gpu-', matrix.only)
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 40000
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- uses: pypa/[email protected]
with:
only: ${{ matrix.only }}
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
path: wheelhouse/*.whl
upload-all:
name: Upload if release
needs:
- build-wheels
- build-sdist
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/setup-python@v4
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1
with:
user: __token__
password: ${{ secrets.pypi_password }}