From a4422a768710bf0b0464013742ce7728afc76be9 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Fri, 10 Jul 2020 02:18:26 -0700 Subject: [PATCH] Update pod version after release (#1338) Summary: This diff updates the Github workflow to update pod versions after the release is published on Cocoapods. ## Changelog - Update Github workflow to update the pod versions till the release is published in Cocoapods. Pull Request resolved: https://github.com/facebook/flipper/pull/1338 Test Plan: A PR got created with the updated pod versions after the release was pushed. https://github.com/facebook/flipper/pull/1365 Reviewed By: passy Differential Revision: D22456857 Pulled By: priteshrnandgaonkar fbshipit-source-id: 335996bc1ebb6da309d3f60a8f3401559e0a83c7 --- .github/workflows/publish-pods.yml | 145 +++++++++++++++++------------ scripts/prepare-release.sh | 31 ------ scripts/update-pod-versions.sh | 46 +++++++++ 3 files changed, 132 insertions(+), 90 deletions(-) create mode 100755 scripts/update-pod-versions.sh diff --git a/.github/workflows/publish-pods.yml b/.github/workflows/publish-pods.yml index 0c34e66aa..da7c5fe13 100644 --- a/.github/workflows/publish-pods.yml +++ b/.github/workflows/publish-pods.yml @@ -8,104 +8,131 @@ jobs: publish_flipper_pod: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Install Dependences - run: pod repo update + - name: Install Dependences + run: pod repo update - - name: Pod Version - run: pod --version + - name: Pod Version + run: pod --version - - name: Push Flipper - run: pod trunk push Flipper.podspec --use-libraries --allow-warnings --verbose --skip-import-validation - env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + - name: Update Flipper version + run: ./scripts/update-pod-versions.sh ./ ./Flipper.podspec + + - name: Push Flipper + run: pod trunk push Flipper.podspec --use-libraries --allow-warnings --verbose --skip-import-validation + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} publish_flipperkit_pod: needs: publish_flipper_pod runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Install Dependences - run: pod repo update + - name: Install Dependences + run: pod repo update - - name: Pod Version - run: pod --version + - name: Pod Version + run: pod --version - - name: Push FlipperKit - run: | + - name: Update FlipperKit version + run: ./scripts/update-pod-versions.sh ./ ./FlipperKit.podspec + + - name: Push FlipperKit + run: | # 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 && break || sleep 30; done - env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} create_pr: needs: publish_flipperkit_pod runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Install Dependencies - run: pod repo update + - name: Update Flipper's Podspec + run: ./scripts/update-pod-versions.sh ./ ./Flipper.podspec - - name: Pod Version - run: pod --version + - name: Update FlipperKit's Podspec + run: ./scripts/update-pod-versions.sh ./ ./FlipperKit.podspec - - name: Update Sample's Podfile.lock - run: | + - name: Update Tutorial's Podfile + run: ./scripts/update-pod-versions.sh ./ ./iOS/Tutorial/Podfile + + - name: Update Sample's Podfile + run: ./scripts/update-pod-versions.sh ./ ./iOS/Sample/Podfile + + - name: Update SampleSwift's Podfile + run: ./scripts/update-pod-versions.sh ./ ./iOS/SampleSwift/Podfile + + - name: Update Getting Started + run: ./scripts/update-pod-versions.sh ./ ./docs/getting-started/ios-native.mdx + + - name: Update RN getting started guide + run: ./scripts/update-pod-versions.sh ./ ./docs/getting-started/react-native-ios.mdx + + - name: Install Dependencies + run: pod repo update + + - name: Pod Version + run: pod --version + + - name: Update Sample's Podfile.lock + run: | cd iOS/Sample/ pod update ls - - name: Update SampleSwift's Podfile.lock - run: | + - name: Update SampleSwift's Podfile.lock + run: | cd iOS/SampleSwift/ pod update ls - - name: Update Tutorial's Podfile.lock - run: | + - name: Update Tutorial's Podfile.lock + run: | cd iOS/Tutorial/ # Retrying an update, as Flipper and FlipperKit pod may take time to get updated on CocoaPods. 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 update && break || sleep 30; done ls - # Followed this https://github.com/peter-evans/create-pull-request/blob/master/docs/concepts-guidelines.md#creating-pull-requests-on-tag-push - - name: Create a temporary tag branch - run: | - git config --global user.name 'GitHub' - git config --global user.email 'noreply@github.com' - git checkout -b temp-${GITHUB_REF:10} - git push --set-upstream origin temp-${GITHUB_REF:10} + # Followed this https://github.com/peter-evans/create-pull-request/blob/master/docs/concepts-guidelines.md#creating-pull-requests-on-tag-push + - name: Create a temporary tag branch + run: | + git config --global user.name 'GitHub' + git config --global user.email 'noreply@github.com' + git checkout -b temp-${GITHUB_REF:10} + git push --set-upstream origin temp-${GITHUB_REF:10} - - name: Git status - run: | + - name: Git status + run: | git status - - name: Git diff - run: | + - name: Git diff + run: | git diff - - name: Git branch - run: | + - name: Git branch + run: | git branch - - name: Create PR to Update Podfile.lock - uses: peter-evans/create-pull-request@v2 - with: - title: 'Automated: Update Podfile.lock' - body: | - This is an automated PR to update the Podfile.lock. - - Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions. - - Also make sure that all the dependencies are updated to the latest one. - - This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request) - base: 'master' - branch-suffix: short-commit-hash - labels: automated pr - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create PR to Update Podfile.lock + uses: peter-evans/create-pull-request@v2 + with: + title: "Automated: Update Podfile.lock" + body: | + This is an automated PR to update the Podfile.lock. + - Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions. + - Also make sure that all the dependencies are updated to the latest one. + - This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request) + base: "master" + branch-suffix: short-commit-hash + labels: automated pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Delete tag branch - run: | - git push --delete origin temp-${GITHUB_REF:10} + - name: Delete tag branch + run: | + git push --delete origin temp-${GITHUB_REF:10} diff --git a/scripts/prepare-release.sh b/scripts/prepare-release.sh index 6bc13d385..964d6e118 100755 --- a/scripts/prepare-release.sh +++ b/scripts/prepare-release.sh @@ -45,12 +45,7 @@ VERSION_PART="${2:-minor}" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SONAR_DIR="$DIR/../" DESKTOP_DIR="$SONAR_DIR/desktop" -FLIPPERKIT_PODSPEC_PATH="$SONAR_DIR/FlipperKit.podspec" FLIPPER_PODSPEC_PATH="$SONAR_DIR/Flipper.podspec" -TUTORIAL_PODFILE_PATH="$SONAR_DIR/iOS/Tutorial/Podfile" -IOS_GETTING_STARTED_DOC="$SONAR_DIR/docs/getting-started/ios-native.mdx" -RN_IOS_GETTING_STARTED_DOC="$SONAR_DIR/docs/getting-started/react-native-ios.mdx" -SPECS_DIR="$SONAR_DIR/Specs/" FLIPPERKIT_VERSION_TAG='flipperkit_version' OLD_VERSION_POD_ARG=$(< "$FLIPPER_PODSPEC_PATH" grep "$FLIPPERKIT_VERSION_TAG =" ) OLD_VERSION="${OLD_VERSION_POD_ARG##* }" @@ -84,32 +79,6 @@ yarn --cwd "$SONAR_DIR"/react-native/react-native-flipper version --new-version SNAPSHOT_MINOR_VERSION=$(echo "$VERSION" | sed -Ee 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\3 + 1/' | bc) SNAPSHOT_VERSION="$(echo "$VERSION" | sed -Ee 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1.\2./')""$SNAPSHOT_MINOR_VERSION""-SNAPSHOT" -echo "Updating version $VERSION in podspecs, podfiles and in getting started docs..." - -# Update Podspec files and podfiles with correct version -echo "Updating $FLIPPERKIT_PODSPEC_PATH" -if $darwin; then -sed -i '' "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$FLIPPERKIT_PODSPEC_PATH" -echo "Updating $FLIPPER_PODSPEC_PATH" -sed -i '' "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$FLIPPER_PODSPEC_PATH" -echo "Updating $IOS_GETTING_STARTED_DOC" -sed -i '' "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$IOS_GETTING_STARTED_DOC" -echo "Updating $RN_IOS_GETTING_STARTED_DOC" -sed -i '' "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$RN_IOS_GETTING_STARTED_DOC" -echo "Updating $TUTORIAL_PODFILE_PATH" -sed -i '' "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$TUTORIAL_PODFILE_PATH" -else - sed -i "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$FLIPPERKIT_PODSPEC_PATH" - echo "Updating $FLIPPER_PODSPEC_PATH" - sed -i "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$FLIPPER_PODSPEC_PATH" - echo "Updating $IOS_GETTING_STARTED_DOC" - sed -i "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$IOS_GETTING_STARTED_DOC" - echo "Updating $RN_IOS_GETTING_STARTED_DOC" - sed -i "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$RN_IOS_GETTING_STARTED_DOC" - echo "Updating $TUTORIAL_PODFILE_PATH" - sed -i "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${VERSION}'/" "$TUTORIAL_PODFILE_PATH" -fi - echo "Bumping version number for android related files..." # Update Android related files "$SONAR_DIR"/scripts/bump.sh "$VERSION" diff --git a/scripts/update-pod-versions.sh b/scripts/update-pod-versions.sh new file mode 100755 index 000000000..70e664dfc --- /dev/null +++ b/scripts/update-pod-versions.sh @@ -0,0 +1,46 @@ +#!/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 path to update the pod version in your second argument." + exit 1 +fi + +darwin=false +case "$(uname)" in + Darwin*) darwin=true ;; +esac + +if ! jq --version > /dev/null; then + if $darwin; then + echo "jq is not installed. Installing it..." + brew install jq + else + echo >&2 "jq is not installed. Please install it using your platform's package manager (apt-get, yum, pacman, etc.)." + exit 1 + fi +fi + +FLIPPER_DIR=$1 +PACKAGE_VERSION=$(jq -r .version "$FLIPPER_DIR/desktop/package.json") +OLD_VERSION_POD_ARG=$(< "FlipperKit.podspec" grep "flipperkit_version =" ) +OLD_VERSION="${OLD_VERSION_POD_ARG##* }" +FLIPPERKIT_VERSION_TAG='flipperkit_version' + +echo "Updating $2" +if $darwin; then +sed -i '' "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${PACKAGE_VERSION}'/" "$2" +else + sed -i "s/${FLIPPERKIT_VERSION_TAG} = ${OLD_VERSION}/${FLIPPERKIT_VERSION_TAG} = '${PACKAGE_VERSION}'/" "$2" +fi