From 41d0b2eec21d1e7507f3796c988250a05b3c94d8 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Thu, 26 Jul 2018 05:12:09 -0700 Subject: [PATCH] Move iOS scripts to xplat Summary: Move iOS scripts to xplat Reviewed By: passy Differential Revision: D8989985 fbshipit-source-id: 1499657f6d9b7e82f26aa8c008951c885756b51d --- scripts/public-ios-podspec-update.sh | 32 +++++++++++++++++++++++++++ scripts/public-ios-release.json | 33 ++++++++++++++++++++++++++++ scripts/push-new-github-tag.sh | 17 ++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 scripts/public-ios-podspec-update.sh create mode 100644 scripts/public-ios-release.json create mode 100644 scripts/push-new-github-tag.sh diff --git a/scripts/public-ios-podspec-update.sh b/scripts/public-ios-podspec-update.sh new file mode 100644 index 000000000..ef4d72908 --- /dev/null +++ b/scripts/public-ios-podspec-update.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +echo "✨ Updating podspecs with new release..." + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +FBSOURCE_DIR="$DIR/../../../../" +XPLAT_SONAR_DIR="$FBSOURCE_DIR/xplat/sonar" +XPLAT_SONAR_GETTING_STARTED_DOC="$XPLAT_SONAR_DIR/docs/getting-started.md" +XPLAT_SONAR_CLIENT_SONAR_PODSPEC="$FBSOURCE_DIR/xplat/sonar-client/Sonar/Sonar.podspec" +SPECS_DIR="$FBSOURCE_DIR/xplat/sonar/Specs" +PODSPEC_PATH="$DIR/../OSSProject/SonarKit.podspec" +PODFILE_PATH="$DIR/../Sample/Podfile" +SONARKIT_VERSION_TAG='sonarkit_version' +OLD_VERSION_POD_ARG=$(< "$PODSPEC_PATH" grep "$SONARKIT_VERSION_TAG =" ) +OLD_VERSION="${OLD_VERSION_POD_ARG##* }" + +echo "Currently released version is $OLD_VERSION, What should the version of the next release be?" +read -r VERSION + +echo "Updating version $VERSION in podspecs, podfiles and in getting started docs..." + +# Update Podspec files and podfiles with correct version +sed -i "" "s/${SONARKIT_VERSION_TAG} = ${OLD_VERSION}/${SONARKIT_VERSION_TAG} = '${VERSION}'/g" "$PODSPEC_PATH" +sed -i "" "s/${SONARKIT_VERSION_TAG} = ${OLD_VERSION}/${SONARKIT_VERSION_TAG} = '${VERSION}'/g" "$PODFILE_PATH" +sed -i "" "s/${SONARKIT_VERSION_TAG} = ${OLD_VERSION}/${SONARKIT_VERSION_TAG} = '${VERSION}'/g" "$XPLAT_SONAR_CLIENT_SONAR_PODSPEC" +sed -i "" "s/${SONARKIT_VERSION_TAG} = ${OLD_VERSION}/${SONARKIT_VERSION_TAG} = '${VERSION}'/g" "$XPLAT_SONAR_GETTING_STARTED_DOC" + +# Copy Podfiles +mkdir "$SPECS_DIR/SonarKit/$VERSION" # New Specs dir for SonarKit podspec +mkdir "$SPECS_DIR/Sonar/$VERSION" # New Specs dir for Sonar podspec +cp "$PODSPEC_PATH" "$SPECS_DIR/SonarKit/$VERSION" # Copied SonarKit podspec +cp "$XPLAT_SONAR_CLIENT_SONAR_PODSPEC" "$SPECS_DIR/Sonar/$VERSION" # Copied Sonar podspec diff --git a/scripts/public-ios-release.json b/scripts/public-ios-release.json new file mode 100644 index 000000000..abb1a9982 --- /dev/null +++ b/scripts/public-ios-release.json @@ -0,0 +1,33 @@ +{ + "command": "SandcastleUniversalCommand", + "user": "__USER__", + "args": { + "name": "Release public Sonar build", + "oncall": "danielbuechele", + "steps": [ + { + "name": "Clone from GitHub", + "required": true, + "shell": "git -c http.proxy=fwdproxy:8080 -c https.proxy=fwdproxy:8080 clone https://github.com/facebook/Sonar.git ../xplat/sonar-public" + }, + { + "name": "Publish to github", + "required": true, + "shell": "curl -o RELEASE.json -x fwdproxy:8080 --silent --data '{ \"tag_name\": \"v__VERSION__\", \"target_commitish\": \"master\", \"name\": \"v__VERSION__\", \"body\": \"\", \"draft\": false, \"prerelease\": true}' https://api.github.com/repos/facebook/Sonar/releases?access_token=$(secrets_tool get SONAR_GITHUB_TOKEN)", + "shell_type": "SandcastleLocalShell" + } + ] + }, + "alias": "sonar_release_ios_public_build", + "capabilities": { + "vcs": "fbcode-fbsource", + "type": "lego-mac" + }, + "hash": "master", + "report": [ + { + "type": "email", + "report_to_owner": true + } + ] +} diff --git a/scripts/push-new-github-tag.sh b/scripts/push-new-github-tag.sh new file mode 100644 index 000000000..be12844af --- /dev/null +++ b/scripts/push-new-github-tag.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "✨ Creating new Sonar iOS release on GitHub..." + +echo "What should the patch version of the next release be?" +read -r VERSION + +TMP_DIR=$(mktemp -d) +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +JSON=$(cat "$DIR/public-ios-release.json") +JSON=${JSON/__VERSION__/$VERSION} +JSON=${JSON/__VERSION__/$VERSION} +JSON=${JSON/__USER__/$USER} +echo "$JSON" > "$TMP_DIR/job.json" +scutil create "$TMP_DIR/job.json" +echo "✅ GitHub release will be automatically created once the Sandcastle job finishes." +rm -rf "$TMP_DIR"