From 81b728193625a15a55fcce4c6eb6187358533785 Mon Sep 17 00:00:00 2001
From: Deepak Dahiya <59823596+t-dedah@users.noreply.github.com>
Date: Tue, 14 Feb 2023 01:11:58 -0800
Subject: [PATCH 1/6] Updated branch in Force deletion of caches (#1108)

* Updated branch in Force deletion of caches

Fixes this issue https://github.com/actions/cache/issues/1107

* Update tips-and-workarounds.md
---
 tips-and-workarounds.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tips-and-workarounds.md b/tips-and-workarounds.md
index 0cf05a4..7c1bb4a 100644
--- a/tips-and-workarounds.md
+++ b/tips-and-workarounds.md
@@ -53,7 +53,7 @@ jobs:
           gh extension install actions/gh-actions-cache
           
           REPO=${{ github.repository }}
-          BRANCH=${{ github.ref }}
+          BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge
 
           echo "Fetching list of cache key"
           cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )

From 95b455a0fba5a5e1770cc10ded51e5fe99a6737b Mon Sep 17 00:00:00 2001
From: Lovepreet Singh <pdotl@github.com>
Date: Mon, 20 Feb 2023 19:40:25 +0000
Subject: [PATCH 2/6] 3.2.6

---
 package-lock.json | 4 ++--
 package.json      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 4ef558d..a0a46a8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "cache",
