2323 use_ccache :
2424 required : false
2525 type : boolean
26- default : false
26+ default : true
2727 outputs :
2828 semver :
2929 value : ${{ jobs.Prepare.outputs.semver }}
@@ -88,12 +88,14 @@ jobs:
8888 BUILD_DIR : ${{ github.workspace }}/build/build
8989 INSTALL_DIR : ${{ github.workspace }}/build/install
9090 CCACHE_DIR : ${{ github.workspace }}/build/ccache
91+ CCACHE_MAXSIZE : ' 0'
92+ CCACHE_KEY_PREFIX : ccache-${{ matrix.os }}-${{ matrix.arch }}-
9193 BUILD_TYPE : ${{ inputs.build_type }}
9294 VERSION_IDENTIFIER : ${{ needs.Prepare.outputs.version_identifier }}
9395 EXPECTED_SEMVER : ${{ needs.Prepare.outputs.semver }}
9496 ARTIFACT_PLATFORM : ${{ matrix.platform }}
9597 ARTIFACT_ARCH : ${{ matrix.arch }}
96- USE_CCACHE : ${{ inputs.build_type != 'nightly' && inputs. use_cache && inputs.use_ccache }}
98+ USE_CCACHE : ${{ inputs.use_cache && inputs.use_ccache }}
9799 steps :
98100 - name : Checkout repository
99101 uses : actions/checkout@v4
@@ -113,7 +115,8 @@ jobs:
113115 uses : ./.github/actions/initialize-build-environment
114116 with :
115117 qt_version : ${{ env.QT_VERSION }}
116- use_cache : ${{ inputs.build_type != 'nightly' && inputs.use_cache }}
118+ use_cache : ${{ inputs.use_cache }}
119+ use_ccache : ${{ inputs.use_cache && inputs.use_ccache }}
117120
118121 - name : Download dspm
119122 id : download_dspm
@@ -127,7 +130,7 @@ jobs:
127130 variant : standalone
128131 directory : ${{ runner.temp }}/dspm-download
129132 fail-on-no-match : ' true'
130- cache : ${{ inputs.build_type != 'nightly' && inputs. use_cache }}
133+ cache : ${{ inputs.use_cache }}
131134
132135 - name : Download dssp
133136 id : download_dssp
@@ -141,7 +144,7 @@ jobs:
141144 variant : portable
142145 directory : ${{ runner.temp }}/dssp-download
143146 fail-on-no-match : ' true'
144- cache : ${{ inputs.build_type != 'nightly' && inputs. use_cache }}
147+ cache : ${{ inputs.use_cache }}
145148
146149 - name : Extract dssp
147150 if : steps.download_dssp.outputs.matched == 'true'
@@ -173,16 +176,19 @@ jobs:
173176 VCPKG_KEEP_ENV_VARS : VCPKG_BUILD_TYPE;MACOSX_DEPLOYMENT_TARGET
174177 with :
175178 qt-dir : ${{ env.QT_ROOT_DIR }}
176- cache : ${{ inputs.build_type != 'nightly' && inputs. use_cache }}
179+ cache : ${{ inputs.use_cache }}
177180
178181 - name : Restore CCache cache
179- if : inputs.build_type != 'nightly' && inputs. use_cache && inputs.use_ccache
182+ if : inputs.use_cache && inputs.use_ccache
180183 uses : actions/cache/restore@v4
181184 with :
182185 path : ${{ env.CCACHE_DIR }}
183- key : ${{ runner.os }}-ccache-${{ inputs.source_sha }}
184- restore-keys : |
185- ${{ runner.os }}-ccache-
186+ key : ${{ env.CCACHE_KEY_PREFIX }}${{ github.run_id }}-${{ github.run_attempt }}
187+ restore-keys : ${{ env.CCACHE_KEY_PREFIX }}
188+
189+ - name : Prepare CCache
190+ if : inputs.use_cache && inputs.use_ccache
191+ run : ./scripts/ci/Manage-CCache.ps1 -Operation prepare
186192
187193 - name : Build
188194 env :
@@ -213,12 +219,17 @@ jobs:
213219 "APPLICATION_NAME=$($output.ApplicationName)" >> $env:GITHUB_ENV
214220 "INSTALLER_FILE_BASE=$($output.InstallerFileBase)" >> $env:GITHUB_ENV
215221
222+ - name : Prepare CCache snapshot
223+ id : ccache_snapshot
224+ if : inputs.use_cache && inputs.use_ccache && github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
225+ run : ./scripts/ci/Manage-CCache.ps1 -Operation snapshot
226+
216227 - name : Save CCache cache
217- if : inputs.build_type != 'nightly' && inputs.use_cache && inputs.use_ccache
228+ if : steps.ccache_snapshot.outputs.save == 'true'
218229 uses : actions/cache/save@v4
219230 with :
220231 path : ${{ env.CCACHE_DIR }}
221- key : ${{ runner.os }}-ccache- ${{ inputs.source_sha }}
232+ key : ${{ env.CCACHE_KEY_PREFIX }}${{ github.run_id }}- ${{ github.run_attempt }}
222233
223234 - name : Collect symbol files
224235 env :
0 commit comments