Skip to content

Update CI to newest action versions #288

Update CI to newest action versions

Update CI to newest action versions #288

Workflow file for this run

name: Push
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
PROJECT_NAME: flogging
VERSION_FILE: flogging/version.py
DEFAULT_BRANCH: main
BOT_NAME: fragile-bot
BOT_EMAIL: bot@fragile.tech
BOT_AUTH_TOKEN: ${{ secrets.BOT_AUTH_TOKEN }}
TEST_PYPI_PASS: ${{ secrets.TEST_PYPI_PASS }}
PYPI_PASS: ${{ secrets.PYPI_PASS }}
DOCKER_ORG: fragiletech
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_LOGIN }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASS }}
PIP_CACHE: |
~/.cache/pip
~/.local/bin
~/.local/lib/python3.*/site-packages
jobs:
Style-check:
if: "!contains(github.event.head_commit.message, 'Bump version')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: '**/requirements-lint.txt'
- name: Install lint dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements-lint.txt ]; then pip install -r requirements-lint.txt; fi
- name: Run style check and linter
run: |
make check
Pytest:
needs: Style-check
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
steps:
- name: actions/checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements.txt
**/requirements-test.txt
- name: actions/cache
uses: actions/cache@v3
with:
path: ${{ env.PIP_CACHE }}
key: ubuntu-20.04-pip-test-${{ matrix.python-version }}-${{ hashFiles('requirements.txt', 'requirements-test.txt') }}
restore-keys: ubuntu-20.04-pip-test-
- name: Install test and package dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
- name: Test with pytest
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage report
if: ${{ matrix.python-version=='3.8' }}
uses: codecov/codecov-action@v1
Build-pypi:
needs: Style-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements.txt
**/requirements-test.txt
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel bumpversion
- name: Create unique version for test.pypi
run: |
set -e
git pull --no-edit origin $DEFAULT_BRANCH
current_version=$(grep __version__ $VERSION_FILE | cut -d\" -f2)
ts=$(date +%s)
new_version="$current_version$ts"
bumpversion --current-version $current_version --new-version $new_version patch $VERSION_FILE
- name: Build package
run: |
python setup.py --version
python setup.py bdist_wheel sdist --format=gztar
twine check dist/*
- name: Publish package to TestPyPI
if: "'$TEST_PYPI_PASS' != ''"
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TEST_PYPI_PASS }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
Test-pypi:
if: "'$TEST_PYPI_PASS' != ''"
needs: Build-pypi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements.txt
**/requirements-test.txt
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple $PROJECT_NAME
python -m pip install -r requirements-test.txt
- name: Test package
run: |
mv $PROJECT_NAME/tests ./tests
rm -rf $PROJECT_NAME
pytest
Bump-version:
if: "!contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/main' && '$BOT_AUTH_TOKEN' != ''"
needs:
- Test-pypi
- Pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 100
persist-credentials: false
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
git config --global user.name "${BOT_NAME}"
git config --global user.email "${BOT_EMAIL}"
git config --global pull.rebase false
pip install bump2version
- name: Run bump version
run: |
set -x
git pull --no-edit origin $DEFAULT_BRANCH
current_version=$(grep __version__ $VERSION_FILE | cut -d\" -f2)
bumpversion --tag --current-version $current_version --commit patch $VERSION_FILE
git remote add ${BOT_NAME}-remote https://${BOT_NAME}:${BOT_AUTH_TOKEN}@github.com/$GITHUB_REPOSITORY
git push --tags ${BOT_NAME}-remote HEAD:$DEFAULT_BRANCH
set +e
Release-package:
if: "contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/main' && '$PYPI_PASS' != ''"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements.txt
**/requirements-test.txt
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel
- name: Build package
run: |
python setup.py --version
python setup.py bdist_wheel sdist --format=gztar
twine check dist/*
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_PASS }}