forked from breathe-doc/breathe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkrelease
executable file
·121 lines (94 loc) · 1.77 KB
/
mkrelease
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
#!/bin/sh
set -eu
hash cd
hash git
hash gpg
hash mkdir
hash printf
hash python3
hash rm
hash tar
hash twine
# Melvin Vermeeren <[email protected]>
PGP_KEY='8AED 5802 1FEA CDD5 F27B A0E6 A72F 6277 16EA 9D96'
REPO_WWW='https://github.com/michaeljones/breathe'
help()
{
printf 'Usage: %s pack\n' "$0"
printf 'Usage: %s sign\n' "$0"
printf 'Usage: %s upload\n' "$0"
printf 'Usage: %s clean\n' "$0"
return 0
}
pack()
(
mkdir -- mkrelease_tmp
git archive \
--format=tar.gz \
--prefix="breathe-$version/" \
-o "mkrelease_tmp/breathe-$version.tar.gz" \
-- "v$version" \
cd -- mkrelease_tmp
tar -xf "breathe-$version.tar.gz"
cd -- "breathe-$version"
python3 setup.py sdist bdist_wheel
mv -- dist ..
cd -- ..
rm -r -- "breathe-$version"
exit 0
)
sign()
(
cd -- mkrelease_tmp
gpg -bu "$PGP_KEY" -- "breathe-$version.tar.gz"
for file in dist/*; do
gpg -bau "$PGP_KEY" -- "$file"
done
exit 0
)
upload()
(
cd -- mkrelease_tmp
twine upload -- dist/*
{
printf 'Note: Source tarball signature must be uploaded manually.\n'
printf '\tCreate a new release on GitHub for version: %s\n' "$version"
printf '\tThe source tarball itself must not be uploaded.\n'
printf '\t%s\n' "$REPO_WWW/releases/new?tag=v$version"
} >&2
exit 0
)
clean()
(
if [ -d mkrelease_tmp ]; then
rm -r -- mkrelease_tmp
fi
exit 0
)
if [ "$#" -eq 0 ]; then
help >&2
exit 1
fi
if [ ! -d .git ]; then
printf 'Error: Not executed from repository root\n' >&2
exit 1
fi
if ! version="$(git describe --tags --exact)"; then
printf 'Error: Cannot retrieve version from git.\n' >&2
exit 1
fi
version="${version#v}"
command="$1"
case "$command" in
pack|sign|upload|clean)
"$command"
;;
*)
{
printf 'Error: Unknown command: %s\n' "$command"
printf '\n'
help
} >&2
exit 1
esac
exit 0