       """)
     case let .success(output):
       print(output)
-      return output.trimmingCharacters(in: .whitespacesAndNewlines)
+      let repoName = output.trimmingCharacters(in: .whitespacesAndNewlines)
+      return repoName.isEmpty ? nil : repoName
+    }
+  }
+
+  /// @param defaultRepoName The repo name to register if not exists
+  private static func findOrRegisterPrivateCocoaPodsRepo(repo: String, gitRoot: URL,
+                                                         defaultRepoName: String) -> String {
+    if let repoName = findPrivateCocoaPodsRepo(repo: repo, gitRoot: gitRoot) {
+      return repoName
+    }
+
+    let command = "pod repo add \(defaultRepoName) \(repo)"
+    let result = Shell.executeCommandFromScript(command, workingDir: gitRoot)
+    switch result {
+    case let .error(code, output):
+      fatalError("""
+      `pod --version` failed for \(repo) with exit code \(code)
+      Output from `pod repo list`:
+      \(output)
+      """)
+    case .success:
+      return defaultRepoName
     }
   }
 }

    }
  }

  private static func findPrivateCocoaPodsRepo(repo: String, gitRoot: URL) -> String {
    let command = "pod repo list | grep -B2 \(repo) | head -1"
    let result = Shell.executeCommandFromScript(command, workingDir: gitRoot)
    switch result {


  private static func push(to destination: Destination, gitRoot: URL) {
    let cpdcRepo = "sso://cpdc-internal/firebase"
    let cpdcLocation = findOrRegisterPrivateCocoaPodsRepo(
      repo: cpdcRepo,
      gitRoot: gitRoot,
      defaultRepoName: "cpdc-internal-firebase"
    )
    let stagingRepo = "git@github.com:firebase/SpecsStaging"
    let stagingLocation = findOrRegisterPrivateCocoaPodsRepo(
      repo: stagingRepo,
      gitRoot: gitRoot,
      defaultRepoName: "spec-staging"
    )
    let manifest = FirebaseManifest.shared

    for pod in manifest.pods.filter({ $0.releasing }) {
