Update pod push script to handle multiple edge cases (#2511)
Summary: This PR adds a script to publish pods. It handles different edge cases like: - The version was already pushed but still you are trying to push it, it will skip in that case and give a proper message. - This also makes sure that the same version Flipper pod exists before pushing FlipperKit. - It also has the retry mechanism in place if at all the pod trunk push fails to push. ## Changelog Updated the workflow to push pods Pull Request resolved: https://github.com/facebook/flipper/pull/2511 Test Plan: While pushing already published release: https://github.com/facebook/flipper/actions/runs/974346766 While pushing new release: https://github.com/facebook/flipper/actions/runs/978707041 Reviewed By: passy Differential Revision: D29415078 Pulled By: priteshrnandgaonkar fbshipit-source-id: f0fb68a2e399802e5719d7be4216d4a5ed6ef782
This commit is contained in:
committed by
Facebook GitHub Bot
parent
10c6a25aad
commit
8ef5a62010
6
.github/workflows/publish-pods.yml
vendored
6
.github/workflows/publish-pods.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
run: ./scripts/update-pod-versions.sh ./ ./Flipper.podspec
|
run: ./scripts/update-pod-versions.sh ./ ./Flipper.podspec
|
||||||
|
|
||||||
- name: Push Flipper
|
- name: Push Flipper
|
||||||
run: pod trunk push Flipper.podspec --use-libraries --allow-warnings --verbose --skip-import-validation
|
run: ./scripts/publish-flipper-pods.sh ./ Flipper
|
||||||
env:
|
env:
|
||||||
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
|
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
|
||||||
|
|
||||||
@@ -41,9 +41,7 @@ jobs:
|
|||||||
run: ./scripts/update-pod-versions.sh ./ ./FlipperKit.podspec
|
run: ./scripts/update-pod-versions.sh ./ ./FlipperKit.podspec
|
||||||
|
|
||||||
- name: Push FlipperKit
|
- name: Push FlipperKit
|
||||||
run: |
|
run: ./scripts/publish-flipper-pods.sh ./ FlipperKit
|
||||||
# Retry publishing FlipperKit 20 times. Putting this hack unless we have cocoapods 1.10. More information related to the bug https://github.com/CocoaPods/CocoaPods/issues/9502#issuecomment-579486258
|
|
||||||
for i in {1..20}; do pod trunk push FlipperKit.podspec --use-libraries --allow-warnings --verbose --skip-import-validation --synchronous && break || sleep 30; done
|
|
||||||
env:
|
env:
|
||||||
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
|
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
|
||||||
|
|
||||||
|
|||||||
97
scripts/publish-flipper-pods.sh
Executable file
97
scripts/publish-flipper-pods.sh
Executable file
@@ -0,0 +1,97 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the MIT license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "Please pass the root directory of flipper repository as a first argument."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$2" ]
|
||||||
|
then
|
||||||
|
echo "Please pass the pod name to push, It just accepts 'Flipper' and 'FlipperKit', do not append podspec at the end"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$2" != "Flipper" ]] && [[ "$2" != "FlipperKit" ]]
|
||||||
|
then
|
||||||
|
echo "This script just supports Flipper and FlipperKit pods. Please send either Flipper or FlipperKit as an argument."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
FLIPPER_DIR=$1
|
||||||
|
POD_NAME=$2
|
||||||
|
POD_TO_PUSH="$FLIPPER_DIR/$POD_NAME.podspec"
|
||||||
|
|
||||||
|
if ! [[ -f "$POD_TO_PUSH" ]]; then
|
||||||
|
echo "$POD_TO_PUSH does not exist. Please check the pod name."
|
||||||
|
fi
|
||||||
|
|
||||||
|
POD_VERSION_TAG=$(< "$POD_TO_PUSH" grep "flipperkit_version =" )
|
||||||
|
POD_VERSION="${POD_VERSION_TAG##* }"
|
||||||
|
POD_VERSION=$(sed -e "s/^'//" -e "s/'$//" <<<"$POD_VERSION")
|
||||||
|
|
||||||
|
push_pods_and_retry () {
|
||||||
|
echo "Pushing $POD_VERSION of $POD_NAME..."
|
||||||
|
FLAGS="--use-libraries --allow-warnings --verbose --skip-import-validation"
|
||||||
|
if [[ "$POD_NAME" == "FlipperKit" ]]
|
||||||
|
then
|
||||||
|
FLAGS="$FLAGS --synchronous"
|
||||||
|
fi
|
||||||
|
POD_COMMAND="pod trunk push $POD_TO_PUSH $FLAGS"
|
||||||
|
MAX_ATTEMPT=4
|
||||||
|
ATTEMPT_NUM=0
|
||||||
|
TIME_TO_WAIT=1
|
||||||
|
until [ "$ATTEMPT_NUM" -ge "$MAX_ATTEMPT" ]
|
||||||
|
do
|
||||||
|
echo "Retry attempt $ATTEMPT_NUM..."
|
||||||
|
if [ "$ATTEMPT_NUM" -ge 1 ]
|
||||||
|
then
|
||||||
|
echo "Retry attempt $ATTEMPT_NUM..."
|
||||||
|
fi
|
||||||
|
$POD_COMMAND && break
|
||||||
|
echo "Failed to push. Will Retry in $TIME_TO_WAIT minute."
|
||||||
|
sleep $((60*TIME_TO_WAIT))
|
||||||
|
# Exponential back off.
|
||||||
|
TIME_TO_WAIT=$((2*TIME_TO_WAIT))
|
||||||
|
ATTEMPT_NUM=$((ATTEMPT_NUM+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$ATTEMPT_NUM" -ge "$MAX_ATTEMPT" ]
|
||||||
|
then
|
||||||
|
echo "Exhausted all retry attempts and failed to push, please try again later..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ENDPOINT_TO_CHECK="https://github.com/CocoaPods/Specs/blob/master/Specs/a/e/a/Flipper/$POD_VERSION"
|
||||||
|
if [[ "$POD_NAME" == "FlipperKit" ]]
|
||||||
|
then
|
||||||
|
STATUS_CODE=$(curl -LI "$ENDPOINT_TO_CHECK" -o /dev/null -w '%{http_code}\n' -s)
|
||||||
|
if ! [[ $STATUS_CODE == 200 ]]
|
||||||
|
then
|
||||||
|
echo "Please push $POD_VERSION of Flipper before pushing $POD_VERSION of FlipperKit."
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
ENDPOINT_TO_CHECK="https://github.com/CocoaPods/Specs/tree/master/Specs/3/2/5/FlipperKit/$POD_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Verifying if $POD_VERSION already pushed for $POD_NAME..."
|
||||||
|
echo "Curling $ENDPOINT_TO_CHECK"
|
||||||
|
STATUS_CODE=$(curl -LI "$ENDPOINT_TO_CHECK" -o /dev/null -w '%{http_code}\n' -s)
|
||||||
|
echo "$STATUS_CODE"
|
||||||
|
|
||||||
|
if [[ "$STATUS_CODE" -ge 400 ]]
|
||||||
|
then
|
||||||
|
push_pods_and_retry "$@"
|
||||||
|
else
|
||||||
|
echo "$POD_VERSION of $POD_NAME is already pushed."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Successfully published $POD_VERSION of $POD_NAME."
|
||||||
Reference in New Issue
Block a user