-  "version": "3.2.5",
+  "version": "3.2.6",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "cache",
-      "version": "3.2.5",
+      "version": "3.2.6",
       "license": "MIT",
       "dependencies": {
         "@actions/cache": "^3.1.3",
diff --git a/package.json b/package.json
index c5cfcc2..cb9708e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cache",
-  "version": "3.2.5",
+  "version": "3.2.6",
   "private": true,
   "description": "Cache dependencies and build outputs",
   "main": "dist/restore/index.js",

From 8f7fa5d715f6773b40e9fbf9cb77bcb5d914d0dc Mon Sep 17 00:00:00 2001
From: Lovepreet Singh <pdotl@github.com>
Date: Mon, 20 Feb 2023 19:41:53 +0000
Subject: [PATCH 3/6] Bump @actions/cache version

---
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package.json b/package.json
index cb9708e..89c0c3b 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,7 @@
   "author": "GitHub",
   "license": "MIT",
   "dependencies": {
-    "@actions/cache": "^3.1.3",
+    "@actions/cache": "^3.1.4",
     "@actions/core": "^1.10.0",
     "@actions/exec": "^1.1.1",
     "@actions/io": "^1.1.2"

From 7d4d6f7ffd301005e7fac90369bb90ae1d547974 Mon Sep 17 00:00:00 2001
From: Lovepreet Singh <pdotl@github.com>
Date: Mon, 20 Feb 2023 19:42:58 +0000
Subject: [PATCH 4/6] Update package-lock.json

---
 package-lock.json | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index a0a46a8..12ccc83 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
       "version": "3.2.6",
       "license": "MIT",
       "dependencies": {
-        "@actions/cache": "^3.1.3",
+        "@actions/cache": "^3.1.4",
         "@actions/core": "^1.10.0",
         "@actions/exec": "^1.1.1",
         "@actions/io": "^1.1.2"
@@ -36,9 +36,9 @@
       }
     },
     "node_modules/@actions/cache": {
-      "version": "3.1.3",
-      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.3.tgz",
-      "integrity": "sha512-5YbATJUS6nVs9EkpK7JaliC3G5koKdJT99NLreL0gJlznudzZzXGNIheW5+HUT9C2DBvubOxYIyfX4v2UpZWrA==",
+      "version": "3.1.4",
+      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.4.tgz",
+      "integrity": "sha512-Uh9wsz7SxunfyqF3UY/wfHI81z97CYQrZs4NU+whzYd0N8emTaloB+XtrAq46X2RbQEOBjF6R090jKQpX4coGg==",
       "dependencies": {
         "@actions/core": "^1.10.0",
         "@actions/exec": "^1.0.1",
@@ -9722,9 +9722,9 @@
   },
   "dependencies": {
     "@actions/cache": {
-      "version": "3.1.3",
-      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.3.tgz",
-      "integrity": "sha512-5YbATJUS6nVs9EkpK7JaliC3G5koKdJT99NLreL0gJlznudzZzXGNIheW5+HUT9C2DBvubOxYIyfX4v2UpZWrA==",
+      "version": "3.1.4",
+      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.4.tgz",
+      "integrity": "sha512-Uh9wsz7SxunfyqF3UY/wfHI81z97CYQrZs4NU+whzYd0N8emTaloB+XtrAq46X2RbQEOBjF6R090jKQpX4coGg==",
       "requires": {
         "@actions/core": "^1.10.0",
         "@actions/exec": "^1.0.1",

From b1db4b48979ec1f6d6142513d9448c4288d05ec4 Mon Sep 17 00:00:00 2001
From: Lovepreet Singh <pdotl@github.com>
Date: Mon, 20 Feb 2023 19:44:02 +0000
Subject: [PATCH 5/6] Fix zstd breaking after new version release

---
 README.md                  |  1 +
 RELEASES.md                |  3 +++
 dist/restore-only/index.js | 20 ++++++++------------
 dist/restore/index.js      | 20 ++++++++------------
 dist/save-only/index.js    | 20 ++++++++------------
 dist/save/index.js         | 20 ++++++++------------
 6 files changed, 36 insertions(+), 48 deletions(-)

diff --git a/README.md b/README.md
index 35df207..b509076 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac
 * New actions are available for granular control over caches - [restore](restore/action.yml) and [save](save/action.yml).
 * Support cross-os caching as an opt-in feature. See [Cross OS caching](./tips-and-workarounds.md#cross-os-cache) for more info.
 * Added option to fail job on cache miss. See [Exit workflow on cache miss](./restore/README.md#exit-workflow-on-cache-miss) for more info.
+* Fix zstd not being used after zstd version upgrade to 1.5.4 on hosted runners
 
 See the [v2 README.md](https://github.com/actions/cache/blob/v2/README.md) for older updates.
 
diff --git a/RELEASES.md b/RELEASES.md
index 359ded7..a06ec0f 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -73,3 +73,6 @@
 
 ### 3.2.5
 - Added fix to prevent from setting MYSYS environment variable globally.
+
+### 3.2.6
+- Fix zstd not being used after zstd version upgrade to 1.5.4 on hosted runners.
diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js
index 45c628e..0949366 100644
--- a/dist/restore-only/index.js
+++ b/dist/restore-only/index.js
@@ -1152,12 +1152,13 @@ function unlinkFile(filePath) {
     });
 }
 exports.unlinkFile = unlinkFile;
-function getVersion(app) {
+function getVersion(app, additionalArgs = []) {
     return __awaiter(this, void 0, void 0, function* () {
-        core.debug(`Checking ${app} --version`);
         let versionOutput = '';
+        additionalArgs.push('--version');
+        core.debug(`Checking ${app} ${additionalArgs.join(' ')}`);
         try {
-            yield exec.exec(`${app} --version`, [], {
+            yield exec.exec(`${app}`, additionalArgs, {
                 ignoreReturnCode: true,
                 silent: true,
                 listeners: {
@@ -1177,19 +1178,14 @@ function getVersion(app) {
 // Use zstandard if possible to maximize cache performance
 function getCompressionMethod() {
     return __awaiter(this, void 0, void 0, function* () {
-        const versionOutput = yield getVersion('zstd');
+        const versionOutput = yield getVersion('zstd', ['--quiet']);
         const version = semver.clean(versionOutput);
-        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
-            // zstd is not installed
+        core.debug(`zstd version: ${version}`);
+        if (versionOutput === '') {
             return constants_1.CompressionMethod.Gzip;
         }
-        else if (!version || semver.lt(version, 'v1.3.2')) {
-            // zstd is installed but using a version earlier than v1.3.2
-            // v1.3.2 is required to use the `--long` options in zstd
-            return constants_1.CompressionMethod.ZstdWithoutLong;
-        }
         else {
-            return constants_1.CompressionMethod.Zstd;
+            return constants_1.CompressionMethod.ZstdWithoutLong;
         }
     });
 }
diff --git a/dist/restore/index.js b/dist/restore/index.js
index c2dd9b8..6767d7b 100644
--- a/dist/restore/index.js
+++ b/dist/restore/index.js
@@ -1152,12 +1152,13 @@ function unlinkFile(filePath) {
     });
 }
 exports.unlinkFile = unlinkFile;
-function getVersion(app) {
+function getVersion(app, additionalArgs = []) {
     return __awaiter(this, void 0, void 0, function* () {
-        core.debug(`Checking ${app} --version`);
         let versionOutput = '';
+        additionalArgs.push('--version');
+        core.debug(`Checking ${app} ${additionalArgs.join(' ')}`);
         try {
-            yield exec.exec(`${app} --version`, [], {
+            yield exec.exec(`${app}`, additionalArgs, {
                 ignoreReturnCode: true,
                 silent: true,
                 listeners: {
@@ -1177,19 +1178,14 @@ function getVersion(app) {
 // Use zstandard if possible to maximize cache performance
 function getCompressionMethod() {
     return __awaiter(this, void 0, void 0, function* () {
-        const versionOutput = yield getVersion('zstd');
+        const versionOutput = yield getVersion('zstd', ['--quiet']);
         const version = semver.clean(versionOutput);
-        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
-            // zstd is not installed
+        core.debug(`zstd version: ${version}`);
+        if (versionOutput === '') {
             return constants_1.CompressionMethod.Gzip;
         }
-        else if (!version || semver.lt(version, 'v1.3.2')) {
-            // zstd is installed but using a version earlier than v1.3.2
-            // v1.3.2 is required to use the `--long` options in zstd
-            return constants_1.CompressionMethod.ZstdWithoutLong;
-        }
         else {
-            return constants_1.CompressionMethod.Zstd;
+            return constants_1.CompressionMethod.ZstdWithoutLong;
         }
     });
 }
diff --git a/dist/save-only/index.js b/dist/save-only/index.js
index c678c5b..139d8ba 100644
--- a/dist/save-only/index.js
+++ b/dist/save-only/index.js
@@ -1208,12 +1208,13 @@ function unlinkFile(filePath) {
     });
 }
 exports.unlinkFile = unlinkFile;
-function getVersion(app) {
+function getVersion(app, additionalArgs = []) {
     return __awaiter(this, void 0, void 0, function* () {
-        core.debug(`Checking ${app} --version`);
         let versionOutput = '';
+        additionalArgs.push('--version');
+        core.debug(`Checking ${app} ${additionalArgs.join(' ')}`);
         try {
-            yield exec.exec(`${app} --version`, [], {
+            yield exec.exec(`${app}`, additionalArgs, {
                 ignoreReturnCode: true,
                 silent: true,
                 listeners: {
@@ -1233,19 +1234,14 @@ function getVersion(app) {
 // Use zstandard if possible to maximize cache performance
 function getCompressionMethod() {
     return __awaiter(this, void 0, void 0, function* () {
-        const versionOutput = yield getVersion('zstd');
+        const versionOutput = yield getVersion('zstd', ['--quiet']);
         const version = semver.clean(versionOutput);
-        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
-            // zstd is not installed
+        core.debug(`zstd version: ${version}`);
+        if (versionOutput === '') {
             return constants_1.CompressionMethod.Gzip;
         }
-        else if (!version || semver.lt(version, 'v1.3.2')) {
-            // zstd is installed but using a version earlier than v1.3.2
-            // v1.3.2 is required to use the `--long` options in zstd
-            return constants_1.CompressionMethod.ZstdWithoutLong;
-        }
         else {
-            return constants_1.CompressionMethod.Zstd;
+            return constants_1.CompressionMethod.ZstdWithoutLong;
         }
     });
 }
diff --git a/dist/save/index.js b/dist/save/index.js
index adf43e8..cd23f84 100644
--- a/dist/save/index.js
+++ b/dist/save/index.js
@@ -1152,12 +1152,13 @@ function unlinkFile(filePath) {
     });
 }
 exports.unlinkFile = unlinkFile;
-function getVersion(app) {
+function getVersion(app, additionalArgs = []) {
     return __awaiter(this, void 0, void 0, function* () {
-        core.debug(`Checking ${app} --version`);
         let versionOutput = '';
+        additionalArgs.push('--version');
+        core.debug(`Checking ${app} ${additionalArgs.join(' ')}`);
         try {
-            yield exec.exec(`${app} --version`, [], {
+            yield exec.exec(`${app}`, additionalArgs, {
                 ignoreReturnCode: true,
                 silent: true,
                 listeners: {
@@ -1177,19 +1178,14 @@ function getVersion(app) {
 // Use zstandard if possible to maximize cache performance
 function getCompressionMethod() {
     return __awaiter(this, void 0, void 0, function* () {
-        const versionOutput = yield getVersion('zstd');
+        const versionOutput = yield getVersion('zstd', ['--quiet']);
         const version = semver.clean(versionOutput);
-        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
-            // zstd is not installed
+        core.debug(`zstd version: ${version}`);
+        if (versionOutput === '') {
             return constants_1.CompressionMethod.Gzip;
         }
-        else if (!version || semver.lt(version, 'v1.3.2')) {
-            // zstd is installed but using a version earlier than v1.3.2
-            // v1.3.2 is required to use the `--long` options in zstd
-            return constants_1.CompressionMethod.ZstdWithoutLong;
-        }
         else {
-            return constants_1.CompressionMethod.Zstd;
+            return constants_1.CompressionMethod.ZstdWithoutLong;
         }
     });
 }

From 8d3a1e02aa504540dff5000c782b8263e3b411fb Mon Sep 17 00:00:00 2001
From: Lovepreet Singh <pdotl@github.com>
Date: Mon, 20 Feb 2023 20:03:56 +0000
Subject: [PATCH 6/6] Fix license

---
 .licenses/npm/@actions/cache.dep.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.licenses/npm/@actions/cache.dep.yml b/.licenses/npm/@actions/cache.dep.yml
index e6ae37e..ddbc316 100644
--- a/.licenses/npm/@actions/cache.dep.yml
+++ b/.licenses/npm/@actions/cache.dep.yml
@@ -1,6 +1,6 @@
 ---
 name: "@actions/cache"
-version: 3.1.3
+version: 3.1.4
 type: npm
 summary:
 homepage: