Skip to content

Commit c82fdd4

Browse files
authored
Merge pull request #25 from bybatkhuu/develop
💥🔨 Changed 'BEANS_LOGGING_DIR' to 'BEANS_LOGGING_LOGS_DIR…
2 parents ea49619 + ff39f3e commit c82fdd4

File tree

6 files changed

+48
-30
lines changed

6 files changed

+48
-30
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ DEBUG=true
33

44
BEANS_LOGGING_DISABLE_DEFAULT=false
55
BEANS_LOGGING_CONFIG_PATH="./configs/logger.yml"
6-
BEANS_LOGGING_DIR="./logs"
6+
BEANS_LOGGING_LOGS_DIR="./logs"

.github/workflows/1.bump-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
run: |
2727
git config user.name "github-actions"
2828
git config user.email "github-actions@github.com"
29-
./scripts/bump-version.sh -b=${{ inputs.bump_type }} -p
29+
./scripts/bump-version.sh -b=${{ inputs.bump_type }} -c -t -p

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ DEBUG=true
387387
388388
BEANS_LOGGING_DISABLE_DEFAULT=false
389389
BEANS_LOGGING_CONFIG_PATH="./configs/logger.yml"
390-
BEANS_LOGGING_DIR="./logs"
390+
BEANS_LOGGING_LOGS_DIR="./logs"
391391
```
392392

393393
## Configuration

beans_logging/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ def _check_env(self):
310310
if _is_debug and (self.config.level != "TRACE"):
311311
self.config.level = "DEBUG"
312312

313-
if "BEANS_LOGGING_DIR" in os.environ:
314-
self.config.file.logs_dir = os.getenv("BEANS_LOGGING_DIR")
313+
if "BEANS_LOGGING_LOGS_DIR" in os.environ:
314+
self.config.file.logs_dir = os.getenv("BEANS_LOGGING_LOGS_DIR")
315315

316316
# if self.config.stream.use_color:
317317
# ## Checking terminal could support xterm colors:

scripts/bump-version.sh

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cd "${_PROJECT_DIR}" || exit 2
1212
# shellcheck disable=SC1091
1313
source ./scripts/base.sh
1414

15-
# Loading .env file:
15+
# Loading .env file (if exists):
1616
if [ -f ".env" ]; then
1717
# shellcheck disable=SC1091
1818
source .env
@@ -22,13 +22,15 @@ fi
2222

2323
## --- Variables --- ##
2424
# Load from envrionment variables:
25-
VERSION_FILE="${VERSION_FILE:-beans_logging/__version__.py}"
25+
VERSION_FILE_PATH="${VERSION_FILE_PATH:-beans_logging/__version__.py}"
2626

2727

2828
_BUMP_TYPE=""
2929

3030
# Flags:
31-
_IS_PUSH_TAG=false
31+
_IS_COMMIT=false
32+
_IS_TAG=false
33+
_IS_PUSH=false
3234
## --- Variables --- ##
3335

3436

@@ -42,12 +44,18 @@ main()
4244
-b=* | --bump-type=*)
4345
_BUMP_TYPE="${_input#*=}"
4446
shift;;
45-
-p | --push-tag)
46-
_IS_PUSH_TAG=true
47+
-c | --commit)
48+
_IS_COMMIT=true
49+
shift;;
50+
-t | --tag)
51+
_IS_TAG=true
52+
shift;;
53+
-p | --push)
54+
_IS_PUSH=true
4755
shift;;
4856
*)
4957
echoError "Failed to parsing input -> ${_input}"
50-
echoInfo "USAGE: ${0} -b=*, --bump-type=* [major | minor | patch] | -p, --push-tag"
58+
echoInfo "USAGE: ${0} -b=*, --bump-type=* [major | minor | patch] | -c, --commit | -t, --tag | -p, --push"
5159
exit 1;;
5260
esac
5361
done
@@ -65,7 +73,7 @@ main()
6573
exit 1
6674
fi
6775

68-
if [ "${_IS_PUSH_TAG}" == true ]; then
76+
if [ "${_IS_COMMIT}" == true ]; then
6977
exitIfNoGit
7078
fi
7179

@@ -91,26 +99,36 @@ main()
9199

92100
echoInfo "Bumping version to '${_new_version}'..."
93101
# Update the version file with the new version:
94-
echo -e "# -*- coding: utf-8 -*-\n\n__version__ = \"${_new_version}\"" > "${VERSION_FILE}" || exit 2
102+
echo -e "# -*- coding: utf-8 -*-\n\n__version__ = \"${_new_version}\"" > "${VERSION_FILE_PATH}" || exit 2
95103
echoOk "New version: '${_new_version}'"
96104

97-
if [ "${_IS_PUSH_TAG}" == true ]; then
98-
echoInfo "Pushing git tag 'v${_new_version}'..."
99-
if git rev-parse "v${_new_version}" > /dev/null 2>&1; then
100-
echoError "'v${_new_version}' tag is already exists."
101-
exit 1
102-
else
103-
# Commit the updated version file:
104-
git add "${VERSION_FILE}" || exit 2
105-
git commit -m ":bookmark: Bump version to '${_new_version}'." || exit 2
106-
git push || exit 2
105+
if [ "${_IS_COMMIT}" == true ]; then
106+
echoInfo "Committing bump version 'v${_new_version}'..."
107+
# Commit the updated version file:
108+
git add "${VERSION_FILE_PATH}" || exit 2
109+
git commit -m ":bookmark: Bump version to '${_new_version}'." || exit 2
110+
echoOk "Done."
107111

112+
if [ "${_IS_TAG}" == true ]; then
113+
echoInfo "Tagging 'v${_new_version}'..."
114+
if git rev-parse "v${_new_version}" > /dev/null 2>&1; then
115+
echoError "'v${_new_version}' tag is already exists."
116+
exit 1
117+
fi
108118
git tag "v${_new_version}" || exit 2
109-
# git push origin "v${_new_version}" || exit 2
110-
# shellcheck disable=SC1083
111-
git push "$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream} | sed 's/\/.*//')" "v${_new_version}" || exit 2
119+
echoOk "Done."
120+
fi
121+
122+
if [ "${_IS_PUSH}" == true ]; then
123+
echoInfo "Pushing 'v${_new_version}'..."
124+
git push || exit 2
125+
126+
if [ "${_IS_TAG}" == true ]; then
127+
# shellcheck disable=SC1083
128+
git push "$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream} | sed 's/\/.*//')" "v${_new_version}" || exit 2
129+
fi
130+
echoOk "Done."
112131
fi
113-
echoOk "Done."
114132
fi
115133
}
116134

scripts/get-version.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ fi
1717

1818
## --- Variables --- ##
1919
# Load from envrionment variables:
20-
VERSION_FILE="${VERSION_FILE:-beans_logging/__version__.py}"
20+
VERSION_FILE_PATH="${VERSION_FILE_PATH:-beans_logging/__version__.py}"
2121
## --- Variables --- ##
2222

2323

24-
if [ -n "${VERSION_FILE}" ] && [ -f "${VERSION_FILE}" ]; then
25-
_current_version=$(< "${VERSION_FILE}" grep "__version__ = " | awk -F' = ' '{print $2}' | tr -d '"') || exit 2
24+
if [ -n "${VERSION_FILE_PATH}" ] && [ -f "${VERSION_FILE_PATH}" ]; then
25+
_current_version=$(< "${VERSION_FILE_PATH}" grep "__version__ = " | awk -F' = ' '{print $2}' | tr -d '"') || exit 2
2626
else
2727
_current_version="0.0.0"
2828
fi

0 commit comments

Comments
 (0)