Skip to content

bumped version

bumped version #22

Workflow file for this run

name: Ubuntu/MacOS/Windows/Lint/Docs/Publish
on:
push:
branches:
- main
paths:
- 'setup.py'
- 'asrpy/**'
- 'tests/**'
- '.github/workflows/publish.yml'
jobs:
test:
name: Test, Lint, and Coverage on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-cov flake8
- name: Run linting with flake8
run: flake8 asrpy/ tests/
- name: Run unit tests with coverage
run: |
pytest --cov=asrpy --cov-report=xml tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-coverage
fail_ci_if_error: true
publish:
name: Build and Publish to PyPI
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install tools
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine requests
- name: Get version from setup.py
id: get_version
run: |
VERSION=$(python setup.py --version)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if version already exists on PyPI
id: check_version
run: |
VERSION="${{ steps.get_version.outputs.version }}"
PACKAGE="asrpy"
EXISTS=$(python -c "import json, sys, urllib.request;
package = sys.argv[1]
version = sys.argv[2]
versions = json.load(urllib.request.urlopen(f'https://pypi.org/pypi/{package}/json'))['releases']
print('true' if version in versions else 'false')" "$PACKAGE" "$VERSION")
echo "exists=$EXISTS" >> $GITHUB_OUTPUT
- name: Stop if version already exists
if: steps.check_version.outputs.exists == 'true'
run: echo "Version already exists on PyPI — skipping publish."
- name: Build distribution
if: steps.check_version.outputs.exists == 'false'
run: python setup.py sdist bdist_wheel
- name: Publish to PyPI
if: steps.check_version.outputs.exists == 'false'
env:
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/* -u __token__ -p "$TWINE_PASSWORD"
- name: Generate documentation with pdoc3
if: steps.check_version.outputs.exists == 'false'
run: |
pip install pdoc3
pip install -e .
pdoc3 --html --output-dir docs asrpy -f -c sort_identifiers=False
- name: Deploy Docs to GitHub Pages
if: steps.check_version.outputs.exists == 'false'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/asrpy