Skip to content

Commit

Permalink
Add release script
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes committed Jan 12, 2024
1 parent 250b651 commit 0c85b7b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -exo pipefail

# Gets a property out of a .properties file
# usage: getProperty $key $filename
function getProperty() {
grep "${1}" "$2" | cut -d'=' -f2
}

NEW_VERSION=$1
NEW_SNAPSHOT_VERSION=$2
CUR_SNAPSHOT_VERSION=$(getProperty 'VERSION_NAME' gradle.properties)

if [ -z "$NEW_SNAPSHOT_VERSION" ]; then
# If no snapshot version was provided, use the current value
NEW_SNAPSHOT_VERSION=$CUR_SNAPSHOT_VERSION
fi

echo "Publishing $NEW_VERSION"

# Prepare release
sed -i.bak "s/${CUR_SNAPSHOT_VERSION}/${NEW_VERSION}/g" gradle.properties
git add gradle.properties
git commit -m "Prepare for release $NEW_VERSION"

# Build
./gradlew build

# Add git tag
git tag "v$NEW_VERSION"
# Prepare next snapshot
echo "Setting next snapshot version $NEW_SNAPSHOT_VERSION"
sed -i.bak "s/${NEW_VERSION}/${NEW_SNAPSHOT_VERSION}/g" gradle.properties
git add gradle.properties
git commit -m "Prepare next development version"

# Remove the backup file from sed edits
rm gradle.properties.bak

# Push it all up
#git push && git push --tags

0 comments on commit 0c85b7b

Please sign in to comment.