diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e87fb71e2b..205468b3e4f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,8 +10,9 @@ on: pull_request: ~ env: - CACHE_VERSION: 5 + CACHE_VERSION: 7 PIP_CACHE_VERSION: 1 + HA_SHORT_VERSION: 2022.3 DEFAULT_PYTHON: 3.9 PRE_COMMIT_CACHE: ~/.cache/pre-commit PIP_CACHE: /tmp/pip-cache @@ -155,8 +156,8 @@ jobs: - name: Generate partial pip restore key id: generate-pip-key run: >- - echo "::set-output name=key::base-pip-${{ env.PIP_CACHE_VERSION }}-$( - date -u '+%Y-%m-%dT%H:%M:%s')" + echo "::set-output name=key::base-pip-${{ env.PIP_CACHE_VERSION }}-${{ + env.HA_SHORT_VERSION }}-$(date -u '+%Y-%m-%dT%H:%M:%s')" - name: Restore base Python virtual environment id: cache-venv uses: actions/cache@v2.1.7 @@ -183,7 +184,7 @@ jobs: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ steps.generate-pip-key.outputs.key }} restore-keys: | - ${{ runner.os }}-${{ steps.python.outputs.python-version }}-base-pip-${{ env.PIP_CACHE_VERSION }}- + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-base-pip-${{ env.PIP_CACHE_VERSION }}-${{ env.HA_SHORT_VERSION }}- - name: Create Python virtual environment if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -543,8 +544,8 @@ jobs: - name: Generate partial pip restore key id: generate-pip-key run: >- - echo "::set-output name=key::pip-${{ env.PIP_CACHE_VERSION }}-$( - date -u '+%Y-%m-%dT%H:%M:%s')" + echo "::set-output name=key::pip-${{ env.PIP_CACHE_VERSION }}-${{ + env.HA_SHORT_VERSION }}-$(date -u '+%Y-%m-%dT%H:%M:%s')" - name: Restore full Python ${{ matrix.python-version }} virtual environment id: cache-venv uses: actions/cache@v2.1.7 @@ -571,7 +572,7 @@ jobs: ${{ runner.os }}-${{ matrix.python-version }}-${{ steps.generate-pip-key.outputs.key }} restore-keys: | - ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ env.PIP_CACHE_VERSION }}- + ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ env.PIP_CACHE_VERSION }}-${{ env.HA_SHORT_VERSION }}- - name: Create full Python ${{ matrix.python-version }} virtual environment if: steps.cache-venv.outputs.cache-hit != 'true' run: | diff --git a/script/version_bump.py b/script/version_bump.py index 6044cdb277c..7cc27c2e1e7 100755 --- a/script/version_bump.py +++ b/script/version_bump.py @@ -131,6 +131,23 @@ def write_version_metadata(version: Version) -> None: fp.write(content) +def write_ci_workflow(version: Version) -> None: + """Update ci workflow with new version.""" + with open(".github/workflows/ci.yaml") as fp: + content = fp.read() + + short_version = ".".join(str(version).split(".", maxsplit=2)[:2]) + content = re.sub( + r"(\n\W+HA_SHORT_VERSION: )\d{4}\.\d{1,2}\n", + f"\\g<1>{short_version}\n", + content, + count=1, + ) + + with open(".github/workflows/ci.yaml", "w") as fp: + fp.write(content) + + def main(): """Execute script.""" parser = argparse.ArgumentParser(description="Bump version of Home Assistant") @@ -154,6 +171,7 @@ def main(): write_version(bumped) write_version_metadata(bumped) + write_ci_workflow(bumped) if not arguments.commit: return