Development #43
Workflow file for this run
This file contains hidden or 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: Test and Tag and Publish | |
on: | |
push: | |
branches: [ main, development ] | |
pull_request: | |
branches: [ main, development ] | |
release: | |
types: [created] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build pytest pytest-cov ruff toml | |
pip install -r requirements.txt | |
pip install -e . | |
- name: Lint with ruff | |
run: | | |
ruff check . | |
- name: Test with pytest | |
run: | | |
pytest --cov | |
- name: Build package | |
run: python -m build | |
create-tag: | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development') | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get version from pyproject.toml | |
id: get_version | |
run: | | |
version=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | |
echo "version=$version" >> $GITHUB_OUTPUT | |
- name: Create and push tag | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release v${{ steps.get_version.outputs.version }}" | |
git push origin "v${{ steps.get_version.outputs.version }}" | |
publish: | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' && github.event.action == 'created' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build pytest pytest-cov ruff twine | |
pip install -r requirements.txt | |
pip install -e . | |
- name: Run tests | |
run: | | |
pytest --cov | |
- name: Build package | |
run: python -m build | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
python -m twine check dist/* | |
python -m twine upload --skip-existing dist/* |