diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 88e925ab..f50314cf 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -23,7 +23,8 @@ runs: - name: macOS tools if: runner.os == 'macOS' shell: bash - run: brew install autoconf autoconf-archive automake pkg-config + run: | + brew install autoconf autoconf-archive automake pkg-config md5sha1sum - name: simple build run: echo "preset = ${{ inputs.preset }}" @@ -39,16 +40,26 @@ runs: # get baseline from vcpkg vcpkgJsonGlob: './vcpkg.json' - - uses: actions/cache@v4 - if: runner.os != 'Linux' - with: - key: deps-${{ inputs.preset }}-${{ hashFiles('./vcpkg.json') }} - path: ./vcpkg_cache + - name: get vcpkg cache key + id: get_vcpkg_cache_key + shell: bash + env: + DISTRO_LABEL: ${{ format('{0}-{1}', matrix.distro.name, matrix.distro.version) }} + KEY_PREFIX: vcpkg_cache-cmake-${{ inputs.preset }} + run: | + common_key="${KEY_PREFIX}-vcpkg_json_md5=$(md5sum ./vcpkg.json | awk '{ print $1 }')" + if [ "${RUNNER_OS}" != "Linux" ]; then + echo "key=${common_key}-ImageVersion=${ImageVersion}" | tee -a $GITHUB_OUTPUT + else + # ImageVersion is irrelevant since the build action runs in a container + # Express the vcpkg overlays, dockerfile, and entry point that the action will use as a single hash + build_action_hash="$(find ./.github/actions/openziti-tunnel-build-action/gh-release -type f -print | xargs md5sum | awk '{ print $1 }' | sort | md5sum | awk '{ print $1 }')" + echo "key=${common_key}-build_action_md5=${build_action_hash}" | tee -a $GITHUB_OUTPUT + fi - uses: actions/cache@v4 - if: runner.os == 'Linux' with: - key: deps=${{ inputs.preset }}-${{ hashFiles('./vcpkg.json', '.github/actions/openziti-tunnel-build-action/gh-release/vcpkg-overlays/**/vcpkg.json') }} + key: ${{ steps.get_vcpkg_cache_key.outputs.key }} path: ./vcpkg_cache - uses: lukka/run-cmake@v10.6 # pin version to avoid failed glibc dependency on ubuntu 20 runners. go back to @latest when ubuntu 22+ is adopted for runner os. diff --git a/.github/workflows/cpack.yml b/.github/workflows/cpack.yml index 0b7fd380..6c11cbe1 100644 --- a/.github/workflows/cpack.yml +++ b/.github/workflows/cpack.yml @@ -78,7 +78,7 @@ jobs: shell: bash run: | dnf -y update - dnf -y install git + dnf -y install git findutils git --version - name: checkout workspace @@ -93,9 +93,21 @@ jobs: run: | cp -vr ./.github/actions/openziti-tunnel-build-action/${DISTRO_LABEL}/* ./.github/actions/openziti-tunnel-build-action/ + - name: get vcpkg cache key + id: get_vcpkg_cache_key + shell: bash + env: + DISTRO_LABEL: ${{ format('{0}-{1}', matrix.distro.name, matrix.distro.version) }} + KEY_PREFIX: vcpkg_cache-cpack-${{ matrix.arch.rpm }}-${{ matrix.distro.name }}-${{ matrix.distro.version }} + run: | + key_prefix="${KEY_PREFIX}-vcpkg_json_md5=$(md5sum ./vcpkg.json | awk '{ print $1 }')" + # Express the vcpkg overlays, dockerfile, and entry point that the action will use as a single hash + build_action_md5="$(find ./.github/actions/openziti-tunnel-build-action/${DISTRO_LABEL} -type f -print | xargs md5sum | awk '{ print $1 }' | sort | md5sum | awk '{ print $1 }')" + echo "key=${key_prefix}-build_action_md5=${build_action_md5}" | tee -a $GITHUB_OUTPUT + - uses: actions/cache@v4 with: - key: deps-cpack-${{ matrix.arch.rpm }}-${{ matrix.distro.name }}-${{ matrix.distro.version }}-${{ hashFiles('./vcpkg.json', './.github/actions/openziti-tunnel-build-action/vcpkg-overlays/**/vcpkg.json') }} + key: ${{ steps.get_vcpkg_cache_key.outputs.key }} path: ./vcpkg_cache # entrypoint.sh uses the value of arch to select the cmake preset