diff --git a/.github/workflows/semantic_release.yml b/.github/workflows/semantic_release.yml new file mode 100644 index 0000000..19f58a5 --- /dev/null +++ b/.github/workflows/semantic_release.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea3c027..ce3fdde 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/custom_components/car_wash/__init__.py b/custom_components/car_wash/__init__.py index da4a86a..7a34749 100644 --- a/custom_components/car_wash/__init__.py +++ b/custom_components/car_wash/__init__.py @@ -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" diff --git a/script/version_bump.py b/script/version_bump.py index fca1117..3254308 100755 --- a/script/version_bump.py +++ b/script/version_bump.py @@ -18,6 +18,8 @@ _LOGGER = logging.getLogger(__name__) +VERSION = "1.1.2" + ROOT = os.path.dirname(os.path.abspath(f"{__file__}/..")) sys.path.append(ROOT) @@ -25,22 +27,23 @@ 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) @@ -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", @@ -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" diff --git a/setup.cfg b/setup.cfg index 9769c0e..a2b449b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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