|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +darwin=false |
| 5 | +case "$(uname)" in |
| 6 | + Darwin*) darwin=true ;; |
| 7 | +esac |
| 8 | + |
| 9 | +if $darwin; then |
| 10 | + sedi="sed -i ''" |
| 11 | +else |
| 12 | + sedi="sed -i" |
| 13 | +fi |
| 14 | + |
| 15 | +echo "Checking for any uncommited changes..." |
| 16 | + |
| 17 | +CHANGES=$(hg st) |
| 18 | +echo "$CHANGES" |
| 19 | + |
| 20 | +if [ ! -z "$CHANGES" ]; |
| 21 | +then |
| 22 | + echo "There are uncommitted changes, either commit it or revert them." |
| 23 | + exit 1 |
| 24 | +fi |
| 25 | + |
| 26 | +echo "✨ Making a new release..." |
| 27 | + |
| 28 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 29 | +SONAR_DIR="$DIR/../" |
| 30 | +SONARKIT_PODSPEC_PATH="$SONAR_DIR/iOS/SonarKit.podspec" |
| 31 | +SONAR_PODSPEC_PATH="$SONAR_DIR/xplat/Sonar/Sonar.podspec" |
| 32 | +SONAR_GETTING_STARTED_DOC="$SONAR_DIR/docs/getting-started.md" |
| 33 | +SPECS_DIR="$SONAR_DIR/Specs/" |
| 34 | +SONARKIT_VERSION_TAG='sonarkit_version' |
| 35 | +OLD_VERSION_POD_ARG=$(< "$SONAR_PODSPEC_PATH" grep "$SONARKIT_VERSION_TAG =" ) |
| 36 | +OLD_VERSION="${OLD_VERSION_POD_ARG##* }" |
| 37 | + |
| 38 | +echo "Currently released version is $OLD_VERSION, What should the version of the next release be?" |
| 39 | +read -r VERSION |
| 40 | + |
| 41 | +echo "Updating version $VERSION in podspecs, podfiles and in getting started docs..." |
| 42 | + |
| 43 | +# Update Podspec files and podfiles with correct version |
| 44 | +echo "Updating $SONARKIT_PODSPEC_PATH" |
| 45 | +$sedi "s/${SONARKIT_VERSION_TAG} = ${OLD_VERSION}/${SONARKIT_VERSION_TAG} = '${VERSION}'/" "$SONARKIT_PODSPEC_PATH" |
| 46 | +echo "Updating $SONAR_PODSPEC_PATH" |
| 47 | +$sedi "s/${SONARKIT_VERSION_TAG} = ${OLD_VERSION}/${SONARKIT_VERSION_TAG} = '${VERSION}'/" "$SONAR_PODSPEC_PATH" |
| 48 | +echo "Updating $SONAR_GETTING_STARTED_DOC" |
| 49 | +$sedi "s/${SONARKIT_VERSION_TAG} = ${OLD_VERSION}/${SONARKIT_VERSION_TAG} = '${VERSION}'/" "$SONAR_GETTING_STARTED_DOC" |
| 50 | + |
| 51 | +# Copy Podfiles |
| 52 | +mkdir "$SPECS_DIR/SonarKit/$VERSION" # New Specs dir for SonarKit podspec |
| 53 | +mkdir "$SPECS_DIR/Sonar/$VERSION" # New Specs dir for Sonar podspec |
| 54 | +echo "Copying SonarKit.podspec in Specs folder" |
| 55 | +cp "$SONARKIT_PODSPEC_PATH" "$SPECS_DIR/SonarKit/$VERSION" # Copied SonarKit podspec |
| 56 | +echo "Copying Sonar.podspec in Specs folder" |
| 57 | +cp "$SONAR_PODSPEC_PATH" "$SPECS_DIR/Sonar/$VERSION" # Copied Sonar podspec |
| 58 | + |
| 59 | +echo "Bumping version number for android related files..." |
| 60 | +# Update Android related files |
| 61 | +"$SONAR_DIR"/scripts/bump.sh "$VERSION" |
| 62 | + |
| 63 | +#Update Package.json |
| 64 | +echo "Bumping version number in package.json" |
| 65 | +jq '.version = $newVal' --arg newVal "$VERSION" "$SONAR_DIR"/package.json > tmp.$$.json && mv tmp.$$.json "$SONAR_DIR"/package.json |
| 66 | + |
| 67 | +echo "Committing the files..." |
| 68 | +hg addremove |
| 69 | +hg commit -m"Flipper Release: v$VERSION" |
| 70 | + |
| 71 | +echo "Preparing diff for your review..." |
| 72 | +arc diff --prepare |
0 commit comments