Skip to content

Commit

Permalink
Merge pull request #2420 from hoffie/actions-cache-create-dmg
Browse files Browse the repository at this point in the history
Build: Cache brew/create-dmg install
  • Loading branch information
hoffie authored Feb 28, 2022
2 parents 158a0ab + 6b48f6d commit 259545f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ jobs:
path: |
/usr/local/opt/qt
~/Library/Caches/pip
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 }}
~/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', 'mac/deploy_mac.sh') }}-${{ matrix.config.cmd1_prebuild }}

- name: "Cache Windows dependencies"
if: ${{ matrix.config.target_os == 'windows' }}
Expand Down
28 changes: 25 additions & 3 deletions mac/deploy_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}")"

Expand All @@ -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}" ];
Expand Down

0 comments on commit 259545f

Please sign in to comment.