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 2 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
81 changes: 61 additions & 20 deletions .github/workflows/main.yml
Expand Up @@ -9,6 +9,38 @@ on:
workflow_dispatch:

jobs:
lint:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logs for the Build package step shows the name of the built artifacts is pytest-asyncio-0.1.dev1+ga5205f2.tar.gz and pytest_asyncio-0.1.dev1+ga5205f2-py3-none-any.whl. As far as I understand these are reused in the deploy stage later.

I expected them to be to have a version like pytest_asyncio-0.16.1+gabcd1234… not 0.1.dev1.

The checkout action seems to do a shallow clone with --no-tags. Is it possible this prevents setuptools_scm from determining the correct version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch-depth: 0 should fix it. Let's see

name: "Run linters"
runs-on: "ubuntu-latest"
outputs:
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "3.9"

- name: "Install poetry, check-wheel-content, and twine"
asvetlov marked this conversation as resolved.
Show resolved Hide resolved
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"
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 Down Expand Up @@ -41,7 +73,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 +83,32 @@ jobs:
- name: Upload coverage
uses: aio-libs/upload-coverage@v21.9.4

package:
name: "Build & verify package"
runs-on: "ubuntu-latest"

deploy:
name: Deploy
environment: release
needs: [lint, check]
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
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/*"
- name: Checkout
uses: actions/checkout@v2.4.0
- name: Download disctributions
asvetlov marked this conversation as resolved.
Show resolved Hide resolved
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