Skip to content

Commit

Permalink
Added script for bumping version
Browse files Browse the repository at this point in the history
  • Loading branch information
benmarten committed Dec 22, 2016
1 parent a8e8671 commit 09a8c89
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 12 deletions.
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ modules build.gradle file:
```groovy
dependencies {
compile 'com.segment.analytics.android:analytics:4.0.4'
compile 'com.leanplum.segment:LeanplumIntegration:1.0.0'
compile 'com.leanplum.segment:LeanplumIntegration:{{LP_SEG_VERSION}}'
}
```
Please add at least the following permissions to your applications AndroidManifest.xml:
Expand Down Expand Up @@ -65,18 +65,18 @@ analytics.onIntegrationReady(LeanplumIntegration.LEANPLUM_SEGMENT_KEY,
We have included a sample application.

1. To run the sample app, open this folder in Android Studio.
2. Choose & run target `Example`
1. Choose & run target `Example`

## Tests
We have included unit tests for the integration.

1. To run the unit tests, open this folder in Android Studio.
2. Choose & run target `LeanplumIntegrationTests`
1. Choose & run target `LeanplumIntegrationTests`

## Install Specific Version of SDK's
By default this integration pulls in the latest versions of the Leanplum SDK and the Segment SDK. If you rather want to use a specific version, simply exclude them from the integration and specify the required versions in your build.gradle file directly.
```groovy
compile('com.leanplum.segment:LeanplumIntegration:1.0.0') {
compile('com.leanplum.segment:LeanplumIntegration:{{LP_SEG_VERSION}}') {
exclude group: 'com.segment.analytics.android', module: 'analytics'
exclude group: 'com.leanplum', module: 'Leanplum'
}
Expand All @@ -93,18 +93,24 @@ To upload a new version to jCenter or mavenCentral we use bintray.com.
bintrayUser=benmarten
bintrayApiKey= [...]
```
3. Increase the package version in gradle.properties project file:
1. Checkout a new release branch from develop:

```groovy
bintrayPackageVersion=1.0.0
```bash
git checkout develop
git checkout -b release/NEW_VERSION
```
1. Run the bump version script:

```bash
sh bump_version.sh
```
4. Run gradle build & upload scripts
1. Run gradle build & upload scripts

```bash
./gradlew install
./gradlew bintrayUpload
./gradle install
./gradle bintrayUpload
```
5. Go to bintray.com to double check your new release.
1. Go to bintray.com to double check your new release.

## License
See LICENSE file.
86 changes: 86 additions & 0 deletions bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset
#set -x

# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"

echo $__dir

HR="--------------------------------------------------------------------------------\n"

# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
R="$(tput setaf 1)"
G="$(tput setaf 2)"
B="$(tput setaf 4)"
Y="$(tput setaf 3)"
BD="$(tput bold)"
N="$(tput sgr0)"
else
R=""
G=""
B=""
Y=""
BD=""
N=""
fi

# Ask a Question, https://gist.github.com/davejamesmiller/1965569
function ask() {
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi

# Ask the question (not using "read -p" as it uses stderr not stdout)
echo "$1 [$prompt] "

# Read the answer (use /dev/tty in case stdin is redirected from somewhere else)
read REPLY </dev/tty

# Default?
if [ -z "$REPLY" ]; then
REPLY=$default
fi

# Check if the reply is valid
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}

function replace_version() {
sed -i '' -e "s|$2|$3|g" "$__dir/$1"
env git status --porcelain 2>/dev/null| grep "$(basename "$1")" || {
echo "${R}Error patching version info in file: $__dir/$1${N}" && exit 1
}
echo "Updated versions in file: $1"
}

function main() {
read -p "${B}Enter the new version number: ${N}" VERSION_NEW
replace_version "README.md" "{{LP_SEG_VERSION}}" $VERSION_NEW
replace_version "gradle.properties" "{{LP_SEG_VERSION}}" $VERSION_NEW
}

main
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
bintrayGroupId=com.leanplum.segment
bintrayArtifactId=LeanplumIntegration
bintrayPackageName=Leanplum-Segment
bintrayPackageVersion=1.0.1
bintrayPackageVersion={{LP_SEG_VERSION}}
bintrayDescription=Leanplum SDK integration for the Segment iOS SDK.
bintrayGithub=Leanplum/Leanplum-Segment-Android
bintrayAuthor=Leanplum Inc.
Expand Down

0 comments on commit 09a8c89

Please sign in to comment.