From 1bb30f6813b445f3379042801a5e8a1ea1198e0f Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 17 Apr 2020 10:36:39 -0400 Subject: [PATCH] Automating repacking script and github tagging after publish. --- example/package-lock.json | 2 +- package.json | 3 ++- repack.sh | 41 ++++++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/example/package-lock.json b/example/package-lock.json index dca8a2c..adc6741 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -4961,7 +4961,7 @@ }, "react-native-ble-advertiser": { "version": "file:../react-native-ble-advertiser-0.0.13.tgz", - "integrity": "sha512-FUV+uaf8tydizmof35n7aJ7RyEclW1bZ46XHyJ2A9NfQWgJ0KpVmlr49ISvgmLkvBiQaQxhBWVvsOJRdMoFwKA==" + "integrity": "sha512-P3aOMq3g0Bv3as3lILx0zsMb2EcCtuEPAmEVMCgmQ50L6mbyWtjdBCXQQ4aH8j0OAzD4QpbcZ8/tQo3SZLcBiQ==" }, "react-native-uuid-generator": { "version": "6.1.1", diff --git a/package.json b/package.json index 09595ee..eb8a91b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "A react-native implementation for sending BLE advertisements", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "postpublish" : "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag $PACKAGE_VERSION && git push --tags" }, "keywords": [ "react", diff --git a/repack.sh b/repack.sh index e0f99cc..711b6b8 100755 --- a/repack.sh +++ b/repack.sh @@ -1,15 +1,34 @@ +#! /bin/sh + +PACKAGE_VERSION=$(cat package.json \ + | grep version \ + | head -1 \ + | awk -F: '{ print $2 }' \ + | sed 's/[",]//g' \ + | tr -d '[[:space:]]') + +NPMFILE="../react-native-ble-advertiser-$PACKAGE_VERSION.tgz" + +echo Packing $PACKAGE_VERSION into $NPMFILE + npm pack + +echo Installing new Lib on Example app + cd example -npm i ../react-native-ble-advertiser-0.0.13.tgz - -if [ $1 = "android" ] -then - npx react-native run-android -else - cd ios - pod install - cd .. - npx react-native run-ios -fi +npm i $NPMFILE +cd ios +pod install +cd .. + +if [ -z "$1" ] then + echo Running on "$1" + case "$1" in + "android") npx react-native run-android + ;; + "ios") npx react-native run-ios --device + ;; + esac +fi cd .. \ No newline at end of file