Skip to content

Commit cd31697

Browse files
authored
Move zip-builder to ArgumentParser. (#6920)
* Move zip-builder to ArgumentParser. This provides more consistency with the other tooling, and lays groundwork to make further changes to arguments passed in. * Update zip build workflow, enable temporarily. * Fix typo in build script. * Removed RC option + other review feedback * Style * Fix Carthage naming. * Revert V2 plan doc, add V3 plan * Remove trailing space. * Update some missed parts, fix zip builds. * Removed old references in README. * Fixed trailing whitespace. * Revert GHA cron run. * Review
1 parent d174b2f commit cd31697

13 files changed

+582
-537
lines changed

ReleaseTooling/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let package = Package(
2626
.executable(name: "zip-builder", targets: ["ZipBuilder"]),
2727
],
2828
dependencies: [
29-
.package(url: "https://github.com/apple/swift-argument-parser", .exact("0.0.1")),
29+
.package(url: "https://github.com/apple/swift-argument-parser", .exact("0.1.0")),
3030
],
3131
targets: [
3232
.target(

ReleaseTooling/README.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,22 @@ for that version. Check with `xcodebuild -version`.
3030

3131
### Launch Arguments
3232

33-
See `main.swift` and the `LaunchArgs` struct for information on specific launch arguments.
33+
See `main.swift` for information on specific launch arguments, or use `swift run zip-builder --help`.
3434

35-
You can pass in launch arguments with Xcode by clicking "zip-builder" beside the Run/Stop buttons, clicking "Edit
36-
Scheme" and adding them in the "Arguments Passed On Launch" section.
35+
You can pass in launch arguments with Xcode by clicking "zip-builder" beside the Run/Stop buttons, clicking
36+
"Edit Scheme" and adding them in the "Arguments Passed On Launch" section.
3737

3838
#### Common Arguments
3939

4040
These arguments assume you're running the command from the `ReleaseTooling` directory.
4141

4242
**Required** arguments:
43-
- `-templateDir $(pwd)/Template`
44-
- This should always be the same.
43+
44+
- `--repo-dir <PATH_TO_firebase_ios_sdk_REPO>`
45+
- The root of the `firebase-ios-sdk` repo.
4546

4647
Typical argument (all use cases except Firebase release build):
47-
- `-zipPods <PATH_TO.json>`
48+
- `--zip-pods <PATH_TO.json>`
4849
- This is a JSON list of the pods to consolidate into a zip of binary frameworks. For example,
4950

5051
```
@@ -65,32 +66,32 @@ valid [CocoaPods Podfile version specifier](https://guides.cocoapods.org/syntax/
6566

6667

6768
Optional common arguments:
68-
- `-updatePodRepo false`
69+
- `--no-update-pod-repo`
6970
- This is for speedups when `pod repo update` has already been run recently.
7071

7172
For release engineers (Googlers packaging an upcoming Firebase release) these commands should also be used:
72-
- `-customSpecRepos sso://cpdc-internal/firebase`
73+
- `--custom-spec-repos sso://cpdc-internal/firebase`
7374
- This pulls the latest podspecs from the CocoaPods staging area.
74-
- `-repoDir path` GitHub repo containing Template and Carthage json file inputs.
75-
- `-carthageBuild true` Turns on generation of Carthage zips and json file updates.
76-
- `-keepBuildArtifacts true` Useful for debugging and verifying the zip build contents.
75+
- `--repo-dir path` GitHub repo containing Template and Carthage json file inputs.
76+
- `--enable-carthage-build` Turns on generation of Carthage zips and json file updates.
77+
- `--keep-build-artifacts` Useful for debugging and verifying the zip build contents.
7778

7879
Putting them all together, here's a common command to build a releaseable Zip file:
7980

8081
```
81-
swift run zip-builder -updatePodRepo true \
82-
-repoDir <PATH_TO_current.firebase_ios_sdk.repo> \
83-
-customSpecRepos sso://cpdc-internal/firebase
84-
-carthageBuild true
85-
-keepBuildArtifacts true
82+
swift run zip-builder --update-pod-repo \
83+
--repo-dir <PATH_TO_current.firebase_ios_sdk.repo> \
84+
--custom-spec-repos sso://cpdc-internal/firebase \
85+
--enable-carthage-build \
86+
--keep-build-artifacts
8687
```
8788

8889
### Carthage
8990

90-
Carthage binaries can also be built at the same time as the zip file by passing in `-carthageBuild
91-
true` as a command line argument. This directory should contain JSON files describing versions
92-
and download locations for each product. This will result in a folder called "carthage" at the root where the zip
93-
directory exists containing all the zip files and JSON files necessary for distribution.
91+
Carthage binaries can also be built at the same time as the zip file by passing in `--enable-carthage-build`
92+
as a command line argument. This directory should contain JSON files describing versions and download
93+
locations for each product. This will result in a folder called "carthage" at the root where the zip directory exists
94+
containing all the zip files and JSON files necessary for distribution.
9495

9596
## Firebase Releaser
9697

@@ -99,11 +100,11 @@ for the process documentation.
99100

100101
### Launch Arguments
101102

102-
See `main.swift` and the `LaunchArgs` struct for information on specific launch arguments.
103+
See `main.swift` for information on specific launch arguments.
103104

104105
You can pass in launch arguments with Xcode by selecting the "firebase-releaser" scheme
105-
beside the Run/Stop buttons, clicking "Edit
106-
Scheme" and adding them in the "Arguments Passed On Launch" section.
106+
beside the Run/Stop buttons, clicking "Edit Scheme" and adding them in the "Arguments Passed On Launch"
107+
section.
107108

108109
## Development Philosophy
109110

ReleaseTooling/Sources/ZipBuilder/CarthageUtils.swift

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ import CommonCrypto
1818
import Foundation
1919
import Utils
2020

21+
struct CarthageBuildOptions {
22+
/// Location of directory containing all JSON Carthage manifests.
23+
let jsonDir: URL
24+
25+
/// Version checking flag.
26+
let isVersionCheckEnabled: Bool
27+
}
28+
2129
/// Carthage related utility functions. The enum type is used as a namespace here instead of having
2230
/// root functions, and no cases should be added to it.
2331
enum CarthageUtils {}
@@ -29,12 +37,11 @@ extension CarthageUtils {
2937
/// - templateDir: The template project directory, contains the dummy Firebase library.
3038
/// - carthageJSONDir: Location of directory containing all JSON Carthage manifests.
3139
/// - artifacts: Release Artifacts from build.
32-
/// - rcNumber: The RC number.
40+
/// - options: Carthage specific options for the build.
3341
/// - Returns: The path to the root of the Carthage installation.
3442
static func packageCarthageRelease(templateDir: URL,
35-
carthageJSONDir: URL,
3643
artifacts: ZipBuilder.ReleaseArtifacts,
37-
rcNumber: Int?) -> URL? {
44+
options: CarthageBuildOptions) -> URL? {
3845
guard let zipLocation = artifacts.carthageDir else { return nil }
3946

4047
do {
@@ -49,18 +56,14 @@ extension CarthageUtils {
4956
// Package the Carthage distribution with the current directory structure.
5057
let carthageDir = zipLocation.deletingLastPathComponent().appendingPathComponent("carthage")
5158
fileManager.removeIfExists(at: carthageDir)
52-
var output = carthageDir.appendingPathComponent(artifacts.firebaseVersion)
53-
if let rcNumber = args.rcNumber {
54-
output.appendPathComponent("rc\(rcNumber)")
55-
} else {
56-
output.appendPathComponent("latest-non-rc")
57-
}
59+
let output = carthageDir.appendingPathComponents([artifacts.firebaseVersion, "latest"])
5860
try fileManager.createDirectory(at: output, withIntermediateDirectories: true)
5961
generateCarthageRelease(fromPackagedDir: carthagePath,
6062
templateDir: templateDir,
61-
jsonDir: carthageJSONDir,
63+
jsonDir: options.jsonDir,
6264
artifacts: artifacts,
63-
outputDir: output)
65+
outputDir: output,
66+
versionCheckEnabled: options.isVersionCheckEnabled)
6467

6568
// Remove the duplicated Carthage build directory.
6669
fileManager.removeIfExists(at: carthagePath)
@@ -87,7 +90,8 @@ extension CarthageUtils {
8790
templateDir: URL,
8891
jsonDir: URL,
8992
artifacts: ZipBuilder.ReleaseArtifacts,
90-
outputDir: URL) {
93+
outputDir: URL,
94+
versionCheckEnabled: Bool) {
9195
factorProtobuf(inPackagedDir: packagedDir)
9296
let directories: [String]
9397
do {
@@ -104,7 +108,8 @@ extension CarthageUtils {
104108

105109
// Parse the JSON file, ensure that we're not trying to overwrite a release.
106110
var jsonManifest = parseJSONFile(fromDir: jsonDir, product: product)
107-
if !args.carthageSkipVersionCheck {
111+
112+
if versionCheckEnabled {
108113
guard jsonManifest[firebaseVersion] == nil else {
109114
print("Carthage release for \(product) \(firebaseVersion) already exists - skipping.")
110115
continue

0 commit comments

Comments
 (0)