Setup PyPI publish action #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Test, & Publish Wheel | |
env: | |
CLONE_PATH: ${{ github.workspace }} | |
on: | |
pull_request: | |
branches: [main] | |
# Limit to only branches named release_v*.*? | |
# release: | |
# types: [published] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-24.04] | |
python-version: ["3.12"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup base Python environment | |
run: | | |
$CLONE_PATH/.github/workflows/setup_base_python.sh ${{ runner.os }} | |
- name: Run tests through wheels | |
run: | | |
python -m pip install build | |
pushd $CLONE_PATH | |
python -m build | |
ls -lart ./dist | |
popd | |
- name: Archive wheel for later publishing | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Taweret-distributions | |
path: | | |
${{ env.CLONE_PATH }}/dist/taweret-*.tar.gz | |
${{ env.CLONE_PATH }}/dist/Taweret-*-py3-none-any.whl | |
test: | |
needs: [build] | |
strategy: | |
matrix: | |
os: [ubuntu-24.04] | |
python-version: ["3.12"] | |
# os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14] | |
# python-version: ["3.9", "3.10", "3.11", "3.12"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install OpenMPI | |
run: | | |
if [ "${{ runner.os }}" == "Linux" ]; then | |
sudo apt-get update | |
sudo apt-get -y install openmpi-bin | |
elif [ "${{ runner.os }}" == "macOS" ]; then | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
brew install open-mpi | |
fi | |
- name: Setup base Python environment | |
run: | | |
$CLONE_PATH/.github/workflows/setup_base_python.sh ${{ runner.os }} | |
- uses: actions/download-artifact@v4 | |
with: | |
name: Taweret-distributions | |
path: ${{ env.CLONE_PATH }}/dist | |
- name: Test source ditribution | |
run: | | |
distribution=$CLONE_PATH/dist/taweret-*.tar.gz | |
venv=$CLONE_PATH/TestSrc | |
which python | |
echo | |
# Run in clean virtual environment | |
python -m venv $venv | |
. $venv/bin/activate | |
which python | |
echo | |
ls -la $distribution | |
echo | |
python -m pip install $distribution | |
echo | |
python -m pip list | |
echo | |
python -c "import Taweret ; print(Taweret.__version__) ; Taweret.test()" | |
rm -rf $venv | |
- name: Test binary wheel | |
run: | | |
distribution=$CLONE_PATH/dist/Taweret-*-py3-none-any.whl | |
venv=$CLONE_PATH/TestWheel | |
which python | |
echo | |
# Run in clean virtual environment | |
python -m venv $venv | |
. $venv/bin/activate | |
which python | |
echo | |
ls -la $distribution | |
echo | |
python -m pip install $distribution | |
echo | |
python -m pip list | |
echo | |
python -c "import Taweret ; print(Taweret.__version__) ; Taweret.test()" | |
rm -rf $venv | |
publish: | |
needs: [test] | |
environment: pypi | |
# permissions: | |
# id-token: write | |
runs-on: ubuntu-latest | |
# if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: Taweret-distributions | |
path: ${{ env.CLONE_PATH }}/dist | |
- name: Standin for now | |
run: ls -lart $CLONE_PATH/dist | |
# - uses: pypa/gh-action-pypi-publish@release/v1 |