Add mac codesign cipd package in flutter deps, so that it can be used by engine_v2 (others can use it as well, though I don't think anything other than engine_v2 would use it).

Change-Id: I3836c030ce3d72a098f55e3871f92395290889f6
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/32281
Commit-Queue: Xilai Zhang <xilaizhang@google.com>
Reviewed-by: Casey Hillers <chillers@google.com>
diff --git a/recipe_modules/flutter_deps/api.py b/recipe_modules/flutter_deps/api.py
index 756e40c..79d0189 100644
--- a/recipe_modules/flutter_deps/api.py
+++ b/recipe_modules/flutter_deps/api.py
@@ -60,6 +60,7 @@
         'chrome_and_driver': self.chrome_and_driver,
         'clang': self.clang,
         'cmake': self.cmake,
+        'codesign': self.codesign,
         'cosign': self.cosign,
         'curl': self.curl,
         'dart_sdk': self.dart_sdk,
@@ -404,6 +405,26 @@
     paths.append(cmake_path.join('bin'))
     env_prefixes['PATH'] = paths
 
+  def codesign(self, env, env_prefixes, version=None):
+    """Installs codesign at https://chrome-infra-packages.appspot.com/p/flutter/codesign.
+
+    Args:
+      env(dict): Current environment variables.
+      env_prefixes(dict): Current environment prefixes variables.
+    """
+    if version != 'latest':
+        msg = 'codesign version is None.'
+        raise ValueError(msg)
+    version = version or 'latest'
+    codesign_path = self.m.path.mkdtemp().join('codesign')
+    codesign = self.m.cipd.EnsureFile()
+    codesign.add_package('flutter/codesign/${platform}', version)
+    with self.m.step.nest('Installing Mac codesign CIPD pkg'):
+      self.m.cipd.ensure(codesign_path, codesign)
+    paths = env_prefixes.get('PATH', [])
+    paths.append(codesign_path)
+    env_prefixes['PATH'] = paths
+
   def cosign(self, env, env_prefixes, version=None):
     """Installs cosign.
 
diff --git a/recipe_modules/flutter_deps/examples/full.expected/basic.json b/recipe_modules/flutter_deps/examples/full.expected/basic.json
index 695aa43..427e4b5 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/basic.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/basic.json
@@ -401,6 +401,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_2/codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -517,7 +550,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -671,10 +704,11 @@
         "[CLEANUP]/tmp_tmp_1/vpython",
         "[START_DIR]/firebase",
         "[CACHE]/cmake/bin",
+        "[CLEANUP]/tmp_tmp_2/codesign",
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json b/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
index 2f62c72..4d4317f 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
@@ -485,6 +485,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_2/codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -601,7 +634,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -757,10 +790,11 @@
         "[CLEANUP]/tmp_tmp_1/vpython",
         "[START_DIR]/firebase",
         "[CACHE]/cmake/bin",
+        "[CLEANUP]/tmp_tmp_2/codesign",
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json b/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
index 695aa43..427e4b5 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
@@ -401,6 +401,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_2/codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -517,7 +550,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -671,10 +704,11 @@
         "[CLEANUP]/tmp_tmp_1/vpython",
         "[START_DIR]/firebase",
         "[CACHE]/cmake/bin",
+        "[CLEANUP]/tmp_tmp_2/codesign",
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/linux.json b/recipe_modules/flutter_deps/examples/full.expected/linux.json
index 695aa43..427e4b5 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/linux.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/linux.json
@@ -401,6 +401,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_2/codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -517,7 +550,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -671,10 +704,11 @@
         "[CLEANUP]/tmp_tmp_1/vpython",
         "[START_DIR]/firebase",
         "[CACHE]/cmake/bin",
+        "[CLEANUP]/tmp_tmp_2/codesign",
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json b/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
index 4cda25e..90bfd88 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
@@ -485,6 +485,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_2/codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -601,7 +634,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -757,10 +790,11 @@
         "[CLEANUP]/tmp_tmp_1/vpython",
         "[START_DIR]/firebase",
         "[CACHE]/cmake/bin",
+        "[CLEANUP]/tmp_tmp_2/codesign",
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/mac.json b/recipe_modules/flutter_deps/examples/full.expected/mac.json
index 97efba4..409f229 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/mac.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/mac.json
@@ -463,6 +463,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_2/codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -579,7 +612,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/windows.json b/recipe_modules/flutter_deps/examples/full.expected/windows.json
index 6f327bd..6148298 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/windows.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/windows.json
@@ -401,6 +401,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd.bat",
+      "ensure",
+      "-root",
+      "[CLEANUP]\\tmp_tmp_2\\codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -517,7 +550,7 @@
       "cipd.bat",
       "ensure",
       "-root",
-      "[CLEANUP]\\tmp_tmp_2\\curl",
+      "[CLEANUP]\\tmp_tmp_3\\curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -638,10 +671,11 @@
         "[CLEANUP]\\tmp_tmp_1\\vpython",
         "[START_DIR]\\firebase",
         "[CACHE]\\cmake\\bin",
+        "[CLEANUP]\\tmp_tmp_2\\codesign",
         "[CACHE]\\cosign\\bin",
         "[CACHE]\\ninja",
         "[CACHE]\\clang\\bin",
-        "[CLEANUP]\\tmp_tmp_2\\curl"
+        "[CLEANUP]\\tmp_tmp_3\\curl"
       ]
     },
     "name": "Install Certs"
@@ -712,10 +746,11 @@
         "[CLEANUP]\\tmp_tmp_1\\vpython",
         "[START_DIR]\\firebase",
         "[CACHE]\\cmake\\bin",
+        "[CLEANUP]\\tmp_tmp_2\\codesign",
         "[CACHE]\\cosign\\bin",
         "[CACHE]\\ninja",
         "[CACHE]\\clang\\bin",
-        "[CLEANUP]\\tmp_tmp_2\\curl"
+        "[CLEANUP]\\tmp_tmp_3\\curl"
       ]
     },
     "name": "Install VS build"
diff --git a/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json b/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
index 03e8d33..448951c 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
@@ -401,6 +401,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_2/codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -517,7 +550,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -671,10 +704,11 @@
         "[CLEANUP]/tmp_tmp_1/vpython",
         "[START_DIR]/firebase",
         "[CACHE]/cmake/bin",
+        "[CLEANUP]/tmp_tmp_2/codesign",
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/with-gems.json b/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
index 21f7d4c..78355ee 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
@@ -401,6 +401,39 @@
   },
   {
     "cmd": [],
+    "name": "Installing Mac codesign CIPD pkg"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_2/codesign",
+      "-ensure-file",
+      "flutter/codesign/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Installing Mac codesign CIPD pkg.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter/codesign/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
     "name": "Install cosign"
   },
   {
@@ -517,7 +550,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -671,10 +704,11 @@
         "[CLEANUP]/tmp_tmp_1/vpython",
         "[START_DIR]/firebase",
         "[CACHE]/cmake/bin",
+        "[CLEANUP]/tmp_tmp_2/codesign",
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.py b/recipe_modules/flutter_deps/examples/full.py
index 23860bd..601fca2 100644
--- a/recipe_modules/flutter_deps/examples/full.py
+++ b/recipe_modules/flutter_deps/examples/full.py
@@ -54,6 +54,9 @@
   api.flutter_deps.flutter_engine(env, env_prefixes)
   api.flutter_deps.firebase(env, env_prefixes)
   api.flutter_deps.cmake(env, env_prefixes)
+  with api.assertions.assertRaises(ValueError):
+    api.flutter_deps.codesign(env, env_prefixes)
+  api.flutter_deps.codesign(env, env_prefixes, 'latest')
   api.flutter_deps.cosign(env, env_prefixes)
   api.flutter_deps.ninja(env, env_prefixes)
   api.flutter_deps.clang(env, env_prefixes)
diff --git a/recipes/cocoon/cipd.expected/cipd_mac.json b/recipes/cocoon/cipd.expected/cipd_mac.json
index 3ac099f..8cad409 100644
--- a/recipes/cocoon/cipd.expected/cipd_mac.json
+++ b/recipes/cocoon/cipd.expected/cipd_mac.json
@@ -150,6 +150,8 @@
       "cipd",
       "pkg-register",
       "codesign.zip",
+      "-ref",
+      "latest",
       "-json-output",
       "/path/to/tmp/json"
     ],
diff --git a/recipes/cocoon/cipd.expected/cipd_win.json b/recipes/cocoon/cipd.expected/cipd_win.json
index e0d8668..9dc4876 100644
--- a/recipes/cocoon/cipd.expected/cipd_win.json
+++ b/recipes/cocoon/cipd.expected/cipd_win.json
@@ -149,6 +149,8 @@
       "cipd.bat",
       "pkg-register",
       "device_doctor.zip",
+      "-ref",
+      "latest",
       "-json-output",
       "/path/to/tmp/json"
     ],
diff --git a/recipes/cocoon/cipd.py b/recipes/cocoon/cipd.py
index 536ed36..1a55e79 100644
--- a/recipes/cocoon/cipd.py
+++ b/recipes/cocoon/cipd.py
@@ -58,7 +58,7 @@
     cipd_zip_path = project_name + '.zip'
 
     api.cipd.build(project_path.join('build'), cipd_zip_path, cipd_full_name)
-    api.cipd.register(cipd_full_name, cipd_zip_path)
+    api.cipd.register(cipd_full_name, cipd_zip_path, refs = ["latest"])
 
 
 def GenTests(api):