Skip to content

Commit

Permalink
Version bump script
Browse files Browse the repository at this point in the history
Adds an simple script to be used when a new version of the app should be
released. It will create a version tag on git and update the helm chart
to point to the version.
  • Loading branch information
jvanz committed May 2, 2021
1 parent 0516977 commit c5f3180
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@ stop-elasticsearch:

wait-elasticsearch:
$(call wait-for, localhost:9200)

.PHONY: bump-version
bump-version:
bash scripts/bump-version.sh
34 changes: 34 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# This script should be used to bump new versions. It will create a git tag for
# the new version and it will update the Helm Chart used to deploy the app in
# Kubernetes.

get_latest_version() {
git describe --tags
}

latest_version=`get_latest_version`
if [ ! $? -eq 0 ]; then
echo "Cannot find any previous version. Please, check if there is some version tag."
exit 1
fi
echo "Latest version detected $latest_version"

major=`echo $latest_version | sed 's/^v//g' | sed 's/-.*$//' | sed 's/+.*$//'| awk '{split($0,version,"."); print version[1]}'`
minor=`echo $latest_version | sed 's/^v//g' | sed 's/-.*$//' | sed 's/+.*$//'| awk '{split($0,version,"."); print version[2]}'`
patch=`echo $latest_version | sed 's/^v//g' | sed 's/-.*$//' | sed 's/+.*$//'| awk '{split($0,version,"."); print version[3]}'`

minor=$(($minor+1))

new_version="$major.$minor.$patch"
echo "New version: $new_version"

echo "Creating new git tag."
git tag $new_version -m "Version bump: $new_version"

echo "Updating app version in the helm chart."
sed -i "s/^appVersion:.*/appVersion: $new_version/" helm/Chart.yaml

echo ""
echo "Now you need to commit the changes! ;)"

0 comments on commit c5f3180

Please sign in to comment.