name: Release
on:
push:
branches:
- master
jobs:
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
name: Release
runs-on: ubuntu-latest
steps:
- name: Getting code
uses: actions/checkout@master
- name: Getting Python
uses: actions/setup-python@master
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Getting Poetry
uses: dschep/install-poetry-action@v1.3
- name: Getting PostgreSQL
uses: harmon758/postgresql-action@v1
with:
postgresql db: 'test_db'
postgresql user: 'postgres'
postgresql password: 'postgres'
- name: Installing dependencies
run: poetry install
- name: Running tests
run: make coverage_run
- name: Running coverage check
run: make coverage_cmd_report
- name: Running codestyle checks
run: make check_black
- name: Running types checks
run: make check_mypy
- name: Generate coverage report
run: make coverage_xml_report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
- name: Getting package version
id: get_version
run: echo "::set-output name=version::$(poetry version)"
- name: Getting package clear version
id: get_clear_version
run: echo "::set-output name=clear_version::$(poetry version | cut -d ' ' -f 2)"
- name: Make release and publish
run: make release USERNAME=${{ secrets.PYPI_USERNAME }} TOKEN=${{ secrets.PYPI_TOKEN }}
- name: Get asset name
id: get_asset_name
run: echo "::set-output name=assert_name::$(ls dist | grep gz)"
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_clear_version.outputs.clear_version }}
release_name: ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
- name: Upload Release assets
id: upload_gz
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ steps.get_asset_name.outputs.assert_name }}
asset_name: ${{ steps.get_asset_name.outputs.assert_name }}
asset_content_type: application/tar+gzip