Skip to content

Commit

Permalink
⚗️ upload to Test PyPI for pushes on main (#461)
Browse files Browse the repository at this point in the history
## Description

This PR updates the CD workflow so that anytime it runs on a push to
`main`, it uploads the resulting package to Test PyPI. This allows to
battle test the packages before official releases.
This will be especially important in the context of #432
## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.
  • Loading branch information
burgholzer authored Sep 29, 2024
2 parents b332365 + 0bd41c5 commit 5a3ae3c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 10 deletions.
45 changes: 35 additions & 10 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,57 @@
name: CD
on:
push:
branches: [main]
release:
types: [published]
workflow_dispatch:
pull_request:
paths:
- .github/workflows/cd.yml

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
attestations: write
contents: read
id-token: write

jobs:
# Builds the sdist and wheels on all supported platforms and uploads the resulting
# wheels as GitHub artifacts `dev-cibw-*`, `test-cibw-*`, or `cibw-*`, depending on
# whether the workflow is triggered from a PR, a push to main, or a release, respectively.
python-packaging:
name: 🐍 Packaging
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
# Do not include local version information on pushes to main to facilitate TestPyPI uploads.
no-local-version: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
# Do not build emulated wheels on pushes to main to reduce runner load for CD.
build-emulated-wheels: ${{ github.ref != 'refs/heads/main' || github.event_name != 'push' }}

# Downloads the previously generated artifacts and deploys to TestPyPI on pushes to main
deploy-test-pypi:
name: 🚀 Deploy to Test PyPI
runs-on: ubuntu-latest
environment:
name: test-pypi
url: https://test.pypi.org/p/mqt.qcec
needs: [python-packaging]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/download-artifact@v4
with:
pattern: test-cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
attestations: true

# Downloads the previously generated artifacts and deploys to PyPI on published releases.
deploy:
if: github.event_name == 'release' && github.event.action == 'published'
name: 🚀 Deploy to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/mqt.qcec
permissions:
id-token: write
attestations: write
contents: read
needs: [python-packaging]
steps:
- uses: actions/download-artifact@v4
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ jobs:
if: fromJSON(needs.change-detection.outputs.run-code-ql)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]

cd:
name: 🚀 CD
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cd)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]

required-checks-pass: # This job does nothing and is only used for branch protection
name: 🚦 Check
if: always()
Expand All @@ -54,6 +60,7 @@ jobs:
- cpp-linter
- python-tests
- code-ql
- cd
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand All @@ -76,4 +83,8 @@ jobs:
fromJSON(needs.change-detection.outputs.run-code-ql)
&& '' || 'code-ql,'
}}
${{
fromJSON(needs.change-detection.outputs.run-cd)
&& '' || 'cd,'
}}
jobs: ${{ toJSON(needs) }}
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ before-build = "pip install delvewheel>=1.7.3"
repair-wheel-command = "delvewheel repair -v -w {dest_dir} {wheel} --namespace-pkg mqt"
environment = { CMAKE_ARGS = "-T ClangCL", SKBUILD_CMAKE_ARGS="--fresh" }

[[tool.cibuildwheel.overrides]]
select = "*-macosx_arm64"
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }


[tool.uv]
reinstall-package = ["mqt.qcec"]

0 comments on commit 5a3ae3c

Please sign in to comment.