Skip to content

Commit e2210cc

Browse files
🔨 Update release function
1 parent cb55031 commit e2210cc

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

toolbox.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,19 @@ function release() {
179179

180180
# @description Create a push and a new branch with commits previously prepared
181181
# @exitcode 0 If successful.
182-
# @exitcode 1 If an error is encountered when push the release.
182+
# @exitcode 1 If the last commit tag does not match the last git tag.
183183
function release_push() {
184-
local last_tag="" branch_name=""
185-
# checkout released tag and creation of branch to push (becasue of main protection)
184+
local last_tag_prepare="" last_tag="" branch_name=""
185+
# Check that the release has been properly prepared
186+
last_tag_prepare=$(git log -2 --pretty=%B|grep "prepare release"|awk '{print $NF}')
187+
# Retrieve last tag
186188
last_tag=$(git tag --sort=-version:refname | head -n 1)
189+
# Check that the tag is correct
190+
if ! [[ "$last_tag_prepare" = "$last_tag" ]]; then
191+
error "The last commit tag does not match the last git tag"
192+
return 1
193+
fi
194+
# Checkout released tag and creation of branch to push (because of main protection)
187195
branch_name="release_${last_tag}"
188196
git checkout -b "${branch_name}"
189197
# push branch associated to new tag release
@@ -242,7 +250,7 @@ function check_opts() {
242250
esac
243251
done
244252
# Help is displayed if no option is passed as script parameter
245-
if [[ $((HELP+INIT+START+STOP+CLEAN+RELEASE+BUILD+COMPILE+BUILD_DOCKER+DISPLAY_LOGS)) -eq 0 ]]; then
253+
if [[ $((HELP+INIT+START+STOP+CLEAN+RELEASE+RELEASE_PUSH+BUILD+COMPILE+BUILD_DOCKER+DISPLAY_LOGS)) -eq 0 ]]; then
246254
HELP=1
247255
fi
248256
return 0
@@ -253,7 +261,7 @@ function execute_function() {
253261
if ! [[ $(type -t "${ARGS[0]}") == function ]]; then
254262
error "Function with name ${ARGS[0]} does not exist" && return 1
255263
fi
256-
eval "${ARGS[@]}"
264+
"${ARGS[@]}"
257265
return $?
258266
}
259267

utils.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function docker_run() {
2323
-p 8000:8000 \
2424
-v "$(pwd)/toolbox.sh:/app/toolbox.sh" \
2525
-v "$(pwd)/utils_bash.sh:/app/utils_bash.sh" \
26+
-v "$(pwd)/.default.docker.env:/app/.default.docker.env" \
2627
-v "$(pwd)/mkdocs.yml:/app/mkdocs.yml" \
2728
-v "$(pwd)/docs:/app/docs" \
2829
-v "$(pwd)/tests:/app/tests" \

utils_bash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function unit_tests() {
5353
# @exitcode 0 If successful.
5454
function lint() {
5555
info "Linting bash code"
56-
shellcheck -x toolbox.sh
56+
shellcheck -e SC1083 -x toolbox.sh
5757
return 0
5858
}
5959

0 commit comments

Comments
 (0)