Skip to content

Build and Release to PyPI #11

Build and Release to PyPI

Build and Release to PyPI #11

Workflow file for this run

name: Build and Release to PyPI
# Trigger workflow on release or prerelease
on:
release:
types: [released, prereleased]
jobs:
build:
name: Publish Release to PyPI
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository code
- name: Check out repository code
uses: actions/checkout@v2
# Step 2: Set up Miniconda
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: false
# Step 3: Create and activate Conda environment
- name: Create Conda environment
run: conda env create --file env.yml
- name: Activate Conda environment and install dependencies
run: |
source $CONDA/bin/activate intreg_env
pip install -e .
# Step 4: Verify Conda environment
- name: Verify Conda environment
run: |
source $CONDA/bin/activate intreg_env
conda info --all
conda list
# Step 5: Run Pytest and generate test coverage
- name: Run Pytest and Coverage
run: |
source $CONDA/bin/activate intreg_env
pytest --cov=intreg tests/ --cov-report=xml
# Step 6: Upload test coverage to Codecov
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
# Step 7: Install build tools
- name: Install build tools
run: pip install build
# Step 8: Build a binary wheel and source tarball
- name: Build a binary wheel and source tarball
run: |
python -m build --sdist --wheel --outdir dist/
# Step 9: Debugging - List contents of dist directory
- name: List contents of dist directory
run: ls -al dist/
# Step 10: Install the package from the built tarball
- name: Install the package from the tarball
run: pip install dist/*.tar.gz
# Step 11: Publish package to PyPI
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.INTREG_TOKEN }}