Skip to content

Revise version for consistency with pypi #20

Revise version for consistency with pypi

Revise version for consistency with pypi #20

name: Python Package using Conda
on:
push:
tags:
- 'v*.*.*' # Trigger on version tags like v1.0.0
pull_request:
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: hwm-1.0.0 # Updated environment name for HWM
environment-file: environment.yml
python-version: '3.10' # Ensure compatibility with HWM requirements
auto-activate-base: false
- name: Set PYTHONPATH
run: |
echo "Setting PYTHONPATH"
echo "PYTHONPATH=$PYTHONPATH:$(pwd)/hwm" >> $GITHUB_ENV # Updated path for HWM
- name: Install Dependencies
run: |
python -m pip install --user "numpy<2" cython # Install specific dependencies
- name: Compile Cython Modules
run: |
find . -name "*.pyx" -exec cythonize -i {} \; # Compile all Cython .pyx files
- name: Install HWM Package
run: |
python -m pip install . # Install the HWM package
- name: Configure Conda
run: |
echo "Configuring conda..."
conda config --set channel_priority strict
conda config --set solver classic
- name: Lint with flake8
run: |
python -m pip install flake8
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
python -m pip install pytest pytest-xdist
pytest -n auto # Utilize all available CPU cores for testing
- name: Build Conda Package
run: |
conda install conda-build
conda build . # Build Conda package
- name: Publish to PyPI
if: github.ref_type == 'tag' # Only publish on tagged releases
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m pip install --upgrade twine
twine upload dist/* # Upload package to PyPI
- name: Publish to Anaconda
if: github.ref_type == 'tag'
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
conda install anaconda-client
anaconda login --token $ANACONDA_TOKEN
anaconda upload path/to/your-package.tar.bz2 # Update with actual package path
- name: Clean up workspace
run: |
find . -name "*.so" -delete
find . -name "*.c" -delete
find . -name "*.cpp" -delete
- name: Upload pytest results
if: failure() # Executes only if previous steps fail
uses: actions/upload-artifact@v3
with:
name: pytest-results
path: ./.pytest_cache/
- name: Debugging Information
if: failure() # Executes only if previous steps fail
run: |
echo "Printing debug information..."
echo "PATH=$PATH"
conda info
conda list