From d54ff5dfeff3fa8ff387a6a2dfa8452492b0f771 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 12 Jan 2022 16:33:31 +0200 Subject: [PATCH 1/5] Release process automation --- .github/workflows/main.yml | 81 ++++++++++++++++++++++++++++---------- tools/get-version.py | 17 ++++++++ tox.ini | 18 +++++++-- 3 files changed, 93 insertions(+), 23 deletions(-) create mode 100644 tools/get-version.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 784ea5e2..192b93fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,38 @@ 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" + - 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: "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" @@ -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 @@ -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 + 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 }} diff --git a/tools/get-version.py b/tools/get-version.py new file mode 100644 index 00000000..e988a32c --- /dev/null +++ b/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()) diff --git a/tox.ini b/tox.ini index dc09b8c5..0092b03e 100644 --- a/tox.ini +++ b/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 @@ -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 From da4924b88dc23cc4dc17808557ebccdf0b6710a0 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 12 Jan 2022 16:50:19 +0200 Subject: [PATCH 2/5] Fix --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 192b93fe..bcaef847 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: python-version: "3.9" - name: "Install poetry, check-wheel-content, and twine" - run: "python -m pip install build check-wheel-contents twine" + run: "python -m pip install build check-wheel-contents tox twine" - name: "Build package" run: "python -m build" - name: "Run tox for linter" From 23cf5444fb98d3dfbe341cdb75f833e360d78c52 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 12 Jan 2022 18:16:22 +0200 Subject: [PATCH 3/5] Fix notes --- .github/workflows/main.yml | 51 ++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bcaef847..a19a671c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,11 +17,12 @@ jobs: prerelease: ${{ steps.version.outputs.prerelease }} steps: - uses: "actions/checkout@v2" + fetch-depth: 0 - uses: "actions/setup-python@v2" with: python-version: "3.9" - - name: "Install poetry, check-wheel-content, and twine" + - 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" @@ -53,6 +54,7 @@ jobs: steps: - uses: "actions/checkout@v2" + fetch-depth: 0 - uses: "actions/setup-python@v2" with: python-version: "${{ matrix.python-version }}" @@ -89,26 +91,27 @@ jobs: needs: [lint, check] runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2.4.0 - - name: Download disctributions - 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 }} + - name: Checkout + uses: actions/checkout@v2.4.0 + fetch-depth: 0 + - name: Download disctributions + 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 }} From 56c47f90b66c1cb757df4e7097e0068b133a9700 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 12 Jan 2022 18:17:24 +0200 Subject: [PATCH 4/5] Fix typo --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a19a671c..dfc080cd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -94,7 +94,7 @@ jobs: - name: Checkout uses: actions/checkout@v2.4.0 fetch-depth: 0 - - name: Download disctributions + - name: Download distributions uses: actions/download-artifact@v2 with: name: dist From 4eeef6e342282df4290920c11b0a8e7170c30ca9 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Thu, 13 Jan 2022 10:12:28 +0200 Subject: [PATCH 5/5] Deploy on tag ppushing only --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6805d6fe..186b31b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -93,6 +93,8 @@ jobs: 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: