-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.sh
More file actions
executable file
·93 lines (78 loc) · 2.67 KB
/
make.sh
File metadata and controls
executable file
·93 lines (78 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# --- Makefile like bash script for development ---
# --- Source this script in your terminal to set up the dev environment ---
# --- Execute the script to see a list of available commands ---
# ------------------------------------------------------------------------------
[[ -n $MKWD ]] || export MKWD=$(echo $(command cd $(dirname '$0'); pwd))
CONDAENV=python-logg
## -----------------------------------------------------------------------------
if [[ $(basename "${0}") != "make.sh" ]]; then
# Script sourced, load or create condaenv
if ! conda activate $CONDAENV; then
# Create a conda environment.
echo "Setting up $CONDAENV conda environment."
conda create -n $CONDAENV python=3.10 || return 10
conda activate $CONDAENV || return 11
fi
export PYTHONPATH=$MKWD
alias cdmk="cd $MKWD/"
alias mk="$MKWD/make.sh"
echo "Environment set up. You can now use 'mk' to execute this script."
return 0
fi
bump() {
# Bump the version number.
echo "Note: This may not work in MACOS!"
VERSION=$(sed -n 's/__version__ = "\(.*\)"/\1/p' pylogg/__init__.py)
echo "version = $VERSION"
VERSION=$(python -c "v='$VERSION'.split('.');print('%s.%s.%d' %(v[0], v[1], int(v[2])+1))")
echo " >>>"
sed -i "s/\(__version__ = \"\)[^\"]*\"/\1$VERSION\"/" pylogg/__init__.py
echo "version = $VERSION"
}
publish() {
# Run tests
pytest || exit 1
version=$(sed -n 's/__version__ = "\(.*\)"/\1/p' pylogg/__init__.py)
# Add to git and push.
git add pylogg/__init__.py
git commit -m "Bump to v$version"
git push
# Create a new git tag using the pylogg/__init__.py version
# and push the tag to origin.
git tag v$version && git push origin v$version
echo "OK"
}
setup() {
pip install -e .[dev]
pip install pytest pre-commit
pre-commit install
}
prepare() {
pre-commit run --all-files
pytest
}
test() {
pytest -vv -s
}
## EXECUTE OR SHOW USAGE.
## -----------------------------------------------------------------------------
if [[ "$#" -lt 1 ]]; then
echo -e "\nUSAGE: mk <command> [options ...]"
echo -e "\tSource this script to setup the terminal environment."
echo -e "\nAvailable commands:"
echo -e "------------------------------------------------------------------"
echo -e " setup Install dev requirements and setup env."
echo
echo -e " prepare Prepare files to publish."
echo
echo -e " test Run tests."
echo
echo -e " bump Bump the minor version number."
echo
echo -e " publish Publish current changes as a new version."
echo
else
cd $MKWD
"$@"
fi