File: update_pypi.sh

package info (click to toggle)
mkdocs-test 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 436 kB
  • sloc: python: 938; sh: 34; makefile: 5
file content (47 lines) | stat: -rwxr-xr-x 1,312 bytes parent folder | download
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
# -------------------------------------------------------------
# update the package on pypi
# 2024-10-12
#
# Tip: if you don't want to retype pypi's username every time
#      define it as an environment variable (TWINE_USERNAME)
#
# -------------------------------------------------------------
function warn {
  GREEN='\033[0;32m'
  NORMAL='\033[0m'
  echo -e "${GREEN}$1${NORMAL}"
}

function get_value {
  # get the value from the config file
  toml get --toml-path pyproject.toml $1
}

# Clean the subdirs, for safety and to guarantee integrity
./cleanup.sh

# Check for changes in the files compared to the repository
if ! git diff --quiet; then
  warn "Won't do it: there are changes in the repository. Please commit first!"
  exit 1
fi

# get the project inform
package_name=$(get_value project.name)
package_version=v$(get_value project.version) # add a 'v' in front (git convention)

# update Pypi
warn "Rebuilding $package_name..."
rm -rf build dist *.egg-info # necessary to guarantee integrity
PYTHON=$(which python3.11)
$PYTHON -m build
if twine upload dist/*; then
  git push # just in case
  warn "... create tag $package_version, and push to remote git repo..."
  git tag $package_version
  git push --tags
  warn "Done ($package_version)!"
else
  warn "Failed ($package_version)!"
  exit 1
fi