Skip to content

Commit

Permalink
Use poetry publish
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Apr 3, 2024
1 parent df0ce40 commit 52485f3
Showing 1 changed file with 24 additions and 45 deletions.
69 changes: 24 additions & 45 deletions .github/workflows/python-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,45 @@ on:
- '*'

jobs:
build:
name: Build source distribution
build-publish:
name: Build and publish wheels
runs-on: ubuntu-latest
strategy:
matrix:
package:
# This should be the same list as in `jobs.upload_pypi`.
- 'quantinuum-hugr-py'

steps:
- uses: actions/checkout@v4
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install poetry
run: pipx install poetry
- name: Set up Python '3.10'
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: "poetry"
#- name: Install the project libraries
# run: poetry install

- name: Build sdist and wheels
run: |
mkdir -p dist
pipx run build ${{ matrix.package }} --outdir dist
cd ${{ matrix.package }}
poetry build -o ../dist
- uses: actions/upload-artifact@v4
- name: Upload the built packages as artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.package }}-sdist
path: dist/*.tar.gz

- uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.package }}-wheel
path: dist/*.whl

upload_pypi:
needs: [build]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
strategy:
matrix:
package:
# This should be the same list as in `jobs.build`.
- 'quantinuum-hugr-py'

steps:
- name: Download artifacts
if: startsWith(github.ref, 'refs/tags/${{ matrix.package }}-v')
uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: build-${{ matrix.package }}-*
path: dist
merge-multiple: true
path: |
dist/*.tar.gz
dist/*.whl
- name: Publish to test instance of PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name != 'push' || github.ref_type != 'tag' ||
not(startsWith(github.ref, 'refs/tags/${{ matrix.package }}-v'))
with:
repository-url: https://test.pypi.org/legacy/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'push' && github.ref_type == 'tag' &&
startsWith(github.ref, 'refs/tags/${{ matrix.package }}-v')
with:
# TODO: Use the real PyPI URL
repository-url: https://test.pypi.org/legacy/
run: |
cd ${{ matrix.package }}
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry publish -r test-pypi -o ../dist

0 comments on commit 52485f3

Please sign in to comment.