Skip to content

Commit

Permalink
Release process automation (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jan 13, 2022
1 parent 2eb12a7 commit cd84987
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 21 deletions.
17 changes: 17 additions & 0 deletions .github/actionlint-matcher.json
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "actionlint",
"pattern": [
{
"code": 5,
"column": 3,
"file": 1,
"line": 2,
"message": 4,
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$"
}
]
}
]
}
88 changes: 70 additions & 18 deletions .github/workflows/main.yml
Expand Up @@ -9,6 +9,43 @@ on:
workflow_dispatch:

jobs:
lint:
name: Run linters
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install GitHub matcher for ActionLint checker
run: |
echo "::add-matcher::.github/actionlint-matcher.json"
- name: Install check-wheel-content, and twine
run: python -m pip install build check-wheel-contents tox twine
- name: Build package
run: python -m build
- name: Run tox for linter
run: python -m tox -e lint
- name: List result
run: ls -l dist
- name: Check wheel contents
run: check-wheel-contents dist/*.whl
- name: Check long_description
run: python -m twine check dist/*
- name: Get version info
id: version
run: tox -e version-info
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: dist
path: dist

test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
Expand All @@ -21,6 +58,8 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -41,7 +80,7 @@ jobs:
check:
name: Check
if: always()
needs: [test]
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand All @@ -51,23 +90,36 @@ jobs:
- name: Upload coverage
uses: aio-libs/upload-coverage@v21.9.4

package:
name: Build & verify package
deploy:
name: Deploy
environment: release
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: [lint, check]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Checkout
uses: actions/checkout@v2.4.0
with:
python-version: '3.9'

- name: Install poetry, check-wheel-content, and twine
run: python -m pip install build check-wheel-contents twine
- name: Build package
run: python -m build
- name: List result
run: ls -l dist
- name: Check wheel contents
run: check-wheel-contents dist/*.whl
- name: Check long_description
run: python -m twine check dist/*
fetch-depth: 0
- name: Download distributions
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Collected dists
run: |
tree dist
- name: PyPI upload
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
packages_dir: dist
password: ${{ secrets.PYPI_API_TOKEN }}
- name: GitHub Release
uses: ncipollo/release-action@v1
with:
name: pytest-asyncio ${{ needs.lint.outputs.version }}
artifacts: dist
bodyFile: README.rst
prerelease: ${{ needs.lint.outputs.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions tools/get-version.py
@@ -0,0 +1,17 @@
import json
import sys
from importlib import metadata

from packaging.version import parse as parse_version


def main():
version_string = metadata.version("pytest-asyncio")
version = parse_version(version_string)
print(f"::set-output name=version::{version}")
prerelease = json.dumps(version.is_prerelease)
print(f"::set-output name=prerelease::{prerelease}")


if __name__ == "__main__":
sys.exit(main())
18 changes: 15 additions & 3 deletions tox.ini
@@ -1,20 +1,25 @@
[tox]
minversion = 3.14.0
envlist = py37, py38, py39, py310, lint
envlist = py37, py38, py39, py310, lint, version-info
skip_missing_interpreters = true
passenv =
CI

[testenv]
extras = testing
commands = make test
allowlist_externals =
make

[testenv:lint]
skip_install = true
basepython = python3.9
extras = tests
deps =
pre-commit
pre-commit == 2.16.0
commands =
make lint
allowlist_externals =
make

[testenv:coverage-report]
deps = coverage
Expand All @@ -23,6 +28,13 @@ commands =
coverage combine
coverage report

[testenv:version-info]
basepython = python3.9
deps =
packaging == 21.3
commands =
python ./tools/get-version.py

[gh-actions]
python =
3.7: py37
Expand Down

0 comments on commit cd84987

Please sign in to comment.