Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed Oct 15, 2020
1 parent 3dde28b commit 071175d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 45 deletions.
40 changes: 0 additions & 40 deletions ZipBuilder/Sources/FirebaseManifest/FirebaseManifest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,3 @@ public struct Manifest {
public let version: String
public let pods: [Pod]
}

/// Struct describing Firebase pods to release.
public struct Pod {
public let name: String
public let isClosedSource: Bool
public let isBeta: Bool
public let isFirebase: Bool
public let allowWarnings: Bool // Allow validation warnings. Ideally these should all be false
public let podVersion: String? // Non-Firebase pods have their own version
public let releasing: Bool // Non-Firebase pods may not release

init(_ name: String,
isClosedSource: Bool = false,
isBeta: Bool = false,
isFirebase: Bool = true,
allowWarnings: Bool = false,
podVersion: String? = nil,
releasing: Bool = true) {
self.name = name
self.isClosedSource = isClosedSource
self.isBeta = isBeta
self.isFirebase = isFirebase
self.allowWarnings = allowWarnings
self.podVersion = podVersion
self.releasing = releasing
}

public func podspecName() -> String {
return isClosedSource ? "\(name).podspec.json" : "\(name).podspec"
}

/// Closed source pods do not validate on Xcode 12 until they support the ARM simulator slice.
public func skipImportValidation() -> String {
if isClosedSource || name == "Firebase" {
return "-skip-import-validation"
} else {
return ""
}
}
}
57 changes: 57 additions & 0 deletions ZipBuilder/Sources/FirebaseManifest/Pod.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import Foundation

/// Struct describing Firebase pods to release.
public struct Pod {
public let name: String
public let isClosedSource: Bool
public let isBeta: Bool
public let isFirebase: Bool
public let allowWarnings: Bool // Allow validation warnings. Ideally these should all be false
public let podVersion: String? // Non-Firebase pods have their own version
public let releasing: Bool // Non-Firebase pods may not release

init(_ name: String,
isClosedSource: Bool = false,
isBeta: Bool = false,
isFirebase: Bool = true,
allowWarnings: Bool = false,
podVersion: String? = nil,
releasing: Bool = true) {
self.name = name
self.isClosedSource = isClosedSource
self.isBeta = isBeta
self.isFirebase = isFirebase
self.allowWarnings = allowWarnings
self.podVersion = podVersion
self.releasing = releasing
}

public func podspecName() -> String {
return isClosedSource ? "\(name).podspec.json" : "\(name).podspec"
}

/// Closed source pods do not validate on Xcode 12 until they support the ARM simulator slice.
public func skipImportValidation() -> String {
if isClosedSource || name == "Firebase" {
return "-skip-import-validation"
} else {
return ""
}
}
}
8 changes: 8 additions & 0 deletions ZipBuilder/Sources/FirebaseReleaser/InitializeRelease.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ struct InitializeRelease {
} else {
let version = pod.podVersion ??
(pod.isBeta ? manifest.version + "-beta" : manifest.version)

// Patch the new version to the podspec's version attribute.
Shell.executeCommand("sed -i.bak -e \"s/\\(\\.version.*=[[:space:]]*'\\).*'/\\1" +
"\(version)'/\" \(pod.name).podspec", workingDir: path)
}
}
}
}

// This function patches the versions in the Firebase.podspec. It uses Swift instead of sed
// like the other version patching.
// TODO: Choose one or the other mechanism.
// TODO: If we keep Swift, consider using Scanner.
private static func updateFirebasePodspec(path: URL, manifest: FirebaseManifest.Manifest) {
let podspecFile = path.appendingPathComponent("Firebase.podspec")
var contents = ""
Expand All @@ -72,6 +78,8 @@ struct InitializeRelease {
let pod = firebasePod.name
let version = firebasePod.isBeta ? firebaseVersion + "-beta" : firebaseVersion
if pod == "Firebase" {
// TODO: This then block is redundant with the updatePodspecs function above and is left
// until we decide to go with Swift or sed.
// Replace version in string like s.version = '6.9.0'
guard let range = contents.range(of: "s.version") else {
fatalError("Could not find version of Firebase pod in podspec at \(podspecFile)")
Expand Down
4 changes: 2 additions & 2 deletions ZipBuilder/Sources/FirebaseReleaser/Push.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import Foundation
import FirebaseManifest
import Utils

struct Push {
static func cpdc(gitRoot: URL) {
enum Push {
static func pushPodsToCPDC(gitRoot: URL) {
let cpdcLocation = findCpdc(gitRoot: gitRoot)
let manifest = FirebaseManifest.shared

Expand Down
2 changes: 1 addition & 1 deletion ZipBuilder/Sources/FirebaseReleaser/Tags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Foundation
import FirebaseManifest
import Utils

struct Tags {
enum Tags {
static func create(gitRoot: URL) {
let manifest = FirebaseManifest.shared
createTag(gitRoot: gitRoot, tag: "CocoaPods-\(manifest.version)")
Expand Down
4 changes: 2 additions & 2 deletions ZipBuilder/Sources/FirebaseReleaser/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ struct FirebaseReleaser: ParsableCommand {
Shell.executeCommand("git branch --set-upstream-to=origin/\(branch) \(branch)",
workingDir: gitRoot)
Tags.create(gitRoot: gitRoot)
Push.cpdc(gitRoot: gitRoot)
Push.pushPodsToCPDC(gitRoot: gitRoot)
} else if pushOnly {
Push.cpdc(gitRoot: gitRoot)
Push.pushPodsToCPDC(gitRoot: gitRoot)
}
}

Expand Down

0 comments on commit 071175d

Please sign in to comment.