Skip to content

Commit

Permalink
chore: Bump go-tools image to v1.1.0 (#77)
Browse files Browse the repository at this point in the history
* chore: Bump go-tools image to v1.1.0

* chore: Use svu in release script
  • Loading branch information
obalunenko authored Aug 11, 2023
1 parent d65fc5d commit c3a5f3f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1))
APP_NAME?=ge-tax-calc
SHELL := env APP_NAME=$(APP_NAME) $(SHELL)

RELEASE_BRANCH?=master
SHELL := env RELEASE_BRANCH=$(RELEASE_BRANCH) $(SHELL)

COMPOSE_TOOLS_FILE=deployments/docker-compose/go-tools-docker-compose.yml
COMPOSE_TOOLS_CMD_BASE=docker compose -f $(COMPOSE_TOOLS_FILE)
COMPOSE_TOOLS_CMD_UP=$(COMPOSE_TOOLS_CMD_BASE) up --remove-orphans --exit-code-from
Expand Down
2 changes: 1 addition & 1 deletion build/docker/go-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM ghcr.io/obalunenko/go-tools:v1.0.0 AS builder
FROM ghcr.io/obalunenko/go-tools:v1.1.0 AS builder

CMD ["/bin/sh", "-c", ""]
54 changes: 40 additions & 14 deletions scripts/release/new-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,39 @@

set -Eeuo pipefail

SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
SCRIPT_NAME="$(basename "$0")"
SCRIPT_DIR="$(dirname "$0")"
REPO_ROOT="$(cd "${SCRIPT_DIR}" && git rev-parse --show-toplevel)"
SCRIPTS_DIR="${REPO_ROOT}/scripts"

source "${SCRIPTS_DIR}/helpers-source.sh"

APP=${APP_NAME}

RELEASE_BRANCH=${RELEASE_BRANCH:-"release"}

echo "${SCRIPT_NAME} is running fo ${APP}... "

checkInstalled 'svu'

echo "${SCRIPT_NAME} is running... "

function requireReleaseBranch() {
err=0
branch=$(git branch --show-current)

echo "Current branch is: ${branch}"

if [[ ${branch} != "${RELEASE_BRANCH}" ]]; then
err=1
fi

if [[ ${err} == 1 ]]; then
echo >&2 "Please checkout to ${RELEASE_BRANCH} branch."
exit 1
fi
}

function require_clean_work_tree() {
# Update the index
git update-index -q --ignore-submodules --refresh
Expand All @@ -32,35 +61,29 @@ function require_clean_work_tree() {
}

function menu() {
PREV_VERSION=$(svu current)
clear

echo "Current version: ${PREV_VERSION}"
printf "Select what you want to update: \n"
printf "1 - Major update\n"
printf "2 - Minor update\n"
printf "3 - Patch update\n"
printf "4 - Exit\n"
read -r selection

SHORTCOMMIT="$(git rev-parse --short HEAD)"

PREV_VERSION="$(git tag | sort -V | tail -1)"
if [ -z "${PREV_VERSION}" ] || [ "${PREV_VERSION}" = "${SHORTCOMMIT}" ]; then
PREV_VERSION="v0.0.0"
fi

echo "Current version: ${PREV_VERSION}"

case "$selection" in
1)
printf "Major updates......\n"
NEW_VERSION=$(echo ${PREV_VERSION} | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, ($1+1),0,0 }')
NEW_VERSION=$(svu major)
;;
2)
printf "Run Minor update.........\n"
NEW_VERSION=$(echo ${PREV_VERSION} | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, $1,($2+1),0 }')
NEW_VERSION=$(svu minor)
;;
3)
printf "Patch update.........\n"
NEW_VERSION=$(echo ${PREV_VERSION} | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, $1,$2,($3 + 1) }')
NEW_VERSION=$(svu patch)
;;
4)
printf "Exit................................\n"
Expand All @@ -75,6 +98,9 @@ function menu() {

}

## Check if release branch
requireReleaseBranch

## Check if git is clean
require_clean_work_tree "create new version"

Expand All @@ -92,7 +118,7 @@ while true; do
case $yn in
[Yy]*)

git tag -a "${NEW_TAG}" -m "${NEW_TAG}" &&
git tag -a "${NEW_TAG}" -m "${NEW_TAG}" &&
git push --tags

break
Expand Down

0 comments on commit c3a5f3f

Please sign in to comment.