diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 89994be..7ffb926 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -21,7 +21,8 @@ concurrency: cancel-in-progress: false jobs: - build: + build-main: + if: ${{ ! startsWith(github.ref, 'refs/tags/') }} name: Build the documentation with Sphinx runs-on: ubuntu-latest steps: @@ -48,9 +49,37 @@ jobs: with: path: 'docs/_build/html' + build-tagged: + if: ${{ startsWith(github.ref, 'refs/tags/') }} + name: Build the documentation with Sphinx + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch origin main + - name: troubleshooting + run: | + git branch + git remote -v + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install package + run: | + sudo apt-get install -y doxygen graphviz + pip install -e .[docs] + pip install -r requirements.txt + - name: Build documentation + run: sphinx-build docs/ docs/_build/html/${{ github.ref_name }} + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: 'docs/_build/html' + deploy: name: Deploy documentation to GitHub Pages - needs: build + needs: [build-main, build-tagged] environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -61,5 +90,3 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 - with: - base_path: /sansmic/${{ github.ref_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bcc5a85..269e72c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,39 +1,89 @@ -name: Build wheels and push to PyPI +name: Publish Python 🐍 distribution 📦 to TestPyPI -on: +on: push: + branches: + - 'main' tags: - '*' jobs: - - wheels: + build_wheels: + name: Build distribution 📦 on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, macOS-13, macOS-latest, ubuntu-latest] + # macos-13 is an intel runner, macos-14 is apple silicon + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + + steps: + - uses: actions/checkout@v4 + + - uses: pypa/cibuildwheel@v2.21.0 + # ... + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + make_sdist: + name: Make SDist artifact 📦 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Build wheels - uses: pypa/cibuildwheel@v2.11.1 - env: - CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*" - CIBW_SKIP: "*-win32 *-manylinux_i686 pp* *-musllinux*" + with: + fetch-depth: 0 # Optional, use if you use setuptools_scm + submodules: true # Optional, use if you have submodules + + - name: Build SDist + run: pipx run build --sdist + - uses: actions/upload-artifact@v4 with: - path: ./wheelhouse/*.whl + name: cibw-sdist + path: dist/*.tar.gz - source: + upload_test: + name: >- + Publish Python 🐍 distribution 📦 to TestPyPI + needs: [build_wheels, make_sdist] + environment: + name: testpypi + url: https://test.pypi.org/p/sansmic + permissions: + id-token: write runs-on: ubuntu-latest + if: github.event_name == 'release' steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: build the sdist - run: | - python -m pip install --upgrade build - python -m build --sdist - - uses: actions/upload-artifact@v4 - with: - path: dist/*.tar.gz + - uses: actions/download-artifact@v4 + with: + pattern: cibw-* + path: dist + merge-multiple: true + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + upload_all: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + needs: [build_wheels, make_sdist, upload_test] + environment: + name: release + url: https://pypi.org/p/sansmic + permissions: + id-token: write + runs-on: ubuntu-latest + if: github.event_name == 'release' + steps: + - uses: actions/download-artifact@v4 + with: + pattern: cibw-* + path: dist + merge-multiple: true + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index 2f9cb0b..df0665b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ tests = [ ] [project.urls] +Documentation = "https://sandialabs.github.io/sansmic" Issues = "https://github.com/sandialabs/sansmic/issues" Repository = "https://github.com/sandialabs/sansmic.git" @@ -66,7 +67,9 @@ requires = ["setuptools", "pybind11"] build-backend = "setuptools.build_meta" [tool.cibuildwheel] -skip = ["cp313-*", "pp*"] +skip = ["cp313-*", "pp*", "*-win32", "*-manylinux_i686", "*-musllinux*"] +test-extras = "tests" +test-command = "pytest {project}/tests" [tool.setuptools.package-data] "sansmic" = ["src/python/sansmic/*.pyd"]