Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release process automation #252

Merged
merged 6 commits into from Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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