From 184ce2725ba3d7649ae6cf9167b0403c87d56039 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Sat, 6 Apr 2024 15:08:51 -0700 Subject: [PATCH] Build Python sdist separately to avoid duplicate artifacts (#491) --- .github/workflows/build.yml | 75 +++++++++++++++++++++++++------------ pyproject.toml | 2 +- 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21f7f584..30123dce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: name: ${{ matrix.os }} - native path: pkg - build-python: + build-python-wheel: timeout-minutes: 10 strategy: fail-fast: false @@ -50,7 +50,7 @@ jobs: - os: macOS-14 version: '3.9' - name: "${{ matrix.os }} - python ${{ matrix.version }}" + name: "${{ matrix.os }} - python ${{ matrix.version }} wheel" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -69,7 +69,7 @@ jobs: run: pip3 install build tox - name: Build - run: python3 -m build + run: python3 -m build --wheel - name: Repair wheel if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macOS') @@ -81,9 +81,57 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: ${{ matrix.os }} - python ${{ matrix.version }} + name: ${{ matrix.os }} - python ${{ matrix.version }} wheel path: dist + build-python-sdist: + timeout-minutes: 10 + + name: "Python sdist" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.version }} + + - name: Update version string + run: python3 ./tools/update_version.py + + - name: Install build and tox Python packages + run: pip3 install build tox + + - name: Build + run: python3 -m build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.os }} - python ${{ matrix.version }} sdist + path: dist + + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-22.04 + needs: [build-python-wheel, build-python-sdist] + if: github.repository_owner == 'SleipnirGroup' && github.ref == 'refs/heads/main' + environment: + name: pypi + url: https://pypi.org/p/sleipnirgroup-jormungandr + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + pattern: '* - python *' + merge-multiple: true + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + build-cross: strategy: fail-fast: false @@ -135,22 +183,3 @@ jobs: with: name: Wasm path: pkg - - pypi-publish: - name: Upload release to PyPI - runs-on: ubuntu-22.04 - needs: [build-python] - if: github.repository_owner == 'SleipnirGroup' && github.ref == 'refs/heads/main' - environment: - name: pypi - url: https://pypi.org/p/sleipnirgroup-jormungandr - permissions: - id-token: write - steps: - - uses: actions/download-artifact@v4 - with: - path: dist - pattern: '* - python *' - merge-multiple: true - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index c862b755..3d4f792b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "sleipnirgroup-jormungandr" description = "A linearity-exploiting sparse nonlinear constrained optimization problem solver that uses the interior-point method." -version = "0.0.1.dev106" +version = "0.0.1.dev108" readme = "README.md" requires-python = ">=3.7" dependencies = [ "matplotlib", "numpy", "scipy" ]