Skip to content

[pre-commit.ci] pre-commit autoupdate #68

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #68

Workflow file for this run

name: Publish to PyPI
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]
jobs:
build:
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- { os: ubuntu-latest, py: 3.9 }
- { os: ubuntu-latest, py: "3.10" }
- { os: ubuntu-latest, py: "3.11", doc: 1, whl: 1 }
- { os: ubuntu-latest, py: "3.12" }
- { os: windows-latest, py: "3.11", exe: 1 }
# pure python wheels
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.config.py }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.py }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev,webview]
mkdir release
mkdir dist
- name: Check that the docs build (linux only)
if: matrix.config.doc == 1
run: |
python -m pip install sphinx
make -j 4 -C doc SPHINXOPTS="-W --keep-going" html
- name: Build binary wheel
if: matrix.config.whl == 1
run: |
python -m pip install build setuptools wheel
python -m build
- name: Build installer
if: matrix.config.exe == 1
run: |
pwsh -command ".\$GITHUB_WORKSPACE\extra\build_win_installer.ps1"
mv dist\Refl1D*.zip release\
# See the following for how to upload to a release
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.config.os }}-${{ matrix.config.py }}
path: |
dist/*.whl
dist/*.zip
dist/*.tar.gz
release/*.zip
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Retrieve all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: artifacts-*
merge-multiple: true
- name: show files
run: |
ls -R artifacts
echo "WINDOWS_INSTALLER=$(ls artifacts/release/*.zip)" >> $GITHUB_ENV
echo "SRC_DIST=$(ls artifacts/dist/*.tar.gz)" >> $GITHUB_ENV
echo "PY3_WHL=$(ls artifacts/dist/*.whl)" >> $GITHUB_ENV
- name: Update current release
if: startsWith(github.ref, 'refs/tags')
uses: johnwbyrd/update-release@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
${{ env.WINDOWS_INSTALLER }}
${{ env.PY3_WHL }}
- name: publish distribution to Test PyPI
env:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
if: env.TEST_PYPI_API_TOKEN != null
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
packages-dir: artifacts/dist/
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: artifacts/dist/