Repository: bumps/bumps (language: python)

Issue:
Publish package in pypi
When tag `vX.Y.Z` is created and pushed to the `master` branch, a dedicated GitHub Actions workflow will run with the following responsibilities:
- build a `noarch` pure Python wheel `bumps-X.Y.Z-py3-none-any.whl`
- for the following systems:
    + ubuntu-latest, py: 3.8, 3.9, 3.10, 3.11, 3.12
    + windows-latest, py: 3.9
    + macos-latest, py: 3.9
  install the wheel in a dedicated conda environment, then install necessary dependencies for testing. Run tests:
``` bash
pytest -v
python check_examples.py --chisq
python check_examples.py --chisq
```
(some of the test may make sense only for the `webview` branch)
- The python wheel will have the no entry points.
- Some of the [optional dependencies for webview](https://github.com/bumps/bumps/blob/master/pyproject.toml#L27) should be incorporated as package dependencies (which ones decided by trial an error, probably when running the tests).
### GitHub Workflow structure
Three worfklows:
    `Aw`. build the wheel, for all push events
    `wB` test with the wheel, for all push events
    `wC`. publish the wheel, for tag-push events with tag pattern `v*`
Workflow `wA` uploads the wheels as an artifact
- `wB` waits for `wA` ending with success, then downloads the wheel and
    + installs the wheel and runs the tests except those for webview
    + installs webview dependencies and runs the webview tests
- `wC` waits for `wB` to complete successfully



Discussion / hints:

Fix patch:
diff --git a/pyproject.toml b/pyproject.toml
index c09cb11d..4d0a014e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -8,7 +8,11 @@ authors = [
 ]
 license = { file = "LICENSE.txt" }
 dependencies = [
-    'typing_extensions>=3.7.4', 'dataclasses; python_version < "3.7.0"'
+    'numpy',
+    'scikit-learn',
+    'scipy',
+    'typing_extensions>=3.7.4',
+    'graphlib_backport; python_version < "3.9"'
 ]
 classifiers=[
     'Development Status :: 4 - Beta',
@@ -25,18 +29,24 @@ classifiers=[
 requires-python = ">=3.8"
 
 [project.optional-dependencies]
+dev = [
+    'build',
+    'pytest',
+    'pytest-cov',
+    'wheel',
+    'setuptools',
+    'sphinx',
+]
 webview = [
-    'scipy',
     'aiohttp',
     'blinker',
+    'dill',
+    'matplotlib',
     'python-socketio',
     'plotly',
     'mpld3',
-    'matplotlib',
     'nodejs',
-    'h5py',
-    'dill',
-    'graphlib_backport; python_version < "3.9"'
+    'h5py'
 ]
 
 [project.urls]


Test patch:
diff --git a/.github/workflows/test-publish.yml b/.github/workflows/test-publish.yml
new file mode 100644
index 00000000..5936eed3
--- /dev/null
+++ b/.github/workflows/test-publish.yml
@@ -0,0 +1,118 @@
+name: Test and Publish to PyPI
+
+on: [push, pull_request, workflow_dispatch]
+
+jobs:
+
+  # Build a pure Python wheel and upload as an artifact
+  build-wheel:
+    runs-on: ubuntu-latest
+
+    steps:
+
+    - name: Checkout code
+      uses: actions/checkout@v4
+
+    - name: Set up Python
+      uses: actions/setup-python@v5
+      with:
+        python-version: '3.10'
+
+    - name: Install dependencies for building the wheel
+      run: |
+        python -m pip install --upgrade pip
+        python -m pip install -e .[dev]
+
+    - name: Create the wheel
+      run: python -m build --wheel --no-isolation
+
+    - name: Upload the wheel artifact
+      uses: actions/upload-artifact@v3
+      with:
+        name: wheel
+        path: dist/bumps-*-py3-none-any.whl
+
+  # Test the wheel on different platforms, test webview, and check docs build
+  test:
+    runs-on: ${{ matrix.cfg.os }}
+    needs: build-wheel
+
+    strategy:
+      matrix:
+        cfg:
+          - { os: ubuntu-latest, py: 3.8 }
+          - { os: ubuntu-latest, py: 3.9, doc: 1 }
+          - { os: ubuntu-latest, py: "3.10" }
+          - { os: ubuntu-latest, py: 3.11 }
+          - { os: ubuntu-latest, py: 3.12 }
+          - { os: windows-latest, py: 3.9 }
+          - { os: macos-latest, py: 3.9 }
+      fail-fast: false
+
+    steps:
+    - uses: actions/checkout@v4
+
+    - name: Set up Python ${{ matrix.cfg.py }}
+      uses: actions/setup-python@v5
+      with:
+        python-version: ${{ matrix.cfg.py }}
+
+    - name: Download the wheel
+      uses: actions/download-artifact@v3
+      with:
+        name: wheel
+        path: dist
+
+    - name: Install the wheel for Windows configuration
+      if: ${{ runner.os == 'Windows' }}
+      run: |
+        $wheel = Get-ChildItem -Path dist -Filter "bumps-*-py3-none-any.whl" | Select-Object -First 1
+        python -m pip install $wheel.FullName
+      shell: pwsh
+
+    - name: Install the wheel for configurations other than Windows
+      if: ${{ runner.os != 'Windows' }}
+      run: python -m pip install dist/bumps-*-py3-none-any.whl
+
+    - name: Install dependencies for testing
+      run: |
+        python -m pip install --upgrade pip
+        python -m pip install pytest pytest-cov
+        python -m pip install -r webview-requirements
+
+    - name: Run tests, except for webview
+      run: pytest -v --ignore=bumps/webview
+
+    - name: Run tests
+      run: pytest -v
+
+    - name: Check examples
+      run: python check_examples.py --chisq
+
+    - name: Check fitters
+      run: python check_fitters.py
+
+    - name: Check that the docs build (linux only)
+      if: matrix.cfg.doc == 1
+      run: |
+        python -m pip install sphinx
+        make -j 4 -C doc SPHINXOPTS="-W --keep-going -n" html
+
+  # Upload wheel to PyPI only when a tag is pushed, and its name begins with 'v'
+  upload-to-pypi:
+    runs-on: ubuntu-latest
+    needs: test
+    if: startsWith(github.ref, 'refs/tags/v')
+    steps:
+
+    - name: Download wheel
+      uses: actions/download-artifact@v3
+      with:
+        name: wheel
+        path: dist
+
+    - name: Upload the wheel to PyPI
+      uses: pypa/gh-action-pypi-publish@v1.5.1
+      with:
+        user: __token__
+        password: ${{ secrets.PYPI_API_TOKEN }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
deleted file mode 100644
index 71d1159f..00000000
--- a/.github/workflows/test.yml
+++ /dev/null
@@ -1,64 +0,0 @@
-name: Test
-
-on: [push, pull_request, workflow_dispatch]
-
-jobs:
-  test:
-
-    runs-on: ${{ matrix.cfg.os }}
-    strategy:
-      matrix:
-        cfg:
-          #- { os: ubuntu-latest, py: 2.7 }
-          - { os: ubuntu-latest, py: 3.8 }
-          - { os: ubuntu-latest, py: 3.9, doc: 1 }
-          - { os: ubuntu-latest, py: "3.10" }
-          - { os: ubuntu-latest, py: 3.11 }
-          - { os: ubuntu-latest, py: 3.12 }
-          - { os: windows-latest, py: 3.9 }
-          - { os: macos-latest, py: 3.9 }
-      fail-fast: false
-
-    steps:
-    - uses: actions/checkout@v4
-
-    - name: Set up Python ${{ matrix.cfg.py }}
-      uses: actions/setup-python@v5
-      with:
-        python-version: ${{ matrix.cfg.py }}
-
-    - name: Install build dependencies [Linux only]
-      if: ${{ runner.os == 'Linux' }}
-      run: |
-        sudo apt-get -y install gcc
-
-    - name: Install Python dependencies
-      run: |
-        python -m pip install --upgrade pip
-        python -m pip install wheel
-        python -m pip install numpy scipy matplotlib scikit-learn pytest pytest-cov
-        python -m pip install -r webview-requirements
-
-    - name: Build package [Linux only]
-      if: ${{ runner.os == 'Linux' }}
-      run: |
-        cd bumps/dream
-        gcc -I../../Random123/include/ -fopenmp -shared -lm -fPIC compiled.c -o _compiled.so
-
-    - name: Test with pytest
-      run: |
-        pytest -v
-
-    - name: Check examples
-      run: |
-        python check_examples.py --chisq
-
-    - name: Check fitters
-      run: |
-        python check_fitters.py
-
-    - name: Check that the docs build (linux only)
-      if: matrix.cfg.doc == 1
-      run: |
-        python -m pip install sphinx
-        make -j 4 -C doc SPHINXOPTS="-W --keep-going -n" html