Skip to content

Commit

Permalink
Merge branch 'release/v1.2.15'
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed Sep 13, 2020
2 parents 9346f77 + c68e416 commit 0b1e731
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 17 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/semantic_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: semantic_release

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
with:
ref: master
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install python-semantic-release
- name: Setup Git
run: |
git config --global user.name "semantic-release"
git config --global user.email "semantic-release@GitHub"
- name: Publish with semantic-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DEBUG='*' semantic-release publish
# Pack the ha-car_wash dir as a zip and upload to the release
- name: Zip car_wash dir
run: |
cd /home/runner/work/ha-car_wash/ha-car_wash/custom_components/car_wash
zip car_wash.zip -r ./
- name: Set release variable
run: |
echo "::set-env name=release_version::`git describe --abbrev=0`"
- name: Sleep
# add delay so upload does not kill the release notes from semantic-release
run: |
sleep 5
- name: Upload zip to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /home/runner/work/ha-car_wash/ha-car_wash/custom_components/car_wash/car_wash.zip
asset_name: car_wash.zip
tag: ${{ env.release_version }}
overwrite: true
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ repos:
- id: no-commit-to-branch
args:
- --branch=master
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.23.0
hooks:
- id: yamllint
- repo: local
hooks:
# Run mypy through our wrapper script in order to get the possible
Expand Down
2 changes: 1 addition & 1 deletion custom_components/car_wash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"""

# Base component constants
VERSION = '1.2.14'
VERSION = '1.2.15'
ISSUE_URL = "https://github.com/Limych/ha-car_wash/issues"
27 changes: 15 additions & 12 deletions script/version_bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,32 @@

_LOGGER = logging.getLogger(__name__)

VERSION = "1.1.2"

ROOT = os.path.dirname(os.path.abspath(f"{__file__}/.."))

sys.path.append(ROOT)


def fallback_version(localpath):
"""Return version from regex match."""
return_value = ""
if os.path.isfile(localpath):
with open(localpath) as local:
ret = re.compile(r"^\b(VERSION|__version__)\s*=\s*['\"](.*)['\"]")
for line in local.readlines():
matcher = ret.match(line)
if matcher:
return_value = str(matcher.group(2))
return return_value
for fname in ("__init__", "const"):
fpath = f"{localpath}/{fname}.py"
if os.path.isfile(fpath):
with open(fpath) as local:
ret = re.compile(r"^\b(VERSION|__version__)\s*=\s*['\"](.*)['\"]")
for line in local.readlines():
matcher = ret.match(line)
if matcher:
return str(matcher.group(2))
return ""


def get_package_version(localpath, package):
"""Return the local version if any."""
_LOGGER.debug("Started for %s (%s)", localpath, package)
return_value = ""
if os.path.isfile(localpath):
if os.path.isfile(f"{localpath}/__init__.py"):
try:
name = "__version__"
return_value = getattr(__import__(f"..{package}", fromlist=[name]), name)
Expand Down Expand Up @@ -178,7 +181,7 @@ def write_version(package_path, version, dry_run=False):
def main():
"""Execute script."""
parser = argparse.ArgumentParser(
description="Bump version of Home Assistant custom component"
description=f"Bump version of Python package. Version {VERSION}"
)
parser.add_argument(
"type",
Expand Down Expand Up @@ -222,7 +225,7 @@ def main():
package_dir = f"{ROOT}/custom_components/{package}"
package = f"custom_components.{package}"

current = Version(get_package_version(f"{package_dir}/__init__.py", package))
current = Version(get_package_version(package_dir, package))
bumped = bump_version(current, arguments.type)
assert bumped > current, "BUG! New version is not newer than old version"

Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ exclude =

[mypy]
ignore_missing_imports = True

[semantic_release]
version_variable=custom_components/car_wash/__init__.py:VERSION
upload_to_pypi=false
upload_to_release=false

0 comments on commit 0b1e731

Please sign in to comment.