Skip to content

Commit 439d26f

Browse files
author
Maksym Trofimenko
committed
update module
1 parent 7e8209e commit 439d26f

File tree

3 files changed

+128
-71
lines changed

3 files changed

+128
-71
lines changed

bump-version.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
3+
# Thanks goes to @pete-otaqui for the initial gist:
4+
# https://gist.github.com/pete-otaqui/4188238
5+
#
6+
# Original version modified by Marek Suscak
7+
#
8+
# works with a file called VERSION in the current directory,
9+
# the contents of which should be a semantic version number
10+
# such as "1.2.3" or even "1.2.3-beta+001.ab"
11+
12+
# this script will display the current version, automatically
13+
# suggest a "minor" version update, and ask for input to use
14+
# the suggestion, or a newly entered value.
15+
16+
# once the new version number is determined, the script will
17+
# pull a list of changes from git history, prepend this to
18+
# a file called CHANGELOG.md (under the title of the new version
19+
# number), give user a chance to review and update the changelist
20+
# manually if needed and create a GIT tag.
21+
22+
NOW="$(date +'%B %d, %Y')"
23+
RED="\033[1;31m"
24+
GREEN="\033[0;32m"
25+
YELLOW="\033[1;33m"
26+
BLUE="\033[1;34m"
27+
PURPLE="\033[1;35m"
28+
CYAN="\033[1;36m"
29+
WHITE="\033[1;37m"
30+
RESET="\033[0m"
31+
32+
LATEST_HASH=`git log --pretty=format:'%h' -n 1`
33+
34+
QUESTION_FLAG="${GREEN}?"
35+
WARNING_FLAG="${YELLOW}!"
36+
NOTICE_FLAG="${CYAN}"
37+
38+
ADJUSTMENTS_MSG="${QUESTION_FLAG} ${CYAN}Now you can make adjustments to ${WHITE}CHANGELOG.md${CYAN}. Then press enter to continue."
39+
PUSHING_MSG="${NOTICE_FLAG} Pushing new version to the ${WHITE}origin${CYAN}..."
40+
41+
if [ -f VERSION ]; then
42+
BASE_STRING=`cat VERSION`
43+
BASE_LIST=(`echo $BASE_STRING | tr '.' ' '`)
44+
V_MAJOR=${BASE_LIST[0]}
45+
V_MINOR=${BASE_LIST[1]}
46+
V_PATCH=${BASE_LIST[2]}
47+
echo -e "${NOTICE_FLAG} Current version: ${WHITE}$BASE_STRING"
48+
echo -e "${NOTICE_FLAG} Latest commit hash: ${WHITE}$LATEST_HASH"
49+
V_MINOR=$((V_MINOR + 1))
50+
V_PATCH=0
51+
SUGGESTED_VERSION="$V_MAJOR.$V_MINOR.$V_PATCH"
52+
echo -ne "${QUESTION_FLAG} ${CYAN}Enter a version number [${WHITE}$SUGGESTED_VERSION${CYAN}]: "
53+
read INPUT_STRING
54+
if [ "$INPUT_STRING" = "" ]; then
55+
INPUT_STRING=$SUGGESTED_VERSION
56+
fi
57+
echo -e "${NOTICE_FLAG} Will set new version to be ${WHITE}$INPUT_STRING"
58+
echo $INPUT_STRING > VERSION
59+
echo "## $INPUT_STRING ($NOW)" > tmpfile
60+
git log --pretty=format:" - %s" "v$BASE_STRING"...HEAD >> tmpfile
61+
echo "" >> tmpfile
62+
echo "" >> tmpfile
63+
cat CHANGELOG.md >> tmpfile
64+
mv tmpfile CHANGELOG.md
65+
echo -e "$ADJUSTMENTS_MSG"
66+
read
67+
echo -e "$PUSHING_MSG"
68+
git add CHANGELOG.md VERSION
69+
git commit -m "Bump version to ${INPUT_STRING}."
70+
git tag -a -m "Tag version ${INPUT_STRING}." "v$INPUT_STRING"
71+
git push origin --tags
72+
else
73+
echo -e "${WARNING_FLAG} Could not find a VERSION file."
74+
echo -ne "${QUESTION_FLAG} ${CYAN}Do you want to create a version file and start from scratch? [${WHITE}y${CYAN}]: "
75+
read RESPONSE
76+
if [ "$RESPONSE" = "" ]; then RESPONSE="y"; fi
77+
if [ "$RESPONSE" = "Y" ]; then RESPONSE="y"; fi
78+
if [ "$RESPONSE" = "Yes" ]; then RESPONSE="y"; fi
79+
if [ "$RESPONSE" = "yes" ]; then RESPONSE="y"; fi
80+
if [ "$RESPONSE" = "YES" ]; then RESPONSE="y"; fi
81+
if [ "$RESPONSE" = "y" ]; then
82+
echo "0.1.0" > VERSION
83+
echo "## 0.1.0 ($NOW)" > CHANGELOG.md
84+
git log --pretty=format:" - %s" >> CHANGELOG.md
85+
echo "" >> CHANGELOG.md
86+
echo "" >> CHANGELOG.md
87+
echo -e "$ADJUSTMENTS_MSG"
88+
read
89+
echo -e "$PUSHING_MSG"
90+
git add VERSION CHANGELOG.md
91+
git commit -m "Add VERSION and CHANGELOG.md files, Bump version to v0.1.0."
92+
git tag -a -m "Tag version 0.1.0." "v0.1.0"
93+
git push origin --tags
94+
fi
95+
fi
96+
97+
echo -e "${NOTICE_FLAG} Finished."

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/rs/zerolog v1.31.0
77
github.com/spf13/cobra v1.8.0
88
github.com/spf13/viper v1.19.0
9-
github.com/tiny-systems/module v0.1.90
9+
github.com/tiny-systems/module v0.1.91
1010
)
1111

1212
require (
@@ -80,15 +80,16 @@ require (
8080
github.com/swaggest/refl v1.3.0 // indirect
8181
github.com/tiny-systems/errorpanic v0.7.1 // indirect
8282
github.com/tiny-systems/platform-api v0.0.10 // indirect
83+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 // indirect
8384
go.opentelemetry.io/contrib/instrumentation/runtime v0.46.1 // indirect
8485
go.opentelemetry.io/otel v1.30.0 // indirect
8586
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0 // indirect
8687
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
8788
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect
88-
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect
89+
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.30.0 // indirect
8990
go.opentelemetry.io/otel/metric v1.30.0 // indirect
90-
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
91-
go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect
91+
go.opentelemetry.io/otel/sdk v1.30.0 // indirect
92+
go.opentelemetry.io/otel/sdk/metric v1.30.0 // indirect
9293
go.opentelemetry.io/otel/trace v1.30.0 // indirect
9394
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
9495
go.uber.org/atomic v1.11.0 // indirect
@@ -104,7 +105,6 @@ require (
104105
golang.org/x/time v0.5.0 // indirect
105106
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
106107
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
107-
google.golang.org/appengine v1.6.8 // indirect
108108
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
109109
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
110110
google.golang.org/grpc v1.66.1 // indirect

0 commit comments

Comments
 (0)