From b2ad4d8a52360de649c65728d6e33d6e61f45c39 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 13 Jul 2020 12:47:52 +0200 Subject: [PATCH] ci: added auto publishing to PyPi --- .github/workflows/publish.yml | 32 ++++++++++++++++++++++++++++++++ .gitignore | 4 +++- local-requirements.txt | 1 + playwright/__init__.py | 1 + setup.py | 11 ++++++++--- upload_package.py | 17 ----------------- 6 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 upload_package.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..79bb7c50a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,32 @@ +name: Upload Python Package +on: + release: + types: [published] +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: microsoft/playwright-github-action@v1 + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 12.x + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r local-requirements.txt + pip install . + - name: Build driver + run: python build_driver.py + - name: Build package + run: python build_package.py + - name: Publish package + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: twine upload dist/* diff --git a/.gitignore b/.gitignore index b7eb9ba27..584189d69 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ env/ htmlcov/ .coverage .DS_Store -.vscode/ \ No newline at end of file +.vscode/ +.eggs +_repo_version.py diff --git a/local-requirements.txt b/local-requirements.txt index e59115163..ba239bb1c 100644 --- a/local-requirements.txt +++ b/local-requirements.txt @@ -10,3 +10,4 @@ wheel==0.34.2 black==19.10b0 pre-commit==2.6.0 flake8==3.8.3 +twine==3.2.0 diff --git a/playwright/__init__.py b/playwright/__init__.py index a3dc9d611..b3ded8c9b 100644 --- a/playwright/__init__.py +++ b/playwright/__init__.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from playwright._repo_version import version as __version__ # noqa:F401 from playwright.main import playwright_object import playwright.helper as helper diff --git a/setup.py b/setup.py index 1e71d714b..58577be9c 100644 --- a/setup.py +++ b/setup.py @@ -19,16 +19,15 @@ setuptools.setup( name="playwright", - version="0.0.3", author="Microsoft Corporation", author_email="", description="A high-level API to automate web browsers", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/Microsoft/playwright-python", - packages=setuptools.find_packages(), + packages=["playwright"], include_package_data=True, - install_requires=["pyee", "typing-extensions",], + install_requires=["pyee", "typing-extensions"], classifiers=[ "Topic :: Software Development :: Testing", "Topic :: Internet :: WWW/HTTP :: Browsers", @@ -40,4 +39,10 @@ "Operating System :: OS Independent", ], python_requires=">=3.7", + use_scm_version={ + "version_scheme": "post-release", + "write_to": "playwright/_repo_version.py", + "write_to_template": 'version = "{version}"\n', + }, + setup_requires=["setuptools_scm"], ) diff --git a/upload_package.py b/upload_package.py deleted file mode 100644 index f1df1c5a1..000000000 --- a/upload_package.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import subprocess - -subprocess.run("python -m twine upload dist/*", shell=True)