From 005671a25b380fb70fbebc1870a4019a867f076c Mon Sep 17 00:00:00 2001 From: David Ochoa Date: Sat, 2 Dec 2023 16:54:02 +0000 Subject: [PATCH] feat: semantic release automation --- .github/workflows/release.yaml | 40 ++++++++++++++++ poetry.lock | 84 +++++++++++++++++++++++++++++++++- pyproject.toml | 11 ++--- src/otg/__init__.py | 2 + tests/test_docs.py | 2 +- 5 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..39f42ae41 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,40 @@ +name: Semantic Release + +on: + push: + branches: + - master + +jobs: + release: + runs-on: ubuntu-latest + concurrency: release + permissions: + id-token: write + contents: write + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.OTG_ETL_RELEASE }} + + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install poetry --upgrade pip + poetry config virtualenvs.create false + poetry install + + - name: Python Semantic Release + run: | + git config --global user.name "github-actions" + git config --global user.email "action@github.com" + semantic-release publish -D commit_author="github-actions " + env: + GH_TOKEN: ${{secrets.OTG_ETL_RELEASE}} + # PyPI_TOKEN: ${{secrets.PyPI_TOKEN}} diff --git a/poetry.lock b/poetry.lock index 0d60a7f82..8b3f5d0fa 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1760,6 +1760,17 @@ files = [ {file = "docutils-0.20.1.tar.gz", hash = "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b"}, ] +[[package]] +name = "dotty-dict" +version = "1.3.1" +description = "Dictionary wrapper for quick access to deeply nested keys." +optional = false +python-versions = ">=3.5,<4.0" +files = [ + {file = "dotty_dict-1.3.1-py3-none-any.whl", hash = "sha256:5022d234d9922f13aa711b4950372a06a6d64cb6d6db9ba43d0ba133ebfce31f"}, + {file = "dotty_dict-1.3.1.tar.gz", hash = "sha256:4b016e03b8ae265539757a53eba24b9bfda506fb94fbce0bee843c6f05541a15"}, +] + [[package]] name = "email-validator" version = "1.3.1" @@ -6412,6 +6423,25 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "python-gitlab" +version = "3.15.0" +description = "Interact with GitLab API" +optional = false +python-versions = ">=3.7.0" +files = [ + {file = "python-gitlab-3.15.0.tar.gz", hash = "sha256:c9e65eb7612a9fbb8abf0339972eca7fd7a73d4da66c9b446ffe528930aff534"}, + {file = "python_gitlab-3.15.0-py3-none-any.whl", hash = "sha256:8f8d1c0d387f642eb1ac7bf5e8e0cd8b3dd49c6f34170cee3c7deb7d384611f3"}, +] + +[package.dependencies] +requests = ">=2.25.0" +requests-toolbelt = ">=0.10.1" + +[package.extras] +autocompletion = ["argcomplete (>=1.10.0,<3)"] +yaml = ["PyYaml (>=5.2)"] + [[package]] name = "python-json-logger" version = "2.0.7" @@ -6437,6 +6467,36 @@ files = [ Jinja2 = ">=2.8" python-slugify = ">=1.2.5" +[[package]] +name = "python-semantic-release" +version = "8.3.0" +description = "Automatic Semantic Versioning for Python projects" +optional = false +python-versions = ">=3.7" +files = [ + {file = "python-semantic-release-8.3.0.tar.gz", hash = "sha256:62325bf32738ea1223ad4efaba0809bac4355ea2d4ad214f676232613a6625f4"}, + {file = "python_semantic_release-8.3.0-py3-none-any.whl", hash = "sha256:7a26551af9f56485571b7e7831c342a327b16931560d58bc5de99b1cf1dc7ef5"}, +] + +[package.dependencies] +click = ">=8,<9" +dotty-dict = ">=1.3.0,<2" +gitpython = ">=3.0.8,<4" +importlib-resources = ">=5.7,<7" +jinja2 = ">=3.1.2,<4" +pydantic = ">=2,<3" +python-gitlab = ">=2,<4" +requests = ">=2.25,<3" +rich = ">=12.5.1" +shellingham = ">=1.5.0.post1" +tomlkit = ">=0.10,<1.0" + +[package.extras] +dev = ["black", "pre-commit", "ruff (==0.0.292)", "tox"] +docs = ["Sphinx (<=6.0.0)", "furo (>=2023.3.27)", "sphinx-autobuild (==2021.03.14)", "sphinxcontrib-apidoc (==0.3.0)"] +mypy = ["mypy", "types-requests"] +test = ["coverage[toml] (>=6,<8)", "pytest (>=7,<8)", "pytest-clarity (>=1.0.1)", "pytest-cov (>=4,<5)", "pytest-lazy-fixture (>=0.6.3,<0.7.0)", "pytest-mock (>=3,<4)", "pytest-pretty (>=1.2.0,<2)", "pytest-xdist (>=2,<4)", "requests-mock (>=1.10.0,<2)", "responses (==0.23.3)", "types-pytest-lazy-fixture (>=0.6.3.3)"] + [[package]] name = "python-slugify" version = "8.0.1" @@ -7360,6 +7420,17 @@ numpy = ">=1.14" docs = ["matplotlib", "numpydoc (==1.1.*)", "sphinx", "sphinx-book-theme", "sphinx-remove-toctrees"] test = ["pytest", "pytest-cov"] +[[package]] +name = "shellingham" +version = "1.5.4" +description = "Tool to Detect Surrounding Shell" +optional = false +python-versions = ">=3.7" +files = [ + {file = "shellingham-1.5.4-py2.py3-none-any.whl", hash = "sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686"}, + {file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"}, +] + [[package]] name = "six" version = "1.16.0" @@ -7680,6 +7751,17 @@ files = [ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] +[[package]] +name = "tomlkit" +version = "0.12.3" +description = "Style preserving TOML library" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomlkit-0.12.3-py3-none-any.whl", hash = "sha256:b0a645a9156dc7cb5d3a1f0d4bab66db287fcb8e0430bdd4664a095ea16414ba"}, + {file = "tomlkit-0.12.3.tar.gz", hash = "sha256:75baf5012d06501f07bee5bf8e801b9f343e7aac5a92581f20f80ce632e6b5a4"}, +] + [[package]] name = "tornado" version = "6.3.3" @@ -8236,4 +8318,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "3.10.8" -content-hash = "2456a037d91c98b6c23b41a40d6fad70983414ac4388166bcde6bf6d5d6a88f5" +content-hash = "5021fc0668eca64873ba89e0365d695d04f1907e42c1778b1a1888bfaf57b17a" diff --git a/pyproject.toml b/pyproject.toml index 46b7589e3..2e7723c44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "otgenetics" -version = "1.0.0" +version = "0.0.1" description = "Open targets Genetics Portal Python ETL" authors = ["Open Targets core team"] license = "Apache License v2" @@ -64,17 +64,16 @@ google-cloud-dataproc = "^5.7.0" apache-airflow = "^2.7.3" apache-airflow-providers-google = "^10.11.1" pydoclint = "^0.3.8" - +python-semantic-release = "^8.3.0" [tool.semantic_release] branch = "main" -version_variable = "src/otg/__init__.py:__version__" +version_variable = ["src/otg/__init__.py:__version__"] version_toml = ["pyproject.toml:tool.poetry.version"] -version_source = "tag" -commit_version_number = true # required for version_source = "tag" -tag_commit = true +major_on_zero = true upload_to_pypi = false upload_to_release = false +build_command = "pip install poetry && poetry build" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/src/otg/__init__.py b/src/otg/__init__.py index 9a6eccd24..b4eb0215b 100644 --- a/src/otg/__init__.py +++ b/src/otg/__init__.py @@ -1,3 +1,5 @@ """Modules supporting Genetics Portal analysis.""" from __future__ import annotations + +__version__ = "0.0.1" diff --git a/tests/test_docs.py b/tests/test_docs.py index ec9c4fb36..52d00970d 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -13,7 +13,7 @@ def mkdocs_build() -> None: """Fixture to build documentation.""" try: - cfg = load_config("mkdocs.yml", strict=False) + cfg = load_config("mkdocs.yml", strict=True) cfg.plugins["material/search"].on_startup(command="build", dirty=not "clean") # config = load_config() # config.strict = True