From ef6f53e93f487d3c6f63b631ddeebd7e89b88e2f Mon Sep 17 00:00:00 2001 From: Tony Li Date: Wed, 29 Nov 2023 10:28:52 +1300 Subject: [PATCH 1/8] Add a hack to patch cocoapods This hack unblocks us from releasing libraries from CI. Hopefully CocoaPods can fix the issue properly and we can remove this hack soon. --- bin/patch-cocoapods | 47 ++++++++++++++++++++++++++++++++++++++++++++ bin/validate_podspec | 4 ++++ 2 files changed, 51 insertions(+) create mode 100755 bin/patch-cocoapods diff --git a/bin/patch-cocoapods b/bin/patch-cocoapods new file mode 100755 index 00000000..7445260a --- /dev/null +++ b/bin/patch-cocoapods @@ -0,0 +1,47 @@ +#!/bin/bash + +# This is a hack to workaround https://github.com/CocoaPods/CocoaPods/issues/12033. +# We can remove this script once the issue is fixed. +# +# This script updates the cocoapods source code to change Xcode project targets' +# minimal deployment target to 13.0, which is a requirement in newer Xcode versions. + +set -euo pipefail + +patch_content=$(cat <<'EOF' +--- lib/cocoapods/installer/analyzer.rb ++++ lib/cocoapods/installer/analyzer.rb +@@ -857,7 +857,7 @@ + Version.new(library_spec.deployment_target(platform_name) || default) + end.max + if platform_name == :ios && build_type.framework? +- minimum = Version.new('8.0') ++ minimum = Version.new('13.0') + deployment_target = [deployment_target, minimum].max + end + Platform.new(platform_name, deployment_target) +--- lib/cocoapods/validator.rb ++++ lib/cocoapods/validator.rb +@@ -566,7 +566,7 @@ + def deployment_target + deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name) + if consumer.platform_name == :ios && use_frameworks +- minimum = Version.new('8.0') ++ minimum = Version.new('13.0') + deployment_target = [Version.new(deployment_target), minimum].max.to_s + end + deployment_target +EOF +) + +cocoapods_gem_path=$(bundle info cocoapods --path) +echo "Path to the cocoapods gem: $cocoapods_gem_path" + +if echo "$patch_content" | patch --forward --force --directory "$cocoapods_gem_path" --strip 0; then + echo "cocoapods patched successfully" + exit 0 +fi + +echo "Failed to patch cocoapods. Try to re-apply the patch" +echo "$patch_content" | patch --reverse --force --directory "$cocoapods_gem_path" --strip 0 +echo "$patch_content" | patch --forward --force --directory "$cocoapods_gem_path" --strip 0; diff --git a/bin/validate_podspec b/bin/validate_podspec index 7c047413..36326071 100755 --- a/bin/validate_podspec +++ b/bin/validate_podspec @@ -3,6 +3,10 @@ echo "--- :rubygems: Setting up Gems" install_gems +echo "--- :writing_hand: Patching cocoapods" +echo "⚠️ Remove this step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033" +patch-cocoapods + if [ -f "Podfile.lock" ]; then echo "--- :cocoapods: Setting up Pods" install_cocoapods From f4d772e971c1355b60e0101677381ec613b7ee6c Mon Sep 17 00:00:00 2001 From: Tony Li Date: Wed, 29 Nov 2023 10:38:12 +1300 Subject: [PATCH 2/8] Update the version in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index db6679bf..0de370ad 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,11 @@ steps: restore_cache $(hash_file package-lock.json) plugins: - - automattic/a8c-ci-toolkit#2.18.2: + - automattic/a8c-ci-toolkit#3.0.0: bucket: a8c-ci-cache # optional ``` -Don't forget to verify what [the latest release](https://github.com/Automattic/a8c-ci-toolkit-buildkite-plugin/releases/latest) is and use that value instead of `2.18.2`. +Don't forget to verify what [the latest release](https://github.com/Automattic/a8c-ci-toolkit-buildkite-plugin/releases/latest) is and use that value instead of `3.0.0`. ## Configuration From ad06d86304852d70d29263c2ef041db7667be79c Mon Sep 17 00:00:00 2001 From: Tony Li Date: Wed, 29 Nov 2023 11:46:05 +1300 Subject: [PATCH 3/8] Call patch-cocoapods in the publish_pod utility --- bin/publish_pod | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/publish_pod b/bin/publish_pod index 56ea304a..8a911067 100755 --- a/bin/publish_pod +++ b/bin/publish_pod @@ -10,6 +10,9 @@ if [ -n "$BUILDKITE_TAG" ] && [ "$BUILDKITE_TAG" != "$POD_VERSION" ]; then exit 1 fi +echo "⚠️ Remove the patch-cocoapods step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033" +patch-cocoapods + # For some reason this fixes a failure in `lib lint` # https://github.com/Automattic/buildkite-ci/issues/7 xcrun simctl list >> /dev/null From 5f4139e09fe7e393978f79029ffe918261b31222 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Wed, 29 Nov 2023 11:51:18 +1300 Subject: [PATCH 4/8] Add a changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab8a040c..6599d3e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,7 +46,7 @@ _None._ ### Internal Changes -_None._ +- Fix an issue where `validate_podspec` and `publish_pod` fail on Xcode 15.0.1 if the pod has a dependency which targets iOS version older than 13. [#78] ## 3.0.0 From 36ec4217eadc620c4f5976fe7d9b69d60b524969 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Wed, 29 Nov 2023 15:39:47 +1300 Subject: [PATCH 5/8] Add a patch-cocoapods option to validate_podspec and publish_pod --- bin/publish_pod | 17 +++++++++++++++-- bin/validate_podspec | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/bin/publish_pod b/bin/publish_pod index 8a911067..49267180 100755 --- a/bin/publish_pod +++ b/bin/publish_pod @@ -1,5 +1,15 @@ #!/bin/bash -eu +PATCH_COCOAPODS="false" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --patch-cocoapods) PATCH_COCOAPODS="true" ;; + *) break ;; + esac + shift +done + PODSPEC_PATH=$1 # POD_NAME=$(bundle exec pod ipc spec "$PODSPEC_PATH" | jq -r '.name') @@ -10,8 +20,11 @@ if [ -n "$BUILDKITE_TAG" ] && [ "$BUILDKITE_TAG" != "$POD_VERSION" ]; then exit 1 fi -echo "⚠️ Remove the patch-cocoapods step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033" -patch-cocoapods + +if [[ "${PATCH_COCOAPODS}" == 'true' ]]; then + echo "⚠️ Remove this step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033" + patch-cocoapods +fi # For some reason this fixes a failure in `lib lint` # https://github.com/Automattic/buildkite-ci/issues/7 diff --git a/bin/validate_podspec b/bin/validate_podspec index 36326071..0d4ee848 100755 --- a/bin/validate_podspec +++ b/bin/validate_podspec @@ -1,11 +1,23 @@ #!/bin/bash -eu +PATCH_COCOAPODS="false" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --patch-cocoapods) PATCH_COCOAPODS="true" ;; + *) break ;; + esac + shift +done + echo "--- :rubygems: Setting up Gems" install_gems -echo "--- :writing_hand: Patching cocoapods" -echo "⚠️ Remove this step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033" -patch-cocoapods +if [[ "${PATCH_COCOAPODS}" == 'true' ]]; then + echo "--- :writing_hand: Patching cocoapods" + echo "⚠️ Remove this step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033" + patch-cocoapods +fi if [ -f "Podfile.lock" ]; then echo "--- :cocoapods: Setting up Pods" From db3eef4e2cc7baafaef5009b76086b8a89d77ab9 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Wed, 29 Nov 2023 15:42:51 +1300 Subject: [PATCH 6/8] Add patch-cocoapods option to publish_private_pod --- bin/publish_pod | 1 - bin/publish_private_pod | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/publish_pod b/bin/publish_pod index 49267180..e553ad55 100755 --- a/bin/publish_pod +++ b/bin/publish_pod @@ -20,7 +20,6 @@ if [ -n "$BUILDKITE_TAG" ] && [ "$BUILDKITE_TAG" != "$POD_VERSION" ]; then exit 1 fi - if [[ "${PATCH_COCOAPODS}" == 'true' ]]; then echo "⚠️ Remove this step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033" patch-cocoapods diff --git a/bin/publish_private_pod b/bin/publish_private_pod index ce25d9e6..ce98bf68 100755 --- a/bin/publish_private_pod +++ b/bin/publish_private_pod @@ -1,5 +1,15 @@ #!/bin/bash -eu +PATCH_COCOAPODS="false" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --patch-cocoapods) PATCH_COCOAPODS="true" ;; + *) break ;; + esac + shift +done + PODSPEC_PATH=$1 PRIVATE_SPECS_REPO=$2 DEPLOY_KEY=$3 @@ -15,6 +25,11 @@ ssh-add -l # Add the host of the spec repo (typically github.com) to the known_hosts to be sure we can clone it via ssh add_host_to_ssh_known_hosts "$PRIVATE_SPECS_REPO" +if [[ "${PATCH_COCOAPODS}" == 'true' ]]; then + echo "⚠️ Remove this step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033" + patch-cocoapods +fi + # For some reason this fixes a failure in `lib lint` # https://github.com/Automattic/buildkite-ci/issues/7 xcrun simctl list >> /dev/null From 6e154745852805ebe39703de4dbd69b0d4f0dc8f Mon Sep 17 00:00:00 2001 From: Tony Li Date: Thu, 30 Nov 2023 10:14:13 +1300 Subject: [PATCH 7/8] Remove an unnecessary semicolon --- bin/patch-cocoapods | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/patch-cocoapods b/bin/patch-cocoapods index 7445260a..4eed7846 100755 --- a/bin/patch-cocoapods +++ b/bin/patch-cocoapods @@ -44,4 +44,4 @@ fi echo "Failed to patch cocoapods. Try to re-apply the patch" echo "$patch_content" | patch --reverse --force --directory "$cocoapods_gem_path" --strip 0 -echo "$patch_content" | patch --forward --force --directory "$cocoapods_gem_path" --strip 0; +echo "$patch_content" | patch --forward --force --directory "$cocoapods_gem_path" --strip 0 From bb2a121402f0dd8672bde7b1614895f614fc5e9d Mon Sep 17 00:00:00 2001 From: Tony Li Date: Thu, 30 Nov 2023 10:17:13 +1300 Subject: [PATCH 8/8] Release 3.0.1 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6599d3e0..0436bd5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,12 @@ _None._ ### Internal Changes +_None._ + +## 3.0.1 + +### Internal Changes + - Fix an issue where `validate_podspec` and `publish_pod` fail on Xcode 15.0.1 if the pod has a dependency which targets iOS version older than 13. [#78] ## 3.0.0