feat: add measure_array and discard_array quantum function (#710) #227
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
name: Build and publish python wheels | |
# Builds and publishes the wheels on pypi. | |
# | |
# When running on a push-to-main event, or as a workflow dispatch on a branch, | |
# this workflow will do a dry-run publish to test-pypi. | |
# | |
# When running on a release event or as a workflow dispatch for a tag, | |
# and if the tag matches `hugr-py-v*`, | |
# this workflow will publish the wheels to pypi. | |
# If the version is already published, pypi just ignores it. | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
jobs: | |
build-publish: | |
name: Build and publish wheels | |
runs-on: ubuntu-latest | |
environment: release | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run sccache-cache | |
uses: mozilla-actions/[email protected] | |
- name: Set up uv | |
run: curl -LsSf https://astral.sh/uv/0.3.4/install.sh | sh | |
- name: "Set up Python" | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Build sdist and wheels | |
run: uvx --from build pyproject-build --installer uv --outdir dist | |
- name: Upload the built packages as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-guppylang-sdist | |
path: | | |
dist/*.tar.gz | |
dist/*.whl | |
- name: Test installing the built wheels | |
run: | | |
echo "Testing the newly built wheels..." | |
uv run -f dist --with guppylang --refresh-package guppylang --no-project -- python -c "import guppylang" | |
uvx twine check --strict dist/* | |
- name: Report tag | |
if: ${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')) }} | |
run: | | |
echo "Publishing to PyPI..." | |
echo "Based on the following workflow variables, this is a new version tag push:" | |
echo " - event_name: ${{ github.event_name }}" | |
echo " - ref_type: ${{ github.ref_type }}" | |
echo " - ref: ${{ github.ref }}" | |
- name: Publish package distributions to PyPI | |
# This workflow is a trusted publisher for this package on PyPI. | |
if: ${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')) }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true | |
skip-existing: true |