From 385d75a5477d261301c75d39181430e89a3ba930 Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:15:11 +0200 Subject: [PATCH] chore(ci): modify release to use poetry (#5) * Update release.yml * minor * change name --- .github/workflows/lint.yml | 163 ++++++++++++++++------------------ .github/workflows/release.yml | 62 +++++++++---- pyproject.toml | 2 +- 3 files changed, 126 insertions(+), 101 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7c5a6a64..c125bc15 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,85 +1,80 @@ ---- - name: Linting +name: Linting - # yamllint disable-line rule:truthy - on: - push: - branches: - - main - pull_request: - workflow_dispatch: - - env: - DEFAULT_PYTHON: "3.11" - - jobs: - codespell: - name: codespell - runs-on: ubuntu-latest - steps: - - name: โคต๏ธ Check out code from GitHub - uses: actions/checkout@v4.1.7 - - name: ๐Ÿ— Set up Poetry - run: pipx install poetry - - name: ๐Ÿ— Set up Python ${{ env.DEFAULT_PYTHON }} - id: python - uses: actions/setup-python@v5.1.1 - with: - python-version: ${{ env.DEFAULT_PYTHON }} - cache: "poetry" - - name: ๐Ÿ— Install workflow dependencies - run: | - poetry config virtualenvs.create true - poetry config virtualenvs.in-project true - - name: ๐Ÿ— Install Python dependencies - run: poetry install --no-interaction - - name: ๐Ÿš€ Check code for common misspellings - run: poetry run codespell **/*.py - - ruff: - name: Ruff - runs-on: ubuntu-latest - steps: - - name: โคต๏ธ Check out code from GitHub - uses: actions/checkout@v4.1.7 - - name: ๐Ÿ— Set up Poetry - run: pipx install poetry - - name: ๐Ÿ— Set up Python ${{ env.DEFAULT_PYTHON }} - id: python - uses: actions/setup-python@v5.1.1 - with: - python-version: ${{ env.DEFAULT_PYTHON }} - cache: "poetry" - - name: ๐Ÿ— Install workflow dependencies - run: | - poetry config virtualenvs.create true - poetry config virtualenvs.in-project true - - name: ๐Ÿ— Install Python dependencies - run: poetry install --no-interaction - - name: ๐Ÿš€ Run ruff linter - run: poetry run ruff check --output-format=github . -# - name: ๐Ÿš€ Run ruff formatter -# run: poetry run ruff format --check . - - pylint: - name: pylint - runs-on: ubuntu-latest - steps: - - name: โคต๏ธ Check out code from GitHub - uses: actions/checkout@v4.1.7 - - name: ๐Ÿ— Set up Poetry - run: pipx install poetry - - name: ๐Ÿ— Set up Python ${{ env.DEFAULT_PYTHON }} - id: python - uses: actions/setup-python@v5.1.1 - with: - python-version: ${{ env.DEFAULT_PYTHON }} - cache: "poetry" - - name: ๐Ÿ— Install workflow dependencies - run: | - poetry config virtualenvs.create true - poetry config virtualenvs.in-project true - - name: ๐Ÿ— Install Python dependencies - run: poetry install --no-interaction - - name: ๐Ÿš€ Run pylint - run: poetry run pylint **/*.py +# yamllint disable-line rule:truthy +on: + push: + branches: + - main + pull_request: + workflow_dispatch: +env: + DEFAULT_PYTHON: "3.11" +jobs: + codespell: + name: codespell + runs-on: ubuntu-latest + steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v4.1.7 + - name: ๐Ÿ— Set up Poetry + run: pipx install poetry + - name: ๐Ÿ— Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v5.1.1 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + cache: "poetry" + - name: ๐Ÿ— Install workflow dependencies + run: | + poetry config virtualenvs.create true + poetry config virtualenvs.in-project true + - name: ๐Ÿ— Install Python dependencies + run: poetry install --no-interaction + - name: ๐Ÿš€ Check code for common misspellings + run: poetry run codespell **/*.py + ruff: + name: ruff + runs-on: ubuntu-latest + steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v4.1.7 + - name: ๐Ÿ— Set up Poetry + run: pipx install poetry + - name: ๐Ÿ— Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v5.1.1 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + cache: "poetry" + - name: ๐Ÿ— Install workflow dependencies + run: | + poetry config virtualenvs.create true + poetry config virtualenvs.in-project true + - name: ๐Ÿ— Install Python dependencies + run: poetry install --no-interaction + - name: ๐Ÿš€ Run ruff linter + run: poetry run ruff check --output-format=github . + # - name: ๐Ÿš€ Run ruff formatter + # run: poetry run ruff format --check . + pylint: + name: pylint + runs-on: ubuntu-latest + steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v4.1.7 + - name: ๐Ÿ— Set up Poetry + run: pipx install poetry + - name: ๐Ÿ— Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v5.1.1 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + cache: "poetry" + - name: ๐Ÿ— Install workflow dependencies + run: | + poetry config virtualenvs.create true + poetry config virtualenvs.in-project true + - name: ๐Ÿ— Install Python dependencies + run: poetry install --no-interaction + - name: ๐Ÿš€ Run pylint + run: poetry run pylint **/*.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 850eed7d..214da9b9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,26 +1,56 @@ -name: Upload Python Package +name: Release +# yamllint disable-line rule:truthy on: release: - types: [created] + types: + - published + +env: + DEFAULT_PYTHON: "3.11" jobs: - deploy: + release: + name: Releasing to PyPi runs-on: ubuntu-latest +# environment: +# name: release +# url: https://pypi.org/p/python-homeassistant-analytics + permissions: + contents: write + id-token: write steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v4.1.7 + - name: ๐Ÿ— Set up Poetry + run: pipx install poetry + - name: ๐Ÿ— Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v5.1.1 with: - python-version: "3.x" - - name: Install dependencies + python-version: ${{ env.DEFAULT_PYTHON }} + cache: "poetry" + - name: ๐Ÿ— Install workflow dependencies run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_APITOKEN }} + poetry config virtualenvs.create true + poetry config virtualenvs.in-project true + - name: ๐Ÿ— Install dependencies + run: poetry install --no-interaction + - name: ๐Ÿ— Set package version run: | - python setup.py sdist bdist_wheel - twine upload dist/* + version="${{ github.event.release.tag_name }}" + version="${version,,}" + version="${version#v}" + poetry version --no-interaction "${version}" + - name: ๐Ÿ— Build package + run: poetry build --no-interaction + - name: ๐Ÿš€ Publish to PyPi + uses: pypa/gh-action-pypi-publish@v1.9.0 + with: + verbose: true + print-hash: true +# - name: โœ๏ธ Sign published artifacts +# uses: sigstore/gh-action-sigstore-python@v3.0.0 +# with: +# inputs: ./dist/*.tar.gz ./dist/*.whl +# release-signing-artifacts: true diff --git a/pyproject.toml b/pyproject.toml index 90439b09..dc191aae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "pyvicare" +name = "pyvicare-neo" version = "0.1.0" description = "Library to communicate with the Viessmann ViCare API." authors = [