grpc-swift icon indicating copy to clipboard operation
grpc-swift copied to clipboard

Automate Podspec deployment with Github action

Open SebastianThiebaud opened this issue 5 years ago • 11 comments

Is your feature request related to a problem? Please describe it.

Everytime a new release is created, it can take hours before the associated podspec is published to Cocoapods.

Describe the solution you'd like

Instead of manually pushing the podspec to Cocoapods, a Github action could take care of running any required scripts, stamp / bump the version of the podspec to match the new release tag and publish the new podspec to Cocoapods once a new release is created/published.

SebastianThiebaud avatar Jun 08 '20 21:06 SebastianThiebaud

I really like this idea! I’ve been trying to work through how to do this as well, but haven’t thought of an elegant solution. (Also at my work project) I’d love some help on this one! 🙂

The biggest challenge for this is that the Pods (CGRPCZlib and gRPC-Swift) have to be pushed in a specific order for them to pass validation. The time required for CGRPCZlib to become available after pushing to trunk can vary from seconds to minutes. This requires the script to sometimes be ran multiple times manually.

It could be retried with some sort of delay, but there’s no guarantee that it’s available that second run (could even be a build issue or actual validation failure)

Jake-Prickett avatar Jun 08 '20 23:06 Jake-Prickett

I can definitely help on this one as I've implemented a similar solution at my work. The only difference is that the Github action I wrote is pushing to a private specs repository rather than the main Cocoapods trunk. There are plenty of actions available already doing the job of pushing the podspec to Cocoapods, we can see if using them works for grpc-swift.

Concerning CGRPCZlib, it seems like we would have to implement a similar action on that repository. But then, we might run into an issue when a grpc-swift release is created before the new CGRPCZlib podspec is published and available. @Jake-Prickett Do you know why the podspec in not immediately available? I've never seen this happening for my own projects.

And if the push of the grpc-swift fails because the CGRPCZlib dependency is not available, we would get alerted by email and we could retry manually, but still not ideal.

SebastianThiebaud avatar Jun 09 '20 00:06 SebastianThiebaud

Both the CGRPCZlib and gRPC-Swift are part of this repo and are pushed sequentially to Trunk. Trunk defaults to use the CDN instead of the Git repository, which takes some time to reflect updates to Podspecs. (Up to 10 minutes)

The issue is properly described here: https://github.com/CocoaPods/CocoaPods/issues/9497

But it looks like a fix was merged in last month!! 🎉 https://github.com/CocoaPods/cocoapods-trunk/pull/147 We could add —synchronous to build_podspec.py when we push to Trunk to resolve that issue.

Now this problem just got much easier! 😂

Jake-Prickett avatar Jun 09 '20 00:06 Jake-Prickett

Amazing! Okay, I'll push a pull request either tonight.

SebastianThiebaud avatar Jun 09 '20 00:06 SebastianThiebaud

@Jake-Prickett The only thing I forgot to mention is that the .podspec files in the repositories won't have the latest version number committed in master. We can discuss about that in the pull request once I submit.

SebastianThiebaud avatar Jun 09 '20 01:06 SebastianThiebaud

Nice! @glbrntt @MrMage - what’re your thoughts?

Jake-Prickett avatar Jun 09 '20 01:06 Jake-Prickett

Now that I'm thinking, we could just not host the podspec files, generate them during the Github action, push them to Cocoapods and that's it. I don't think Cocoapods requires to host the files in the repository, right?

SebastianThiebaud avatar Jun 09 '20 02:06 SebastianThiebaud

I'm hugely on board with this issue!

I don't think Cocoapods requires to host the files in the repository, right?

I think you're right and I'm okay with not having them in the repo, I think @MrMage has an opinion on this though?

glbrntt avatar Jun 09 '20 07:06 glbrntt

Overall, I like the idea. A few points:

  • I would prefer to have the Podspec in the repo, because that makes it easier to review them/look them up manually (e.g. when I want to check what the current deps of the Pod are). GitHub Actions might be able to automatically commit the change, though.
  • This might require storing a CocoaPods session in the repo's secrets; how should we solve that?

MrMage avatar Jun 09 '20 08:06 MrMage

PS: Can we get the alpha 13 released to Cocoapods? :)

SebastianThiebaud avatar Jun 09 '20 18:06 SebastianThiebaud

@MrMage Here is what I think could work to get the CocoaPods session token:

  • Create a new Gmail account (for example [email protected])
  • Enable Gmail API on this account
  • I will write a Github action that:
    • Register a new session pod trunk register [email protected] "gRPC Swift"
    • Fetch Gmail API:
      • Github secret GMAIL_CREDENTIALS will be needed (this is the json data downloadable once the API is enabled)
      • App will auth with the Gmail API to get a token
      • App will fetch the last email from [email protected] or retry every X seconds until the email is received
      • App will parse the email body and create a request with the embedded Cocoapods link to confirm the new session
  • Then, we can proceed to build the podspecs and push them

SebastianThiebaud avatar Jun 10 '20 00:06 SebastianThiebaud