diff --git a/.github/autobuild/get_build_vars.py b/.github/autobuild/get_build_vars.py index 891db8980e..260dd57c4a 100755 --- a/.github/autobuild/get_build_vars.py +++ b/.github/autobuild/get_build_vars.py @@ -35,6 +35,7 @@ import os import re import subprocess +import hashlib REPO_PATH = os.path.join(os.path.dirname(__file__), '..', '..') @@ -74,6 +75,15 @@ def set_github_variable(varname, varval): with open(output_file, "a") as ghout: ghout.write(f"{varname}={varval}\n") +def hash_files(file_list): + key = hashlib.sha256() + mem = memoryview(bytearray(128*1024)) + for file_name in file_list: + with open(file_name, 'rb', buffering=0) as f: + while n := f.readinto(mem): + key.update(mem[:n]) + return key.hexdigest() + jamulus_pro_version = get_version_from_jamulus_pro() set_github_variable("JAMULUS_PRO_VERSION", jamulus_pro_version) build_type, build_version = get_build_version(jamulus_pro_version) @@ -103,3 +113,7 @@ def set_github_variable(varname, varval): set_github_variable("IS_PRERELEASE", str(is_prerelease).lower()) set_github_variable("RELEASE_TITLE", release_title) set_github_variable("RELEASE_TAG", release_tag) + +set_github_variable("CACHE_KEY_MACOS", hash_files([REPO_PATH + '/.github/workflows/autobuild.yml', REPO_PATH + '/.github/autobuild/mac.sh', REPO_PATH + '/mac/deploy_mac.sh']) ) +set_github_variable("CACHE_KEY_WINDOWS", hash_files([REPO_PATH + '/.github/workflows/autobuild.yml', REPO_PATH + '/.github/autobuild/windows.ps1', REPO_PATH + '/windows/deploy_windows.ps1']) ) +set_github_variable("CACHE_KEY_ANDROID", hash_files([REPO_PATH + '/.github/workflows/autobuild.yml', REPO_PATH + '/.github/autobuild/android.sh']) ) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 82d9786a5e..e7ba0d60e7 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -67,6 +67,9 @@ jobs: publish_to_release: ${{ steps.get-build-vars.outputs.PUBLISH_TO_RELEASE }} tag_name: ${{ steps.get-build-vars.outputs.RELEASE_TAG }} build_version: ${{ steps.get-build-vars.outputs.BUILD_VERSION }} + cache_key_macos: ${{ steps.get-build-vars.outputs.CACHE_KEY_MACOS }} + cache_key_windows: ${{ steps.get-build-vars.outputs.CACHE_KEY_WINDOWS }} + cache_key_android: ${{ steps.get-build-vars.outputs.CACHE_KEY_ANDROID }} build_all_targets: ${{ steps.decide-build-targets.outputs.build_all_targets }} env: release_changelog_path: ./.github_release_changelog.md @@ -323,7 +326,7 @@ jobs: path: | ~/qt ~/Library/Cache/jamulus-dependencies - key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', '.github/autobuild/mac.sh', 'mac/deploy_mac.sh') }}-${{ matrix.config.base_command }} + key: ${{ matrix.config.target_os }}-${{ needs.create_release.outputs.cache_key_macos }}-${{ matrix.config.base_command }} - name: Cache Windows dependencies if: matrix.config.target_os == 'windows' @@ -335,7 +338,7 @@ jobs: C:\AutobuildCache ${{ github.workspace }}\libs\NSIS\NSIS-source ${{ github.workspace }}\libs\ASIOSDK2 - key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', '.github/autobuild/windows.ps1', 'windows/deploy_windows.ps1') }}-${{ matrix.config.base_command }} + key: ${{ matrix.config.target_os }}-${{ needs.create_release.outputs.cache_key_windows }}-${{ matrix.config.base_command }} - name: Cache Android dependencies if: matrix.config.target_os == 'android' @@ -345,7 +348,7 @@ jobs: /opt/Qt /opt/android/android-sdk /opt/android/android-ndk - key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', '.github/autobuild/android.sh') }}-${{ matrix.config.base_command }} + key: ${{ matrix.config.target_os }}-${{ needs.create_release.outputs.cache_key_android }}-${{ matrix.config.base_command }} - name: Set up build dependencies for ${{ matrix.config.config_name }} run: ${{ matrix.config.base_command }} setup