Skip to content

bump repo dependencies #76

bump repo dependencies

bump repo dependencies #76

name: Lint, Test and Release
on: [push]
jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Setup Environment
id: setup
run: |
echo "python-version=$(cat .tool-versions | grep -Po '(?<=python ).*')" >> $GITHUB_OUTPUT
echo "poetry-version=$(cat .tool-versions | grep -Po '(?<=poetry ).*')" >> $GITHUB_OUTPUT
if [ $GITHUB_REF == 'refs/heads/master' ]; then echo "ENV=prod"; else echo "ENV=staging"; fi >> $GITHUB_ENV
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ steps.setup.outputs.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ steps.setup.outputs.poetry-version }}
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/.pre-commit-config.yaml') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Run linting pre-commit hooks
run: script -e -c "poetry run pre-commit run --all-files"
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Setup Environment
id: setup
run: |
echo "python-version=$(cat .tool-versions | grep -Po '(?<=python ).*')" >> $GITHUB_OUTPUT
echo "poetry-version=$(cat .tool-versions | grep -Po '(?<=poetry ).*')" >> $GITHUB_OUTPUT
if [ $GITHUB_REF == 'refs/heads/master' ]; then echo "ENV=prod"; else echo "ENV=staging"; fi >> $GITHUB_ENV
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ steps.setup.outputs.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ steps.setup.outputs.poetry-version }}
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/.pre-commit-config.yaml') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Run unit tests
env:
ENV: test
run: script -e -c "poetry run python -m pytest -v example/tests"
release:
runs-on: ubuntu-20.04
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
uses: alexeyatbluescape/github-tag-action@bugfix/semver-empty-results
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
- name: Setup Environment
id: setup
run: |
echo "python-version=$(cat .tool-versions | grep -Po '(?<=python ).*')" >> $GITHUB_OUTPUT
echo "poetry-version=$(cat .tool-versions | grep -Po '(?<=poetry ).*')" >> $GITHUB_OUTPUT
if [ $GITHUB_REF == 'refs/heads/master' ]; then echo "ENV=prod"; else echo "ENV=staging"; fi >> $GITHUB_ENV
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ steps.setup.outputs.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ steps.setup.outputs.poetry-version }}
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/.pre-commit-config.yaml') }}
# Installing twine in a separate step to prevent circular dependencies and conflicts with cache
- name: Install pip twine
run: pip install --upgrade pip twine
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Build and publish to Pypi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
poetry version $(git describe --tags --abbrev=0)
poetry build
twine upload dist/* --verbose