1717 shell : bash
1818 env :
1919 SBT_RUNNER_VERSION : ${{ inputs.sbt-runner-version }}
20- SBT_CACHE_KEY_VERSION : 1.1.25
20+ SBT_CACHE_KEY_VERSION : 1.1.26
2121 run : |
2222 JDK_VERSION=0
2323 if [[ -x "$(command -v java)" ]]; then
@@ -53,10 +53,10 @@ runs:
5353 mkdir -p "$SBT_TOOLPATH"
5454 echo "cache-hit=false" >> "$GITHUB_OUTPUT"
5555 fi
56- - name : Cache sbt distribution
56+ - name : Restore sbt distribution cache
5757 id : cache-dir
5858 if : steps.cache-tool-dir.outputs.cache-hit != 'true'
59- uses : actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
59+ uses : actions/cache/restore @55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
6060 with :
6161 path : ${{ steps.cache-paths.outputs.sbt_toolpath }}
6262 key : ${{ steps.cache-paths.outputs.sbt_cachekey }}
@@ -69,13 +69,19 @@ runs:
6969 key : ${{ steps.cache-paths.outputs.sbt_diskcachekey }}-${{ steps.cache-paths.outputs.sbt_monday }}-${{ hashFiles('**/*.sbt', '**/*.properties') }}
7070 restore-keys : ${{ steps.cache-paths.outputs.sbt_diskcachekey }}
7171 - name : " Download and Install sbt"
72+ id : install
7273 shell : bash
7374 env :
7475 SBT_RUNNER_VERSION : ${{ inputs.sbt-runner-version }}
7576 SBT_TOOLPATH : " ${{ steps.cache-paths.outputs.sbt_toolpath }}"
7677 SBT_DOWNLOADPATH : " ${{ steps.cache-paths.outputs.sbt_downloadpath }}"
77- if : steps.cache-tool-dir.outputs.cache-hit != 'true' && steps.cache-dir.outputs.cache-hit != 'true'
7878 run : |
79+ # Install when the runner is missing on disk, whatever actions/cache's
80+ # cache-hit said: a hit can restore a partial $SBT_TOOLPATH.
81+ if [[ -f "$SBT_TOOLPATH/sbt/bin/sbt" ]]; then
82+ echo "downloaded=false" >> "$GITHUB_OUTPUT"
83+ exit 0
84+ fi
7985 mkdir -p "$SBT_DOWNLOADPATH"
8086 curl -sL "https://github.com/sbt/sbt/releases/download/v$SBT_RUNNER_VERSION/sbt-$SBT_RUNNER_VERSION.zip" > \
8187 "$SBT_DOWNLOADPATH/sbt-$SBT_RUNNER_VERSION.zip"
@@ -85,10 +91,14 @@ runs:
8591 cd "$SBT_DOWNLOADPATH"
8692 unzip -o "sbt-$SBT_RUNNER_VERSION.zip" -d "$SBT_TOOLPATH"
8793
94+ # Never cache or PATH a partial extraction.
95+ test -f "$SBT_TOOLPATH/sbt/bin/sbt"
96+ echo "downloaded=true" >> "$GITHUB_OUTPUT"
97+
8898 - name : " Verify the sbt distribution signature"
8999 id : " ampel-verify"
90100 # Skip on Windows/macOS until go-billy path fix lands: https://github.com/go-git/go-billy/issues/194
91- if : runner.os == 'Linux' && steps.cache-tool-dir .outputs.cache-hit != 'true' && steps.cache-dir.outputs.cache-hit ! = 'true'
101+ if : runner.os == 'Linux' && steps.install .outputs.downloaded = = 'true'
92102 uses : carabiner-dev/actions/ampel/verify@94f29392187fe5082d1195a7d4cae3a7ddf09d9c # v1.2.1
93103 with :
94104 policy : " git+https://github.com/carabiner-dev/policies#signature/signature.json"
@@ -188,6 +198,16 @@ runs:
188198 =CksN
189199 -----END PGP PUBLIC KEY BLOCK-----
190200
201+ - name : " Save sbt distribution cache"
202+ id : cache-dir-save
203+ # Explicit save (not combined actions/cache) so the cache is written only
204+ # after a verified install — never the auto post-job save of a partial dir.
205+ if : steps.install.outputs.downloaded == 'true'
206+ uses : actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
207+ with :
208+ path : ${{ steps.cache-paths.outputs.sbt_toolpath }}
209+ key : ${{ steps.cache-paths.outputs.sbt_cachekey }}
210+
191211 - name : " Setup PATH"
192212 shell : bash
193213 env :
0 commit comments