-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathpush.sh
More file actions
executable file
·90 lines (73 loc) · 3.24 KB
/
push.sh
File metadata and controls
executable file
·90 lines (73 loc) · 3.24 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
#!/bin/bash
echo '';
echo " a. development";
echo " b. master";
echo -n "[+] branch [a/B] ➜ ";
read -r branch;
echo -n "[+] commit ➜ ";
read -r commit;
# package folder & name
package=martor
if [ "$commit" ] && [ "$branch" ]; then
if [ "$branch" == 'b' ] || [ "$branch" == 'B' ]; then
echo -n "[+] upgrade version? [y/N] ➜ ";
read -r upgrade_version;
if [ "$upgrade_version" == 'y' ] || [ "$upgrade_version" == 'Y' ]; then
# https://stackoverflow.com/a/3250387/6396981
old_version=$(grep '__version__ = ".*"' $package/__init__.py | cut -d '"' -f 2);
old_release_date=$(grep '__release_date__ = ".*"' $package/__init__.py | cut -d '"' -f 2);
echo "[i] current version is $old_version, released at $old_release_date";
last_numb_old_version=$(echo "$old_version" | grep -o .$);
last_numb_new_version=$(( last_numb_old_version + 1 ))
suggested_version="${old_version%?}${last_numb_new_version}"
echo -n "[+] type new version [default:$suggested_version] ➜ ";
read -r input_new_version;
if [ ! "$input_new_version" ]; then
input_new_version=$suggested_version;
fi
# 04-Sep-2022
new_release_date=$(date +%d-%b-%Y);
# https://stackoverflow.com/a/525612/6396981
# sed -i -e => for linux user
# sed -i "" => for mac user
echo "[i] updating new version..."
find $package/ -type f \( -name "*.py" -or -name "*.css" -or -name "*.js" \) -exec sed -i "" "s/$old_version/$input_new_version/g" {} \;
find $package/ -type f \( -name "*.py" -or -name "*.css" -or -name "*.js" \) -exec sed -i "" "s/$old_release_date/$new_release_date/g" {} \;
fi
git add .;
git commit -m "$commit";
git checkout master;
git push origin master;
if [ "$upgrade_version" == 'y' ] || [ "$upgrade_version" == 'Y' ]; then
echo "[i] updating new git tag to v$input_new_version"
git tag -a v"$input_new_version" -m "launch v$input_new_version"
git push origin v"$input_new_version"
echo "[i] preparing upload to pypi..."
# Check if hatch is available
if ! [ -x "$(command -v hatch)" ]; then
echo "[!] Error: hatch is not installed or not in PATH"
exit 1
fi
echo "[i] building package for version $input_new_version..."
hatch build
# Verify the built package has the correct version
echo "[i] verifying package version..."
if [ -f "dist/$package-$input_new_version.tar.gz" ]; then
echo "[i] package built successfully: $package-$input_new_version.tar.gz"
echo "[i] publishing to PyPI..."
hatch publish
else
echo "[!] Error: Package not found. Expected: dist/$package-$input_new_version.tar.gz"
exit 1
fi
fi
else
git add .;
git commit -m "$commit";
git checkout development;
git push origin development;
fi
echo "[i] successfully pushed at $(date)";
else
echo "[!] not pushed!";
fi