File: release.sh

package info (click to toggle)
lavacli 2.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 876 kB
  • sloc: python: 15,479; sh: 114; makefile: 30
file content (129 lines) | stat: -rwxr-xr-x 2,005 bytes parent folder | download | duplicates (2)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash

set -eu

###########
# Helpers #
###########
show_help() {
  cat << EOF
Usage: [-c] [-p] [-b] [-u] VERSION

Prepare, build and upload a new release

   -c  clean the current directory
   -p  prepare the release
   -b  build artefacts (pypi and debian)
   -u  upload the release
EOF
}


########################
# Command line parsing #
########################
FULL=1
CLEAN=0
PREPARE=0
BUILD=0
UPLOAD=0


while getopts "bcpuh" opt; do
  case $opt in
    c)
      CLEAN=1
      FULL=0
      ;;
    p)
      PREPARE=1
      FULL=0
      ;;
    b)
      BUILD=1
      FULL=0
      ;;
    u)
      UPLOAD=1
      FULL=0
      ;;
    h)
      show_help
      exit 0
      ;;
    ?)
      show_help >&2
      exit 1
  esac
done
shift "$((OPTIND-1))"

if [ "$FULL" = "1" ]
then
  BUILD=1
  CLEAN=1
  PREPARE=1
  UPLOAD=1
fi

TAG="$*"

if [ "$PREPARE" = "1" -a "$TAG" = "" ]
then
  echo "Missing version" >&2
  show_help >&2
  exit 1
fi

# clean
if [ "$CLEAN" = "1" ]
then
  echo "Cleaning..."
  rm -rf build-area dist lavacli.egg-info
  echo "done"
  echo
fi

# Prepare the release
if [ "$PREPARE" = "1" ]
then
  echo "Preparing..."
  echo "* debian/changelog"
  read
  export EMAIL=$(git config user.email)
  gbp dch --new-version="$TAG-1" --release --commit --commit-msg="Prepare for release v$TAG"
  echo "* lavacli/__about__.py version"
  read
  edit lavacli/__about__.py
  git commit --amend lavacli/__about__.py --message="Prepare for release v$TAG"
  echo "* git tag"
  read
  git tag --annotate --sign "v$TAG"
  echo "done"
  echo
fi

# Build the release artefacts
if [ "$BUILD" = "1" ]
then
  echo "Building..."
  python3 setup.py sdist
  gbp buildpackage -us -uc
  echo "done"
  echo
fi

if [ "$UPLOAD" = "1" ]
then
  echo "Uploading..."
  # Push the release
  echo "* git push --tags origin master"
  read
  git push --tags origin master
  # Uploading to pypi.org
  echo "* twine upload --repository lavacli dist"
  read
  twine upload --repository lavacli dist/*
  echo "done"
  echo
fi