-
Notifications
You must be signed in to change notification settings - Fork 0
/
package
executable file
·89 lines (66 loc) · 2.13 KB
/
package
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
#!/bin/bash
# ------------------------------------------------------------------------------
# Description
# ------------------------------------------------------------------------------
# Run various packaging commands.
# ------------------------------------------------------------------------------
# Process Arguments
# ------------------------------------------------------------------------------
main() {
# Handle only the first command passed into the script
case $1 in
refresh) refresh;;
update) update;;
build) build;;
publish) publish;;
help) print_help;;
--help) print_help;;
*) print_help;;
esac;
# Exit with code
exit 0
}
# ------------------------------------------------------------------------------
# Commands
# ------------------------------------------------------------------------------
refresh() {
poetry cache clear pypi --all
}
update() {
echo "No development dependencies."
}
build() {
poetry build
}
publish() {
# Extract current version
grep 'version = "0.0.0.([0-9]+)"' pyproject.toml
version=$(awk -F'"' '/^version =/ {print $2}' pyproject.toml)
# Chop up the version string
majorversion=$(echo $version | cut -d'.' -f1-3)
minorversion=$(echo $version | cut -d'.' -f4)
# Advance the minor version number
new_mversion=$((minorversion + 1))
new_version="$majorversion.$new_mversion"
# Update the .toml file
sed -i s/version.*=.*/version\ =\ \"$new_version\"/ pyproject.toml
# Build and publish
poetry publish --build
}
print_help() {
cat <<'_HELP_TEXT'
voices <command> <args>
Commands marked with [root] need to be run as root.
Commands:
refresh Refresh central poetry cache.
update Update development dependencies.
build Build the package locally.
publish Update the version number, build and publish the package.
help Print this help information.
_HELP_TEXT
}
# ------------------------------------------------------------------------------
# Run
# ------------------------------------------------------------------------------
# Execute the script with forward-declared functions
main $@