From 69661a2fc13c7ae372e02fe48a3ae7b072079c9d Mon Sep 17 00:00:00 2001 From: Michael Rebello Date: Tue, 15 Oct 2024 07:32:11 -0700 Subject: [PATCH] Automate publishing podspecs to CocoaPods (#313) Resolves https://github.com/connectrpc/connect-swift/issues/311 by adding a job which runs when new release tags are created and automatically publishes new releases to CocoaPods. I also updated the documentation to reflect the new release process. A sample run can be seen here (against this PR, not a release tag): https://github.com/connectrpc/connect-swift/actions/runs/11345378532/job/31552734926?pr=313 --------- Signed-off-by: Michael Rebello --- .github/CONTRIBUTING.md | 21 +++++---------------- .github/workflows/release.yml | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 06a21e34..27d18c4e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -173,23 +173,12 @@ To update dependencies such as `SwiftProtobuf` in this repository: Releases should be tagged in `x.y.z` SemVer format. -1. Create a new GitHub release. -2. Update both [`Connect-Swift.podspec`](../Connect-Swift.podspec) and +1. Update both [`Connect-Swift.podspec`](../Connect-Swift.podspec) and [`Connect-Swift-Mocks.podspec`](../Connect-Swift-Mocks.podspec) to reflect - the newly tagged version. -3. Run `cd Examples/ElizaCocoaPodsApp && pod update` to update the example CocoaPods app. -4. Submit a PR with these changes. -5. Push both specs to CocoaPods: - -```sh -pod trunk push Connect-Swift.podspec -pod repo update -pod trunk push Connect-Swift-Mocks.podspec -``` - -Note: If pushing the mocks podspec fails because CocoaPods cannot find the new -`Connect-Swift` podspec in the specs repo, you may have to wait ~30 min -for it to populate before trying again. + the upcoming version on `main`. In the same PR, update the example CocoaPods + app by running `cd Examples/ElizaCocoaPodsApp && pod install`. +2. Create a new GitHub release/tag after merging these changes. +3. CI will automatically push the updated specs to CocoaPods in its [release job](./workflows/release.yml). [dco]: https://developercertificate.org [commit-message]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca584a8b..89a41598 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,3 +36,17 @@ jobs: append_body: true files: | ./.tmp/bin/artifacts/* + publish-podspecs: + runs-on: macos-14 + steps: + - uses: actions/checkout@v4 + - name: Select Xcode version + # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.app + - name: Publish podspecs to CocoaPods + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + # Note that --synchronous is used since Mocks depends on the primary spec. + run: | + pod trunk push Connect-Swift.podspec --allow-warnings --synchronous + pod trunk push Connect-Swift-Mocks.podspec --allow-warnings --synchronous