-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add update-tags release process #6739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,12 @@ import FirebaseManifest | |
import Utils | ||
|
||
enum Tags { | ||
static func create(gitRoot: URL) { | ||
static func createTags(gitRoot: URL, deleteExistingTags: Bool = false) { | ||
let manifest = FirebaseManifest.shared | ||
createTag(gitRoot: gitRoot, tag: "CocoaPods-\(manifest.version)") | ||
createTag(gitRoot: gitRoot, tag: "CocoaPods-\(manifest.version)-beta") | ||
createTag(gitRoot: gitRoot, tag: "CocoaPods-\(manifest.version)", | ||
deleteExistingTags: deleteExistingTags) | ||
createTag(gitRoot: gitRoot, tag: "CocoaPods-\(manifest.version)-beta", | ||
deleteExistingTags: deleteExistingTags) | ||
|
||
for pod in manifest.pods { | ||
if pod.isFirebase { | ||
|
@@ -36,12 +38,43 @@ enum Tags { | |
fatalError("Non-Firebase pod \(pod.name) is missing a version") | ||
} | ||
let tag = pod.name.replacingOccurrences(of: "Google", with: "") + "-" + version | ||
createTag(gitRoot: gitRoot, tag: tag) | ||
createTag(gitRoot: gitRoot, tag: tag, deleteExistingTags: deleteExistingTags) | ||
} | ||
} | ||
|
||
private static func createTag(gitRoot: URL, tag: String) { | ||
static func updateTags(gitRoot: URL) { | ||
createTags(gitRoot: gitRoot, deleteExistingTags: true) | ||
} | ||
|
||
private static func createTag(gitRoot: URL, tag: String, deleteExistingTags: Bool) { | ||
if deleteExistingTags { | ||
verifyTagsAreSafeToDelete() | ||
Shell.executeCommand("git tag --delete \(tag)", workingDir: gitRoot) | ||
Shell.executeCommand("git push --delete origin \(tag)", workingDir: gitRoot) | ||
} | ||
Shell.executeCommand("git tag \(tag)", workingDir: gitRoot) | ||
Shell.executeCommand("git push origin \(tag)", workingDir: gitRoot) | ||
} | ||
|
||
private static func verifyTagsAreSafeToDelete() { | ||
var homeDirURL: URL | ||
if #available(OSX 10.12, *) { | ||
homeDirURL = FileManager.default.homeDirectoryForCurrentUser | ||
} else { | ||
fatalError("Run on at least macOS 10.12") | ||
} | ||
let manifest = FirebaseManifest.shared | ||
let firebasePublicURL = homeDirURL.appendingPathComponents( | ||
[".cocoapods", "repos", "cocoapods", "Specs", "0", "3", "5", "Firebase"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I curious where the number components come from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the CocoaPods hash of the word Firebase. It's how CocoaPods does sharding. |
||
) | ||
|
||
guard FileManager.default.fileExists(atPath: firebasePublicURL.path) else { | ||
fatalError("You must have the CocoaPods Spec repo installed to retag versions.") | ||
} | ||
|
||
guard !FileManager.default.fileExists(atPath: | ||
firebasePublicURL.appendingPathComponent(manifest.version).path) else { | ||
fatalError("Do not remove tag of a published Firebase version.") | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be extra safe and run a
pod update
here first to be sure that the local repo is up to date? I imagine it's a very very edge case but maybe something worth doing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! See #6774