Skip to content

Commit f44f8fe

Browse files
committed
Second attempt to get file hashes when git checkout is done
1 parent 6c89081 commit f44f8fe

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

.github/autobuild/get_build_vars.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import os
3636
import re
3737
import subprocess
38+
import hashlib
3839

3940
REPO_PATH = os.path.join(os.path.dirname(__file__), '..', '..')
4041

@@ -74,6 +75,15 @@ def set_github_variable(varname, varval):
7475
with open(output_file, "a") as ghout:
7576
ghout.write(f"{varname}={varval}\n")
7677

78+
def hash_files(file_list):
79+
key = hashlib.sha256()
80+
mem = memoryview(bytearray(128*1024))
81+
for file_name in file_list:
82+
with open(file_name, 'rb', buffering=0) as f:
83+
while n := f.readinto(mv):
84+
key.update(mv[:n])
85+
return key.hexdigest()
86+
7787
jamulus_pro_version = get_version_from_jamulus_pro()
7888
set_github_variable("JAMULUS_PRO_VERSION", jamulus_pro_version)
7989
build_type, build_version = get_build_version(jamulus_pro_version)
@@ -103,3 +113,7 @@ def set_github_variable(varname, varval):
103113
set_github_variable("IS_PRERELEASE", str(is_prerelease).lower())
104114
set_github_variable("RELEASE_TITLE", release_title)
105115
set_github_variable("RELEASE_TAG", release_tag)
116+
117+
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']) )
118+
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']) )
119+
set_github_variable("CACHE_KEY_ANDROID", hash_files([REPO_PATH + '/.github/workflows/autobuild.yml', REPO_PATH + '/.github/autobuild/android.sh']) )

.github/workflows/autobuild.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ jobs:
6767
publish_to_release: ${{ steps.get-build-vars.outputs.PUBLISH_TO_RELEASE }}
6868
tag_name: ${{ steps.get-build-vars.outputs.RELEASE_TAG }}
6969
build_version: ${{ steps.get-build-vars.outputs.BUILD_VERSION }}
70+
cache_key_macos: ${{ steps.get-build-vars.outputs.CACHE_KEY_MACOS }}
71+
cache_key_windows: ${{ steps.get-build-vars.outputs.CACHE_KEY_WINDOWS }}
72+
cache_key_android: ${{ steps.get-build-vars.outputs.CACHE_KEY_ANDROID }}
7073
build_all_targets: ${{ steps.decide-build-targets.outputs.build_all_targets }}
7174
env:
7275
release_changelog_path: ./.github_release_changelog.md
@@ -323,7 +326,7 @@ jobs:
323326
path: |
324327
~/qt
325328
~/Library/Cache/jamulus-dependencies
326-
key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', '.github/autobuild/mac.sh', 'mac/deploy_mac.sh') }}-${{ matrix.config.base_command }}
329+
key: ${{ matrix.config.target_os }}-${{ steps.get-build-vars.outputs.CACHE_KEY_MACOS }}-${{ matrix.config.base_command }}
327330

328331
- name: Cache Windows dependencies
329332
if: matrix.config.target_os == 'windows'
@@ -335,7 +338,7 @@ jobs:
335338
C:\AutobuildCache
336339
${{ github.workspace }}\libs\NSIS\NSIS-source
337340
${{ github.workspace }}\libs\ASIOSDK2
338-
key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', '.github/autobuild/windows.ps1', 'windows/deploy_windows.ps1') }}-${{ matrix.config.base_command }}
341+
key: ${{ matrix.config.target_os }}-${{ steps.get-build-vars.outputs.CACHE_KEY_WINDOWS }}-${{ matrix.config.base_command }}
339342

340343
- name: Cache Android dependencies
341344
if: matrix.config.target_os == 'android'
@@ -345,7 +348,7 @@ jobs:
345348
/opt/Qt
346349
/opt/android/android-sdk
347350
/opt/android/android-ndk
348-
key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', '.github/autobuild/android.sh') }}-${{ matrix.config.base_command }}
351+
key: ${{ matrix.config.target_os }}-${{ steps.get-build-vars.outputs.CACHE_KEY_ANDROID }}-${{ matrix.config.base_command }}
349352

350353
- name: Set up build dependencies for ${{ matrix.config.config_name }}
351354
run: ${{ matrix.config.base_command }} setup

0 commit comments

Comments
 (0)