From be7cdf78f99f5c2057fc9b9071656e1a40d19fc0 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Mon, 21 Feb 2022 00:59:59 +0100 Subject: [PATCH 1/2] Build: Cache brew/create-dmg install Fixes #2412 --- .github/workflows/autobuild.yml | 1 + mac/deploy_mac.sh | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 4ef640fde1..4d4f431f14 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -182,6 +182,7 @@ jobs: path: | /usr/local/opt/qt ~/Library/Caches/pip + ~/Library/Cache/jamulus-homebrew-bottles key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/mac/artifacts/autobuild_mac_1_prepare.sh', 'autobuild/mac/codeQL/autobuild_mac_1_prepare.sh') }}-${{ matrix.config.cmd1_prebuild }} - name: "Cache Windows dependencies" diff --git a/mac/deploy_mac.sh b/mac/deploy_mac.sh index a284e819a5..c2aa0a343b 100755 --- a/mac/deploy_mac.sh +++ b/mac/deploy_mac.sh @@ -69,9 +69,8 @@ build_installer_image() { # Install create-dmg via brew. brew needs to be installed first. # Download and later install. This is done to make caching possible - local create_dmg_version="1.0.9" - brew extract --version="${create_dmg_version}" create-dmg homebrew/cask - brew install /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Formula/create-dmg@"${create_dmg_version}".rb + brew_install_pinned "create-dmg" "1.0.9" + # Get Jamulus version local app_version="$(sed -nE 's/^VERSION *= *(.*)$/\1/p' "${project_path}")" @@ -93,6 +92,29 @@ build_installer_image() } +brew_install_pinned() { + local pkg="$1" + local version="$2" + local pkg_version="${pkg}@${version}" + local brew_bottle_dir="${HOME}/Library/Cache/jamulus-homebrew-bottles" + local formula="/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Formula/${pkg_version}.rb" + echo "Installing ${pkg_version}" + mkdir -p "${brew_bottle_dir}" + pushd "${brew_bottle_dir}" + if ! find . | grep -qF "${pkg_version}--"; then + echo "Building fresh ${pkg_version} package" + brew developer on # avoids a warning + brew extract --version="${version}" "${pkg}" homebrew/cask + brew install --build-bottle --formula "${formula}" + brew bottle "${formula}" + # In order to keep the result the same, we uninstall and re-install without --build-bottle later + # (--build-bottle is documented to change behavior, e.g. by not running postinst scripts). + brew uninstall "${pkg_version}" + fi + brew install "${pkg_version}--"* + popd +} + # Check that we are running from the correct location if [ ! -f "${project_path}" ]; From 6b48f6d9d8b658cb5573a1cec19ec9fc07a7d768 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Sun, 27 Feb 2022 12:04:31 +0100 Subject: [PATCH 2/2] Build: Make mac/deploy_mac.sh part of the actions/cache key Failing to do so will lead to a missing cache reset when updating e.g. create-dmg's vesion. Related: #2412 --- .github/workflows/autobuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 4d4f431f14..1c106f11ff 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -183,7 +183,7 @@ jobs: /usr/local/opt/qt ~/Library/Caches/pip ~/Library/Cache/jamulus-homebrew-bottles - key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/mac/artifacts/autobuild_mac_1_prepare.sh', 'autobuild/mac/codeQL/autobuild_mac_1_prepare.sh') }}-${{ matrix.config.cmd1_prebuild }} + key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/mac/artifacts/autobuild_mac_1_prepare.sh', 'autobuild/mac/codeQL/autobuild_mac_1_prepare.sh', 'mac/deploy_mac.sh') }}-${{ matrix.config.cmd1_prebuild }} - name: "Cache Windows dependencies" if: ${{ matrix.config.target_os == 'windows' }}