Procházet zdrojové kódy

Add publish option to release tooling (#6792)

Paul Beusterien před 5 roky
rodič
revize
eb815c632b

+ 27 - 5
ReleaseTooling/Sources/FirebaseReleaser/Push.swift

@@ -19,18 +19,40 @@ import Foundation
 import FirebaseManifest
 import Utils
 
+private enum Destination {
+  case cpdc, trunk
+}
+
 enum Push {
   static func pushPodsToCPDC(gitRoot: URL) {
+    push(to: .cpdc, gitRoot: gitRoot)
+  }
+
+  static func publishPodsToTrunk(gitRoot: URL) {
+    push(to: .trunk, gitRoot: gitRoot)
+  }
+
+  private static func push(to destination: Destination, gitRoot: URL) {
     let cpdcLocation = findCpdc(gitRoot: gitRoot)
     let manifest = FirebaseManifest.shared
 
     for pod in manifest.pods.filter({ $0.releasing }) {
-      let warningsOK = pod.allowWarnings ? " --allow-warnings" : ""
+      let warningsOK = pod.allowWarnings ? "--allow-warnings" : ""
+
+      let command: String = {
+        switch destination {
+        case .cpdc:
+          return "pod repo push --skip-tests --use-json \(warningsOK) \(cpdcLocation) " +
+            pod.skipImportValidation() + " \(pod.podspecName()) " +
+            "--sources=sso://cpdc-internal/firebase.git,https://cdn.cocoapods.org"
 
-      Shell.executeCommand("pod repo push --skip-tests --use-json \(warningsOK) \(cpdcLocation) " +
-        pod.skipImportValidation() + " \(pod.podspecName()) " +
-        "--sources=sso://cpdc-internal/firebase.git,https://cdn.cocoapods.org",
-        workingDir: gitRoot)
+        case .trunk:
+          return "pod trunk push --skip-tests --synchronous \(warningsOK) " +
+            pod.skipImportValidation() + " ~/.cocoapods/repos/\(cpdcLocation)/Specs/\(pod.name)/" +
+            "\(manifest.versionString(pod))/\(pod.name).podspec.json"
+        }
+      }()
+      Shell.executeCommand(command, workingDir: gitRoot)
     }
   }
 

+ 10 - 3
ReleaseTooling/Sources/FirebaseReleaser/main.swift

@@ -38,7 +38,12 @@ struct FirebaseReleaser: ParsableCommand {
           help: "Initialize the release branch")
   var initBranch: Bool
 
-  /// Set this option to update podspecs only.
+  /// Set this option to output the commands to generate the ordered `pod trunk push` commands.
+  @Option(default: false,
+          help: "Publish the podspecs to the CocoaPodsTrunk")
+  var publish: Bool
+
+  /// Set this option to only update the podspecs on cpdc.
   @Option(default: false,
           help: "Update the podspecs only")
   var pushOnly: Bool
@@ -68,10 +73,12 @@ struct FirebaseReleaser: ParsableCommand {
                            workingDir: gitRoot)
       Tags.createTags(gitRoot: gitRoot)
       Push.pushPodsToCPDC(gitRoot: gitRoot)
-    } else if pushOnly {
-      Push.pushPodsToCPDC(gitRoot: gitRoot)
     } else if updateTagsOnly {
       Tags.updateTags(gitRoot: gitRoot)
+    } else if pushOnly {
+      Push.pushPodsToCPDC(gitRoot: gitRoot)
+    } else if publish {
+      Push.publishPodsToTrunk(gitRoot: gitRoot)
     }
   }
 

+ 1 - 1
scripts/build_zip.sh

@@ -25,7 +25,7 @@ fi
 # output directory.
 OUTPUT_DIR="$REPO/$1"
 
-cd ReleaseToolings
+cd ReleaseTooling
 swift run zip-builder -keepBuildArtifacts true -updatePodRepo true \
   -templateDir "${REPO}"/ReleaseTooling/Template -localPodspecPath "${REPO}" \
   -outputDir "${OUTPUT_DIR}" -customSpecRepos https://github.com/firebase/SpecsStaging.git