From 52485f30841ceb6233bef1a341ab87169e721ab2 Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Wed, 3 Apr 2024 10:46:44 +0100 Subject: [PATCH] Use poetry publish --- .github/workflows/python-wheels.yml | 69 ++++++++++------------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml index 3d0827855..d2bfb07f2 100644 --- a/.github/workflows/python-wheels.yml +++ b/.github/workflows/python-wheels.yml @@ -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/sccache-action@v0.0.4 + - 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